[libvirt PATCH v2 67/81] qemu: Implement VIR_MIGRATE_POSTCOPY_RESUME for Finish phase

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

 



Everything was already done in the normal Finish phase and vCPUs are
running. We just need to wait for all remaining data to be transferred.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
Reviewed-by: Peter Krempa <pkrempa@xxxxxxxxxx>
Reviewed-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---

Notes:
    Version 2:
    - no change

 src/qemu/qemu_migration.c | 46 ++++++++++++++++++++++++++++++++++-----
 1 file changed, 40 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index dbebd215b4..a078cbcd41 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -6556,6 +6556,22 @@ qemuMigrationDstFinishFresh(virQEMUDriver *driver,
 }
 
 
+static int
+qemuMigrationDstFinishResume(virQEMUDriver *driver,
+                             virDomainObj *vm)
+{
+    VIR_DEBUG("vm=%p", vm);
+
+    if (qemuMigrationDstWaitForCompletion(driver, vm,
+                                          VIR_ASYNC_JOB_MIGRATION_IN,
+                                          false) < 0) {
+        return -1;
+    }
+
+    return 0;
+}
+
+
 static virDomainPtr
 qemuMigrationDstFinishActive(virQEMUDriver *driver,
                              virConnectPtr dconn,
@@ -6603,8 +6619,14 @@ qemuMigrationDstFinishActive(virQEMUDriver *driver,
         goto error;
     }
 
-    rc = qemuMigrationDstFinishFresh(driver, vm, mig, flags, v3proto,
-                                     timeReceived, &doKill, &inPostCopy);
+    if (flags & VIR_MIGRATE_POSTCOPY_RESUME) {
+        rc = qemuMigrationDstFinishResume(driver, vm);
+        inPostCopy = true;
+    } else {
+        rc = qemuMigrationDstFinishFresh(driver, vm, mig, flags, v3proto,
+                                         timeReceived, &doKill, &inPostCopy);
+    }
+
     if (rc < 0 ||
         !(dom = virGetDomain(dconn, vm->def->name, vm->def->uuid, vm->def->id)))
         goto error;
@@ -6675,6 +6697,8 @@ qemuMigrationDstFinish(virQEMUDriver *driver,
     qemuDomainObjPrivate *priv = vm->privateData;
     unsigned short port;
     unsigned long long timeReceived = 0;
+    int phase = v3proto ? QEMU_MIGRATION_PHASE_FINISH3
+                        : QEMU_MIGRATION_PHASE_FINISH2;
 
     VIR_DEBUG("driver=%p, dconn=%p, vm=%p, cookiein=%s, cookieinlen=%d, "
               "cookieout=%p, cookieoutlen=%p, flags=0x%lx, retcode=%d",
@@ -6689,14 +6713,24 @@ qemuMigrationDstFinish(virQEMUDriver *driver,
         goto cleanup;
     }
 
+    if (flags & VIR_MIGRATE_POSTCOPY_RESUME) {
+        if (!qemuMigrationAnyCanResume(vm, VIR_ASYNC_JOB_MIGRATION_IN, flags,
+                                       QEMU_MIGRATION_PHASE_PREPARE_RESUME))
+            goto cleanup;
+        phase = QEMU_MIGRATION_PHASE_FINISH_RESUME;
+    }
     ignore_value(virTimeMillisNow(&timeReceived));
 
-    if (qemuMigrationJobStartPhase(vm,
-                                   v3proto ? QEMU_MIGRATION_PHASE_FINISH3
-                                           : QEMU_MIGRATION_PHASE_FINISH2) < 0)
+    if (qemuMigrationJobStartPhase(vm, phase) < 0)
         goto cleanup;
 
-    qemuDomainCleanupRemove(vm, qemuMigrationDstPrepareCleanup);
+    if (flags & VIR_MIGRATE_POSTCOPY_RESUME) {
+        virCloseCallbacksUnset(driver->closeCallbacks, vm,
+                               qemuMigrationAnyConnectionClosed);
+        qemuDomainCleanupRemove(vm, qemuProcessCleanupMigrationJob);
+    } else {
+        qemuDomainCleanupRemove(vm, qemuMigrationDstPrepareCleanup);
+    }
     g_clear_pointer(&priv->job.completed, virDomainJobDataFree);
 
     cookie_flags = QEMU_MIGRATION_COOKIE_NETWORK |
-- 
2.35.1




[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]

  Powered by Linux