At the end of migration, it is important to stop NBD
server and thus release all allocated resources.
---
src/qemu/qemu_migration.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index f362a63..8df7d5f 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1492,6 +1492,32 @@ cleanup:
return ret;
}
+static void
+qemuMigrationStopNBDServer(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ qemuMigrationCookiePtr mig)
+{
+ qemuDomainObjPrivatePtr priv = vm->privateData;
+
+ if (!mig->nbd)
+ return;
+
+ if (mig->nbd->port != -1)
+ VIR_WARN("This is strange. NBD port was not -1 "
+ "when shutting NDB server down");
+
+ if (qemuDomainObjEnterMonitorAsync(driver, vm,
+ QEMU_ASYNC_JOB_MIGRATION_IN) < 0) {
+ VIR_WARN("Unable to enter monitor");
+ return;
+ }
+
+ if (qemuMonitorNBDServerStop(priv->mon) < 0)
+ VIR_WARN("Unable to stop NBD server");
+
+ qemuDomainObjExitMonitorWithDriver(driver, vm);
+}
+
/* Validate whether the domain is safe to migrate. If vm is NULL,
* then this is being run in the v2 Prepare stage on the destination
* (where we only have the target xml); if vm is provided, then this
@@ -3882,6 +3908,8 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
VIR_WARN("unable to provide network data for relocation");
}
+ qemuMigrationStopNBDServer(driver, vm, mig);
+
if (flags & VIR_MIGRATE_PERSIST_DEST) {
virDomainDefPtr vmdef;
if (vm->persistent)
--
1.8.0.2