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 0100a6f..f53fcf6 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
@@ -3792,6 +3818,8 @@ qemuMigrationFinish(virQEMUDriverPtr 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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to