]> xenbits.xensource.com Git - libvirt.git/commitdiff
libxl: destroy domain in migration finish phase on failure
authorJim Fehlig <jfehlig@suse.com>
Thu, 13 Nov 2014 00:52:02 +0000 (17:52 -0700)
committerJim Fehlig <jfehlig@suse.com>
Fri, 21 Nov 2014 20:11:47 +0000 (13:11 -0700)
This patch contains three domain cleanup improvements in the migration
finish phase, ensuring a domain is properly disposed when a failure is
detected or the migration is cancelled.

The check for virDomainObjIsActive is moved to libxlDomainMigrationFinish,
where cleanup can occur if migration failed and the domain is inactive.

The 'cleanup' label was missplaced in libxlDomainMigrationFinish, causing
a migrated domain to remain in the event of an error or cancelled migration.

In cleanup, the domain was not removed from the driver's list of domains.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
src/libxl/libxl_driver.c
src/libxl/libxl_migration.c

index 8c2b19211ffc95ed35f240a3012f0a1bc3df5f5c..53c87ce9a3dfff13b595d3e515eb6d50f62e2678 100644 (file)
@@ -4686,17 +4686,8 @@ libxlDomainMigrateFinish3Params(virConnectPtr dconn,
         return NULL;
     }
 
-    if (!virDomainObjIsActive(vm)) {
-        /* Migration failed if domain is inactive */
-        virReportError(VIR_ERR_OPERATION_FAILED,
-                       "%s", _("Migration failed. Domain is not running "
-                               "on destination host"));
-        goto endjob;
-    }
-
     ret = libxlDomainMigrationFinish(dconn, vm, flags, cancelled);
 
- endjob:
     if (!libxlDomainObjEndJob(driver, vm))
         vm = NULL;
 
index 6f83b08f052d3d23c63b98c59662b4d4a36f12c5..0caa3d0734bba207042ad9d7b0a5092fbd62f013 100644 (file)
@@ -537,6 +537,16 @@ libxlDomainMigrationFinish(virConnectPtr dconn,
     if (cancelled)
         goto cleanup;
 
+    /* Check if domain is alive */
+    if (!virDomainObjIsActive(vm)) {
+        /* Migration failed if domain is inactive */
+        virReportError(VIR_ERR_OPERATION_FAILED,
+                       "%s", _("Migration failed. Domain is not running "
+                               "on destination host"));
+        goto cleanup;
+    }
+
+    /* Unpause if requested */
     if (!(flags & VIR_MIGRATE_PAUSED)) {
         if (libxl_domain_unpause(priv->ctx, vm->def->id) != 0) {
             virReportError(VIR_ERR_OPERATION_FAILED, "%s",
@@ -556,24 +566,26 @@ libxlDomainMigrationFinish(virConnectPtr dconn,
                                          VIR_DOMAIN_EVENT_SUSPENDED_PAUSED);
     }
 
-    if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
-        goto cleanup;
-
     if (event) {
         libxlDomainEventQueue(driver, event);
         event = NULL;
     }
 
+    if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
+        goto cleanup;
+
     dom = virGetDomain(dconn, vm->def->name, vm->def->uuid);
 
+ cleanup:
     if (dom == NULL) {
         libxl_domain_destroy(priv->ctx, vm->def->id, NULL);
         libxlDomainCleanup(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED);
         event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED,
                                          VIR_DOMAIN_EVENT_STOPPED_FAILED);
+        if (!vm->persistent)
+            virDomainObjListRemove(driver->domains, vm);
     }
 
- cleanup:
     if (event)
         libxlDomainEventQueue(driver, event);
     virObjectUnref(cfg);