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 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index f8e52fb..14be00b 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1486,6 +1486,32 @@ cleanup:
return ret;
}
+static void
+qemuMigrationStopNBDServer(struct qemud_driver *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
@@ -3781,6 +3807,8 @@ qemuMigrationFinish(struct qemud_driver *driver,
if (qemuDomainMigrateOPDRelocate(driver, vm, mig) < 0)
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.7.8.6