]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Always remove domain object if MigratePrepare fails
authorJiri Denemark <jdenemar@redhat.com>
Mon, 26 Sep 2011 11:36:37 +0000 (13:36 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Wed, 28 Sep 2011 07:57:30 +0000 (09:57 +0200)
If migration failed in Prepare phase after virDomainAssignDef and before
a job was started, the domain object was not properly removed.

src/qemu/qemu_migration.c

index ef48d65af03368aa4ccc35b379b7ef04bb422cbd..be6d0e0f415b4289f64d1798d0c65efc64856044 100644 (file)
@@ -1178,8 +1178,12 @@ cleanup:
     virDomainDefFree(def);
     VIR_FORCE_CLOSE(dataFD[0]);
     VIR_FORCE_CLOSE(dataFD[1]);
-    if (vm)
-        virDomainObjUnlock(vm);
+    if (vm) {
+        if (ret >= 0 || vm->persistent)
+            virDomainObjUnlock(vm);
+        else
+            qemuDomainRemoveInactive(driver, vm);
+    }
     if (event)
         qemuDomainEventQueue(driver, event);
     qemuMigrationCookieFree(mig);
@@ -1188,9 +1192,6 @@ cleanup:
 endjob:
     if (qemuMigrationJobFinish(driver, vm) == 0) {
         vm = NULL;
-    } else if (!vm->persistent) {
-        qemuDomainRemoveInactive(driver, vm);
-        vm = NULL;
     }
     goto cleanup;
 }