]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: add support for qemu switchover-ack
authorJon Kohler <jon@nutanix.com>
Mon, 24 Jun 2024 17:38:51 +0000 (10:38 -0700)
committerJiri Denemark <jdenemar@redhat.com>
Tue, 25 Jun 2024 07:51:00 +0000 (09:51 +0200)
Add plumbing for QEMU's switchover-ack migration capability, which
helps lower the downtime during VFIO migrations. This capability is
enabled by default as long as both the source and destination support
it.

Note: switchover-ack depends on the return path capability, so this may
not be used when VIR_MIGRATE_TUNNELLED flag is set.

Extensive details about the qemu switchover-ack implementation are
available in the qemu series v6 cover letter [1] where the highlight is
the extreme reduction in guest visible downtime. In addition to the
original test results below, I saw a roughly ~20% reduction in downtime
for VFIO VGPU devices at minimum.

  === Test results ===

  The below table shows the downtime of two identical migrations. In the
  first migration swithcover ack is disabled and in the second it is
  enabled. The migrated VM is assigned with a mlx5 VFIO device which has
  300MB of device data to be migrated.

  +----------------------+-----------------------+----------+
  |    Switchover ack    | VFIO device data size | Downtime |
  +----------------------+-----------------------+----------+
  |       Disabled       |         300MB         |  1900ms  |
  |       Enabled        |         300MB         |  420ms   |
  +----------------------+-----------------------+----------+

  Switchover ack gives a roughly 4.5 times improvement in downtime.
  The 1480ms difference is time that is used for resource allocation for
  the VFIO device in the destination. Without switchover ack, this time is
  spent when the source VM is stopped and thus the downtime is much
  higher. With switchover ack, the time is spent when the source VM is
  still running.

[1] https://patchwork.kernel.org/project/qemu-devel/cover/20230621111201.29729-1-avihaih@nvidia.com/

Signed-off-by: Jon Kohler <jon@nutanix.com>
Cc: Alex Williamson <alex.williamson@redhat.com>
Cc: Avihai Horon <avihaih@nvidia.com>
Cc: Markus Armbruster <armbru@redhat.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: YangHang Liu <yanghliu@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
src/qemu/qemu_migration_params.c
src/qemu/qemu_migration_params.h

index 48f8657f716d0ff42f3623e4ce3544d2c5e64e01..9593b6ba65dc9c8e9936ec63f08aa97c1af42eb9 100644 (file)
@@ -105,6 +105,7 @@ VIR_ENUM_IMPL(qemuMigrationCapability,
               "return-path",
               "zero-copy-send",
               "postcopy-preempt",
+              "switchover-ack",
 );
 
 
@@ -138,7 +139,7 @@ struct _qemuMigrationParamsAlwaysOnItem {
 typedef struct _qemuMigrationParamsFlagMapItem qemuMigrationParamsFlagMapItem;
 struct _qemuMigrationParamsFlagMapItem {
     /* Describes what to do with the capability if @flag is found.
-     * When se to QEMU_MIGRATION_FLAG_REQUIRED, the capability will be
+     * When set to QEMU_MIGRATION_FLAG_REQUIRED, the capability will be
      * enabled iff the specified migration flag is enabled. On the other hand
      * QEMU_MIGRATION_FLAG_FORBIDDEN will enable the capability as long as
      * the specified migration flag is not enabled. */
@@ -215,6 +216,11 @@ static const qemuMigrationParamsFlagMapItem qemuMigrationParamsFlagMap[] = {
      .flag = VIR_MIGRATE_ZEROCOPY,
      .cap = QEMU_MIGRATION_CAP_ZERO_COPY_SEND,
      .party = QEMU_MIGRATION_SOURCE},
+
+    {.match = QEMU_MIGRATION_FLAG_FORBIDDEN,
+     .flag = VIR_MIGRATE_TUNNELLED,
+     .cap = QEMU_MIGRATION_CAP_SWITCHOVER_ACK,
+     .party = QEMU_MIGRATION_SOURCE | QEMU_MIGRATION_DESTINATION},
 };
 
 /* Translation from VIR_MIGRATE_PARAM_* typed parameters to
index 91bc6792cd928c3bb22bca4f3b3c58a6eebcc834..df67f1fb92603adc9ef927924c3e32313c83f761 100644 (file)
@@ -41,6 +41,7 @@ typedef enum {
     QEMU_MIGRATION_CAP_RETURN_PATH,
     QEMU_MIGRATION_CAP_ZERO_COPY_SEND,
     QEMU_MIGRATION_CAP_POSTCOPY_PREEMPT,
+    QEMU_MIGRATION_CAP_SWITCHOVER_ACK,
 
     QEMU_MIGRATION_CAP_LAST
 } qemuMigrationCapability;