]> xenbits.xensource.com Git - libvirt.git/commitdiff
libxl: Fix removing non-persistent domain after save
authorJim Fehlig <jfehlig@suse.com>
Mon, 21 Jan 2013 17:32:34 +0000 (10:32 -0700)
committerJim Fehlig <jfehlig@suse.com>
Fri, 25 Jan 2013 18:35:57 +0000 (11:35 -0700)
libxlDoDomainSave() was removing non-persistent domains, but
required callers to have the virDomainObj locked.  Callers could
potentially unlock an already freed virDomainObj.  Move this
logic to the callers of libxlDoDomainSave().

src/libxl/libxl_driver.c

index 5b4874688c7cb68bbe963321ed60e6d1dff30c94..95f90ef4cc90214da7f88e158b3659ca2858b4fd 100644 (file)
@@ -2128,12 +2128,6 @@ libxlDoDomainSave(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
     }
 
     vm->hasManagedSave = true;
-
-    if (!vm->persistent) {
-        virDomainRemoveInactive(&driver->domains, vm);
-        vm = NULL;
-    }
-
     ret = 0;
 
 cleanup:
@@ -2176,7 +2170,15 @@ libxlDomainSaveFlags(virDomainPtr dom, const char *to, const char *dxml,
         goto cleanup;
     }
 
-    ret = libxlDoDomainSave(driver, vm, to);
+    if (libxlDoDomainSave(driver, vm, to) < 0)
+        goto cleanup;
+
+    if (!vm->persistent) {
+        virDomainRemoveInactive(&driver->domains, vm);
+        vm = NULL;
+    }
+
+    ret = 0;
 
 cleanup:
     if (vm)
@@ -2375,7 +2377,15 @@ libxlDomainManagedSave(virDomainPtr dom, unsigned int flags)
 
     VIR_INFO("Saving state to %s", name);
 
-    ret = libxlDoDomainSave(driver, vm, name);
+    if (libxlDoDomainSave(driver, vm, name) < 0)
+        goto cleanup;
+
+    if (!vm->persistent) {
+        virDomainRemoveInactive(&driver->domains, vm);
+        vm = NULL;
+    }
+
+    ret = 0;
 
 cleanup:
     if (vm)