43fe83
From 83fad420027989538efa19d7009a65feb6524c28 Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <83fad420027989538efa19d7009a65feb6524c28.1383922565.git.jdenemar@redhat.com>
43fe83
From: Zeng Junliang <zengjunliang@huawei.com>
43fe83
Date: Wed, 6 Nov 2013 15:22:26 +0100
43fe83
Subject: [PATCH] qemu: clean up migration ports when migration cancelled
43fe83
43fe83
https://bugzilla.redhat.com/show_bug.cgi?id=1019237
43fe83
43fe83
If there's a migration cancelled, the bitmap of migration port should be
43fe83
cleaned up too.
43fe83
43fe83
Signed-off-by: Zeng Junliang <zengjunliang@huawei.com>
43fe83
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
43fe83
(cherry picked from commit c92ca769af2bacefdd451802d7eb1adac5e6597c)
43fe83
---
43fe83
 src/qemu/qemu_migration.c | 7 +++++--
43fe83
 1 file changed, 5 insertions(+), 2 deletions(-)
43fe83
43fe83
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
43fe83
index 4222a10..379e381 100644
43fe83
--- a/src/qemu/qemu_migration.c
43fe83
+++ b/src/qemu/qemu_migration.c
43fe83
@@ -4381,12 +4381,16 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
43fe83
     qemuDomainObjPrivatePtr priv = vm->privateData;
43fe83
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
43fe83
     virCapsPtr caps = NULL;
43fe83
+    unsigned short port;
43fe83
 
43fe83
     VIR_DEBUG("driver=%p, dconn=%p, vm=%p, cookiein=%s, cookieinlen=%d, "
43fe83
               "cookieout=%p, cookieoutlen=%p, flags=%lx, retcode=%d",
43fe83
               driver, dconn, vm, NULLSTR(cookiein), cookieinlen,
43fe83
               cookieout, cookieoutlen, flags, retcode);
43fe83
 
43fe83
+    port = priv->migrationPort;
43fe83
+    priv->migrationPort = 0;
43fe83
+
43fe83
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
43fe83
         goto cleanup;
43fe83
 
43fe83
@@ -4433,8 +4437,6 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
43fe83
         }
43fe83
 
43fe83
         qemuMigrationStopNBDServer(driver, vm, mig);
43fe83
-        virPortAllocatorRelease(driver->migrationPorts, priv->migrationPort);
43fe83
-        priv->migrationPort = 0;
43fe83
 
43fe83
         if (flags & VIR_MIGRATE_PERSIST_DEST) {
43fe83
             virDomainDefPtr vmdef;
43fe83
@@ -4567,6 +4569,7 @@ endjob:
43fe83
     }
43fe83
 
43fe83
 cleanup:
43fe83
+    virPortAllocatorRelease(driver->migrationPorts, port);
43fe83
     if (vm) {
43fe83
         VIR_FREE(priv->origname);
43fe83
         virObjectUnlock(vm);
43fe83
-- 
43fe83
1.8.4.2
43fe83