]> xenbits.xensource.com Git - people/aperard/libvirt.git/commitdiff
qemu: Enable postcopy-preempt migration capability
authorJiri Denemark <jdenemar@redhat.com>
Fri, 5 Jan 2024 11:43:59 +0000 (12:43 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Mon, 8 Jan 2024 21:41:23 +0000 (22:41 +0100)
During post-copy migration (once it actually switches to post-copy mode)
dirty memory pages are continued to be migrated iteratively, while the
destination can explicitly request a specific page to be migrated before
the iterative process gets to it (which happens when a guest wants to
read a page that was not migrated yet). Without the postcopy-preempt
capability enabled such pages need to wait until all other pages already
queued are transferred. Enabling this capability will instruct the
hypervisor to create a separate migration channel for explicitly
requested pages so that they can preempt the queue.

The only requirement for the feature to work is running a migration over
a protocol that supports multiple connections. In other words, we can't
pre-create the connection and pass its file descriptor to QEMU (i.e.,
using MIGRATION_DEST_CONNECT_SOCKET), but we have to let QEMU open the
connections itself (using MIGRATION_DEST_SOCKET). This change is applied
to all post-copy migrations even if postcopy-preempt is not supported to
avoid making the code even uglier than it is now. There's no real
difference between the two methods with modern QEMU (which can properly
report connection failures) anyway.

This capability is enabled for all post-copy migration as long as the
capability is supported on both sides of migration.

https://issues.redhat.com/browse/RHEL-7100

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_migration.c
src/qemu/qemu_migration_params.c
src/qemu/qemu_migration_params.h

index 55041190793c0480aad4f45e1b96181c6c6954c2..25dc16a9e9098bc314d73859827dcee7499cc73e 100644 (file)
@@ -5203,17 +5203,20 @@ qemuMigrationSrcPerformNative(virQEMUDriver *driver,
             return -1;
         }
 
-        if (flags & VIR_MIGRATE_PARALLEL)
+        /* multi-fd and postcopy-preempt require QEMU to connect to the
+         * destination itself */
+        if (flags & (VIR_MIGRATE_PARALLEL | VIR_MIGRATE_POSTCOPY))
             spec.destType = MIGRATION_DEST_SOCKET;
         else
             spec.destType = MIGRATION_DEST_CONNECT_SOCKET;
 
         spec.dest.socket.path = uribits->path;
     } else {
-        /* RDMA and multi-fd migration requires QEMU to connect to the destination
-         * itself.
+        /* RDMA, multi-fd, and postcopy-preempt migration require QEMU to
+         * connect to the destination itself.
          */
-        if (STREQ(uribits->scheme, "rdma") || (flags & VIR_MIGRATE_PARALLEL))
+        if (STREQ(uribits->scheme, "rdma") ||
+            flags & (VIR_MIGRATE_PARALLEL | VIR_MIGRATE_POSTCOPY))
             spec.destType = MIGRATION_DEST_HOST;
         else
             spec.destType = MIGRATION_DEST_CONNECT_HOST;
index cdf437b51c4a8453778dca4ea888e61f28485e68..e955822f68f715b0242feee0c8e68bdc461066e9 100644 (file)
@@ -104,6 +104,7 @@ VIR_ENUM_IMPL(qemuMigrationCapability,
               "dirty-bitmaps",
               "return-path",
               "zero-copy-send",
+              "postcopy-preempt",
 );
 
 
@@ -197,6 +198,7 @@ static const qemuMigrationParamsFlagMapItem qemuMigrationParamsFlagMap[] = {
     {.match = QEMU_MIGRATION_FLAG_REQUIRED,
      .flag = VIR_MIGRATE_POSTCOPY,
      .cap = QEMU_MIGRATION_CAP_POSTCOPY,
+     .optional = QEMU_MIGRATION_CAP_POSTCOPY_PREEMPT,
      .party = QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION},
 
     {.match = QEMU_MIGRATION_FLAG_REQUIRED,
index 115d7bc5979586ec1aa507de9ced305e77042fcf..91bc6792cd928c3bb22bca4f3b3c58a6eebcc834 100644 (file)
@@ -40,6 +40,7 @@ typedef enum {
     QEMU_MIGRATION_CAP_BLOCK_DIRTY_BITMAPS,
     QEMU_MIGRATION_CAP_RETURN_PATH,
     QEMU_MIGRATION_CAP_ZERO_COPY_SEND,
+    QEMU_MIGRATION_CAP_POSTCOPY_PREEMPT,
 
     QEMU_MIGRATION_CAP_LAST
 } qemuMigrationCapability;