]> xenbits.xensource.com Git - libvirt.git/commitdiff
kill vm if saving config failed in v3 protocol
authorWen Congyang <wency@cn.fujitsu.com>
Fri, 1 Jul 2011 10:05:43 +0000 (18:05 +0800)
committerWen Congyang <wency@cn.fujitsu.com>
Mon, 11 Jul 2011 12:53:35 +0000 (20:53 +0800)
If virDomainSaveConfig() failed, we will return NULL to source,
and the vm is still available to restart during confirm() step in
v3 protocol. So we should kill it off in qemuMigrationFinish().

In v2 protocol, we should not set vm to NULL, because we hold
a reference of vm and should unrefernce it.

src/qemu/qemu_migration.c

index d7b27a0a1b77c0f3641d182edf90aabf9c7082d3..3e4f4feb37480dec4087b3b7ee4f19b7cadf69c8 100644 (file)
@@ -2471,7 +2471,7 @@ qemuMigrationFinish(struct qemud_driver *driver,
         if (!virDomainObjIsActive(vm)) {
             qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                             _("guest unexpectedly quit"));
-            goto cleanup;
+            goto endjob;
         }
 
         qemuMigrationVPAssociatePortProfiles(vm->def);
@@ -2491,7 +2491,24 @@ qemuMigrationFinish(struct qemud_driver *driver,
                  * Return a NULL dom pointer, and hope that this is a rare
                  * situation and management tools are smart.
                  */
-                vm = NULL;
+
+                /*
+                 * In v3 protocol, the source VM is still available to
+                 * restart during confirm() step, so we kill it off
+                 * now.
+                 * In v2 protocol, the source is dead, so we leave
+                 * target in paused state, in case admin can fix
+                 * things up
+                 */
+                if (v3proto) {
+                    qemuProcessStop(driver, vm, 1, VIR_DOMAIN_SHUTOFF_FAILED);
+                    qemuAuditDomainStop(vm, "failed");
+                    if (newVM) {
+                        if (qemuDomainObjEndJob(vm) > 0)
+                            virDomainRemoveInactive(&driver->domains, vm);
+                        vm = NULL;
+                    }
+                }
                 goto endjob;
             }