[PATCHv2 10/14] Exit early after domain crash in monitor on migration

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

 



---
 src/qemu/qemu_migration.c | 41 ++++++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 15 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 77e0b35..31494c8 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1663,7 +1663,8 @@ qemuMigrationStartNBDServer(virQEMUDriverPtr driver,
             qemuDomainObjExitMonitor(driver, vm);
             goto cleanup;
         }
-        qemuDomainObjExitMonitor(driver, vm);
+        if (qemuDomainObjExitMonitor(driver, vm) < 0)
+            goto cleanup;
     }
 
     priv->nbdPort = port;
@@ -1860,7 +1861,7 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
 }
 
 
-static void
+static int
 qemuMigrationStopNBDServer(virQEMUDriverPtr driver,
                            virDomainObjPtr vm,
                            qemuMigrationCookiePtr mig)
@@ -1868,22 +1869,23 @@ qemuMigrationStopNBDServer(virQEMUDriverPtr driver,
     qemuDomainObjPrivatePtr priv = vm->privateData;
 
     if (!mig->nbd)
-        return;
+        return 0;
 
     if (qemuDomainObjEnterMonitorAsync(driver, vm,
                                        QEMU_ASYNC_JOB_MIGRATION_IN) < 0)
-        return;
+        return -1;
 
     if (qemuMonitorNBDServerStop(priv->mon) < 0)
         VIR_WARN("Unable to stop NBD server");
 
-    qemuDomainObjExitMonitor(driver, vm);
-
     virPortAllocatorRelease(driver->migrationPorts, priv->nbdPort);
     priv->nbdPort = 0;
+    if (qemuDomainObjExitMonitor(driver, vm) < 0)
+        return -1;
+    return 0;
 }
 
-static void
+static int
 qemuMigrationCancelDriveMirror(qemuMigrationCookiePtr mig,
                                virQEMUDriverPtr driver,
                                virDomainObjPtr vm)
@@ -1891,6 +1893,7 @@ qemuMigrationCancelDriveMirror(qemuMigrationCookiePtr mig,
     qemuDomainObjPrivatePtr priv = vm->privateData;
     size_t i;
     char *diskAlias = NULL;
+    int ret = 0;
 
     VIR_DEBUG("mig=%p nbdPort=%d", mig->nbd, priv->nbdPort);
 
@@ -1914,12 +1917,15 @@ qemuMigrationCancelDriveMirror(qemuMigrationCookiePtr mig,
         if (qemuMonitorBlockJob(priv->mon, diskAlias, NULL, NULL, 0,
                                 BLOCK_JOB_ABORT, true) < 0)
             VIR_WARN("Unable to stop block job on %s", diskAlias);
-        qemuDomainObjExitMonitor(driver, vm);
+        if (qemuDomainObjExitMonitor(driver, vm) < 0) {
+            ret = -1;
+            goto cleanup;
+        }
     }
 
  cleanup:
     VIR_FREE(diskAlias);
-    return;
+    return ret;
 }
 
 /* Validate whether the domain is safe to migrate.  If vm is NULL,
@@ -2125,7 +2131,8 @@ qemuMigrationSetCompression(virQEMUDriverPtr driver,
                 state);
 
  cleanup:
-    qemuDomainObjExitMonitor(driver, vm);
+    if (qemuDomainObjExitMonitor(driver, vm) < 0)
+        ret = -1;
     return ret;
 }
 
@@ -2164,7 +2171,8 @@ qemuMigrationSetAutoConverge(virQEMUDriverPtr driver,
                 state);
 
  cleanup:
-    qemuDomainObjExitMonitor(driver, vm);
+    if (qemuDomainObjExitMonitor(driver, vm) < 0)
+        ret = -1;
     return ret;
 }
 
@@ -2210,7 +2218,8 @@ qemuMigrationSetPinAll(virQEMUDriverPtr driver,
                 state);
 
  cleanup:
-    qemuDomainObjExitMonitor(driver, vm);
+    if (qemuDomainObjExitMonitor(driver, vm) < 0)
+        ret = -1;
     return ret;
 }
 
@@ -2476,7 +2485,8 @@ qemuDomainMigrateGraphicsRelocate(virQEMUDriverPtr driver,
                                        QEMU_ASYNC_JOB_MIGRATION_OUT) == 0) {
         ret = qemuMonitorGraphicsRelocate(priv->mon, type, listenAddress,
                                           port, tlsPort, tlsSubject);
-        qemuDomainObjExitMonitor(driver, vm);
+        if (qemuDomainObjExitMonitor(driver, vm) < 0)
+            ret = -1;
     }
 
  cleanup:
@@ -4000,7 +4010,7 @@ qemuMigrationRun(virQEMUDriverPtr driver,
 
     /* cancel any outstanding NBD jobs */
     if (mig)
-        qemuMigrationCancelDriveMirror(mig, driver, vm);
+        ignore_value(qemuMigrationCancelDriveMirror(mig, driver, vm));
 
     if (spec->fwdType != MIGRATION_FWD_DIRECT) {
         if (iothread && qemuMigrationStopTunnel(iothread, ret < 0) < 0)
@@ -5142,7 +5152,8 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
                     VIR_WARN("unable to provide network data for relocation");
         }
 
-        qemuMigrationStopNBDServer(driver, vm, mig);
+        if (qemuMigrationStopNBDServer(driver, vm, mig) < 0)
+            goto endjob;
 
         if (flags & VIR_MIGRATE_PERSIST_DEST) {
             virDomainDefPtr vmdef;
-- 
2.0.4

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