]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemu: Refactor waiting for completed migration on destination
authorJiri Denemark <jdenemar@redhat.com>
Thu, 15 Oct 2015 17:49:22 +0000 (19:49 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Thu, 19 Nov 2015 08:41:23 +0000 (09:41 +0100)
Move the code from qemuMigrationFinish into a dedicated function.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
src/qemu/qemu_migration.c

index 3eee3a5930074d5d7e13e56ca6d35775831c220f..e6b3484fa3fbf1cfd17c6fb63269d83bbe555c29 100644 (file)
@@ -2763,6 +2763,28 @@ qemuMigrationWaitForCompletion(virQEMUDriverPtr driver,
 }
 
 
+static int
+qemuMigrationWaitForDestCompletion(virQEMUDriverPtr driver,
+                                   virDomainObjPtr vm,
+                                   qemuDomainAsyncJob asyncJob)
+{
+    qemuDomainObjPrivatePtr priv = vm->privateData;
+    int rv;
+
+    if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT))
+        return 0;
+
+    VIR_DEBUG("Waiting for incoming migration to complete");
+
+    while ((rv = qemuMigrationCompleted(driver, vm, asyncJob, NULL, 0)) != 1) {
+        if (rv < 0 || virDomainObjWait(vm) < 0)
+            return -1;
+    }
+
+    return 0;
+}
+
+
 static int
 qemuDomainMigrateGraphicsRelocate(virQEMUDriverPtr driver,
                                   virDomainObjPtr vm,
@@ -5731,22 +5753,13 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
         /* We need to wait for QEMU to process all data sent by the source
          * before starting guest CPUs.
          */
-        if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT)) {
-            int rv;
-            VIR_DEBUG("Waiting for migration to complete");
-            while ((rv = qemuMigrationCompleted(driver, vm,
-                                                QEMU_ASYNC_JOB_MIGRATION_IN,
-                                                NULL, 0)) != 1) {
-                if (rv < 0 || virDomainObjWait(vm) < 0) {
-                    /* There's not much we can do for v2 protocol since the
-                     * original domain on the source host is already gone.
-                     */
-                    if (v3proto)
-                        goto endjob;
-                    else
-                        break;
-                }
-            }
+        if (qemuMigrationWaitForDestCompletion(driver, vm,
+                                               QEMU_ASYNC_JOB_MIGRATION_IN) < 0) {
+            /* There's not much we can do for v2 protocol since the
+             * original domain on the source host is already gone.
+             */
+            if (v3proto)
+                goto endjob;
         }
 
         if (!(flags & VIR_MIGRATE_PAUSED)) {