render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
Blob Blame History Raw
From 83fad420027989538efa19d7009a65feb6524c28 Mon Sep 17 00:00:00 2001
Message-Id: <83fad420027989538efa19d7009a65feb6524c28.1383922565.git.jdenemar@redhat.com>
From: Zeng Junliang <zengjunliang@huawei.com>
Date: Wed, 6 Nov 2013 15:22:26 +0100
Subject: [PATCH] qemu: clean up migration ports when migration cancelled

https://bugzilla.redhat.com/show_bug.cgi?id=1019237

If there's a migration cancelled, the bitmap of migration port should be
cleaned up too.

Signed-off-by: Zeng Junliang <zengjunliang@huawei.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
(cherry picked from commit c92ca769af2bacefdd451802d7eb1adac5e6597c)
---
 src/qemu/qemu_migration.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 4222a10..379e381 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -4381,12 +4381,16 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
     qemuDomainObjPrivatePtr priv = vm->privateData;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
     virCapsPtr caps = NULL;
+    unsigned short port;
 
     VIR_DEBUG("driver=%p, dconn=%p, vm=%p, cookiein=%s, cookieinlen=%d, "
               "cookieout=%p, cookieoutlen=%p, flags=%lx, retcode=%d",
               driver, dconn, vm, NULLSTR(cookiein), cookieinlen,
               cookieout, cookieoutlen, flags, retcode);
 
+    port = priv->migrationPort;
+    priv->migrationPort = 0;
+
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto cleanup;
 
@@ -4433,8 +4437,6 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
         }
 
         qemuMigrationStopNBDServer(driver, vm, mig);
-        virPortAllocatorRelease(driver->migrationPorts, priv->migrationPort);
-        priv->migrationPort = 0;
 
         if (flags & VIR_MIGRATE_PERSIST_DEST) {
             virDomainDefPtr vmdef;
@@ -4567,6 +4569,7 @@ endjob:
     }
 
 cleanup:
+    virPortAllocatorRelease(driver->migrationPorts, port);
     if (vm) {
         VIR_FREE(priv->origname);
         virObjectUnlock(vm);
-- 
1.8.4.2