It should not be needed in all qemuMigrationSet* functions,
but I changed them all for consistency.
---
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 0acbb57..ed7d6fe 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1662,7 +1662,8 @@ qemuMigrationStartNBDServer(virQEMUDriverPtr driver,
qemuDomainObjExitMonitor(driver, vm);
goto cleanup;
}
- qemuDomainObjExitMonitor(driver, vm);
+ if (qemuDomainObjExitMonitorAlive(driver, vm) < 0)
+ goto cleanup;
}
priv->nbdPort = port;
@@ -1859,7 +1860,7 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
}
-static void
+static int
qemuMigrationStopNBDServer(virQEMUDriverPtr driver,
virDomainObjPtr vm,
qemuMigrationCookiePtr mig)
@@ -1867,22 +1868,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 (qemuDomainObjExitMonitorAlive(driver, vm) < 0)
+ return -1;
+ return 0;
}
-static void
+static int
qemuMigrationCancelDriveMirror(qemuMigrationCookiePtr mig,
virQEMUDriverPtr driver,
virDomainObjPtr vm)
@@ -1890,6 +1892,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);
@@ -1913,12 +1916,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 (qemuDomainObjExitMonitorAlive(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,
@@ -2124,7 +2130,8 @@ qemuMigrationSetCompression(virQEMUDriverPtr driver,
state);
cleanup:
- qemuDomainObjExitMonitor(driver, vm);
+ if (qemuDomainObjExitMonitorAlive(driver, vm) < 0)
+ ret = -1;
return ret;
}
@@ -2163,7 +2170,8 @@ qemuMigrationSetAutoConverge(virQEMUDriverPtr driver,
state);
cleanup:
- qemuDomainObjExitMonitor(driver, vm);
+ if (qemuDomainObjExitMonitorAlive(driver, vm) < 0)
+ ret = -1;
return ret;
}
@@ -2209,7 +2217,8 @@ qemuMigrationSetPinAll(virQEMUDriverPtr driver,
state);
cleanup:
- qemuDomainObjExitMonitor(driver, vm);
+ if (qemuDomainObjExitMonitorAlive(driver, vm) < 0)
+ ret = -1;
return ret;
}
@@ -2475,7 +2484,8 @@ qemuDomainMigrateGraphicsRelocate(virQEMUDriverPtr driver,
QEMU_ASYNC_JOB_MIGRATION_OUT) == 0) {
ret = qemuMonitorGraphicsRelocate(priv->mon, type, listenAddress,
port, tlsPort, tlsSubject);
- qemuDomainObjExitMonitor(driver, vm);
+ if (qemuDomainObjExitMonitorAlive(driver, vm) < 0)
+ ret = -1;
}
cleanup:
@@ -4020,7 +4030,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)
@@ -5171,7 +5181,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