Skip to contentSkip to conversation

yank: Unregister function when using TLS migration

PATCH Superseded Leonardo Bras 2 participants 3 messages May 26, 2021 – May 27, 2021

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 yank: Unregister function when using TLS migration

After yank feature was introduced, whenever migration is started using TLS, the following error happens in both source and destination hosts:

(qemu) qemu-kvm: ../util/yank.c:107: yank_unregister_instance:
Assertion `QLIST_EMPTY(&entry->yankfns)' failed.

This happens because of a missing yank_unregister_function() when using qio-channel-tls.

Fix this by also allowing TYPE_QIO_CHANNEL_TLS object type to perform yank_unregister_function() in channel_close() and multifd_load_cleanup().

Fixes 50186051f ("Introduce yank feature")

--
Changes since v1:
- Cast p->c to QIOChannelTLS into multifd_load_cleanup()

---
 migration/multifd.c           | 6 ++++++
 migration/qemu-file-channel.c | 7 +++++++
 2 files changed, 13 insertions(+)
migration/multifd.c +6 -0
index 0a4803cfcc..81de11c6fc 100644
@@ -992,6 +992,12 @@ int multifd_load_cleanup(Error **errp)
             yank_unregister_function(MIGRATION_YANK_INSTANCE,
                                      migration_yank_iochannel,
                                      QIO_CHANNEL(p->c));
+        } else if (object_dynamic_cast(OBJECT(p->c), TYPE_QIO_CHANNEL_TLS)
+                   && OBJECT(p->c)->ref == 1) {
+            QIOChannelTLS *tioc = QIO_CHANNEL_TLS(p->c);
+            yank_unregister_function(MIGRATION_YANK_INSTANCE,
+                                     migration_yank_iochannel,
+                                     QIO_CHANNEL(tioc->master));
         }
 
         object_unref(OBJECT(p->c));
migration/qemu-file-channel.c +7 -0
index 876d05a540..4f79090f3f 100644
@@ -26,6 +26,7 @@
 #include "qemu-file-channel.h"
 #include "qemu-file.h"
 #include "io/channel-socket.h"
+#include "io/channel-tls.h"
 #include "qemu/iov.h"
 #include "qemu/yank.h"
 #include "yank_functions.h"
@@ -111,6 +112,12 @@ static int channel_close(void *opaque, Error **errp)
         yank_unregister_function(MIGRATION_YANK_INSTANCE,
                                  migration_yank_iochannel,
                                  QIO_CHANNEL(ioc));
+    } else if (object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_TLS)
+               && OBJECT(ioc)->ref == 1) {
+        QIOChannelTLS *tioc = opaque;
+        yank_unregister_function(MIGRATION_YANK_INSTANCE,
+                                 migration_yank_iochannel,
+                                 QIO_CHANNEL(tioc->master));
     }
     object_unref(OBJECT(ioc));
     return ret;
Signature · 1 line
2.31.1
#1 lore raw
CC Daniel P. Berrange <[email protected]>
Quoted 71 lines · Leonardo Bras

After yank feature was introduced, whenever migration is started using TLS,
the following error happens in both source and destination hosts:

(qemu) qemu-kvm: ../util/yank.c:107: yank_unregister_instance:
Assertion `QLIST_EMPTY(&entry->yankfns)' failed.

This happens because of a missing yank_unregister_function() when using qio-channel-tls.

Fix this by also allowing TYPE_QIO_CHANNEL_TLS object type to perform yank_unregister_function() in channel_close() and multifd_load_cleanup().

Fixes 50186051f ("Introduce yank feature")

--
Changes since v1:
- Cast p->c to QIOChannelTLS into multifd_load_cleanup()
---
 migration/multifd.c           | 6 ++++++ migration/qemu-file-channel.c | 7 +++++++

 2 files changed, 13 insertions(+)
migration/multifd.c +6 -0
index 0a4803cfcc..81de11c6fc 100644
@@ -992,6 +992,12 @@ int multifd_load_cleanup(Error **errp)
              yank_unregister_function(MIGRATION_YANK_INSTANCE,
                                       migration_yank_iochannel,
                                       QIO_CHANNEL(p->c));
+        } else if (object_dynamic_cast(OBJECT(p->c),
 TYPE_QIO_CHANNEL_TLS)
+                   && OBJECT(p->c)->ref == 1) {
+            QIOChannelTLS *tioc = QIO_CHANNEL_TLS(p->c);
+            yank_unregister_function(MIGRATION_YANK_INSTANCE,
+                                     migration_yank_iochannel,
+                                     QIO_CHANNEL(tioc->master));
          }


         object_unref(OBJECT(p->c));

migration/qemu-file- renamed from migration/qemu-file-channel.c +0 -0

channel.c
index 876d05a540..4f79090f3f 100644

migration/qemu-file-channel.c +7 -0
@@ -26,6 +26,7 @@
  #include "qemu-file-channel.h"
  #include "qemu-file.h"
  #include "io/channel-socket.h"
+#include "io/channel-tls.h"
  #include "qemu/iov.h"
  #include "qemu/yank.h"
  #include "yank_functions.h"
@@ -111,6 +112,12 @@ static int channel_close(void *opaque, Error
 **errp)
          yank_unregister_function(MIGRATION_YANK_INSTANCE,
                                   migration_yank_iochannel,
                                   QIO_CHANNEL(ioc));
+    } else if (object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_TLS)
+               && OBJECT(ioc)->ref == 1) {
+        QIOChannelTLS *tioc = opaque;
+        yank_unregister_function(MIGRATION_YANK_INSTANCE,
+                                 migration_yank_iochannel,
+                                 QIO_CHANNEL(tioc->master));
      }
      object_unref(OBJECT(ioc));

     return ret;

#2 lore raw
In reply to Leonardo Bras
Quoted 9 lines · Leonardo Bras

After yank feature was introduced, whenever migration is started using TLS, the following error happens in both source and destination hosts:

(qemu) qemu-kvm: ../util/yank.c:107: yank_unregister_instance:
Assertion `QLIST_EMPTY(&entry->yankfns)' failed.

This happens because of a missing yank_unregister_function() when using qio-channel-tls.

Quoted 6 lines

Fix this by also allowing TYPE_QIO_CHANNEL_TLS object type to perform yank_unregister_function() in channel_close() and multifd_load_cleanup().

Fixes 50186051f ("Introduce yank feature")

Assuming you'll post a v3 soon trying to drop all references to ioc->master as we've discussed. Meanwhile it should possibly be b5eea99ec2f ("migration: Add yank feature", 2021-01-13) for the "fixes:"?

Signature · 1 line
Peter Xu