From 8521898936a4205220607c3fcafe893154c81ad6 Mon Sep 17 00:00:00 2001 From: Zeng Junliang Date: Wed, 6 Nov 2013 11:36:57 +0800 Subject: [PATCH] qemu: clean up migration ports when migration cancelled If there's a migration cancelled, the bitmap of migration port should be cleaned up too. Signed-off-by: Zeng Junliang Signed-off-by: Jiri Denemark (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 d83293dcfe..58f90c2885 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -4341,12 +4341,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; @@ -4393,8 +4397,6 @@ qemuMigrationFinish(virQEMUDriverPtr driver, } qemuMigrationStopNBDServer(driver, vm, mig); - virPortAllocatorRelease(driver->migrationPorts, priv->migrationPort); - priv->migrationPort = 0; if (flags & VIR_MIGRATE_PERSIST_DEST) { virDomainDefPtr vmdef; @@ -4527,6 +4529,7 @@ endjob: } cleanup: + virPortAllocatorRelease(driver->migrationPorts, port); if (vm) { VIR_FREE(priv->origname); virObjectUnlock(vm);