[PATCH 09/16] qemu: Add support for VIR_MIGRATE_POSTCOPY_AFTER_PRECOPY flag

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/qemu/qemu_migration.c | 16 ++++++++++++++++
 src/qemu/qemu_migration.h |  3 ++-
 src/qemu/qemu_process.c   |  3 +++
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 7ccb0ba..296e54e 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2718,6 +2718,7 @@ enum qemuMigrationCompletedFlags {
     QEMU_MIGRATION_COMPLETED_CHECK_STORAGE  = (1 << 1),
     QEMU_MIGRATION_COMPLETED_UPDATE_STATS   = (1 << 2),
     QEMU_MIGRATION_COMPLETED_POSTCOPY       = (1 << 3),
+    QEMU_MIGRATION_COMPLETED_POSTCOPY_AUTO  = (1 << 4),
 };
 
 /**
@@ -2815,6 +2816,19 @@ qemuMigrationWaitForCompletion(virQEMUDriverPtr driver,
         if (rv < 0)
             return rv;
 
+        if (flags & QEMU_MIGRATION_COMPLETED_POSTCOPY_AUTO &&
+            priv->job.postcopyEnabled &&
+            jobInfo->stats.ram_iteration > 1) {
+            flags ^= QEMU_MIGRATION_COMPLETED_POSTCOPY_AUTO;
+
+            VIR_DEBUG("One pre-copy iteration finished; switching to post-copy");
+            if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
+                return -2;
+            rv = qemuMonitorMigrateStartPostCopy(priv->mon);
+            if (qemuDomainObjExitMonitor(driver, vm) < 0 || rv < 0)
+                return -2;
+        }
+
         if (events) {
             if (virDomainObjWait(vm) < 0) {
                 jobInfo->type = VIR_DOMAIN_JOB_FAILED;
@@ -4659,6 +4673,8 @@ qemuMigrationRun(virQEMUDriverPtr driver,
         waitFlags |= QEMU_MIGRATION_COMPLETED_CHECK_STORAGE;
     if (flags & VIR_MIGRATE_POSTCOPY)
         waitFlags |= QEMU_MIGRATION_COMPLETED_POSTCOPY;
+    if (flags & VIR_MIGRATE_POSTCOPY_AFTER_PRECOPY)
+        waitFlags |= QEMU_MIGRATION_COMPLETED_POSTCOPY_AUTO;
 
     rc = qemuMigrationWaitForCompletion(driver, vm,
                                         QEMU_ASYNC_JOB_MIGRATION_OUT,
diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
index e30b2ec..ccef71b 100644
--- a/src/qemu/qemu_migration.h
+++ b/src/qemu/qemu_migration.h
@@ -42,7 +42,8 @@
      VIR_MIGRATE_ABORT_ON_ERROR |               \
      VIR_MIGRATE_AUTO_CONVERGE |                \
      VIR_MIGRATE_RDMA_PIN_ALL |                 \
-     VIR_MIGRATE_POSTCOPY)
+     VIR_MIGRATE_POSTCOPY |                     \
+     VIR_MIGRATE_POSTCOPY_AFTER_PRECOPY)
 
 /* All supported migration parameters and their types. */
 # define QEMU_MIGRATION_PARAMETERS                                \
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 5ced279..e067c3f 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1552,6 +1552,9 @@ qemuProcessHandleMigrationPass(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
+    priv->job.current->stats.ram_iteration = pass;
+    virDomainObjBroadcast(vm);
+
     qemuDomainEventQueue(driver,
                          virDomainEventMigrationIterationNewFromObj(vm, pass));
 
-- 
2.7.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]