]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
libxl: MigrateConfirm: Dont unlock virDomainObj in helper function
authorJim Fehlig <jfehlig@suse.com>
Mon, 12 Mar 2018 18:22:34 +0000 (12:22 -0600)
committerJim Fehlig <jfehlig@suse.com>
Fri, 16 Mar 2018 17:14:57 +0000 (11:14 -0600)
The libxlDomainMigrateConfirm3Params API locks and ref counts the associated
virDomainObj but relies on the helper function libxlDomainMigrationConfirm
to unlock the object. Unref'ing the object is not done in either function.
libxlDomainMigrationConfirm is also used by libxlDomainMigratePerform3Params
for p2p migration, but in that case the lock/ref and unref/unlock are
properly handled in the API entry point.

Remove the unlock from libxlDomainMigrationConfirm and adjust
libxlDomainMigrateConfirm3Params to properly unref/unlock the virDomainObj
on success and error paths.

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

index 5d2d9cf19f8683880d4cda9bedf074899cf91d0a..a89816e3347bda28c4f32a719efc7e1d99144b2f 100644 (file)
@@ -6172,6 +6172,7 @@ libxlDomainMigrateConfirm3Params(virDomainPtr domain,
 {
     libxlDriverPrivatePtr driver = domain->conn->privateData;
     virDomainObjPtr vm = NULL;
+    int ret = -1;
 
 #ifdef LIBXL_HAVE_NO_SUSPEND_RESUME
     virReportUnsupportedError();
@@ -6185,12 +6186,14 @@ libxlDomainMigrateConfirm3Params(virDomainPtr domain,
     if (!(vm = libxlDomObjFromDomain(domain)))
         return -1;
 
-    if (virDomainMigrateConfirm3ParamsEnsureACL(domain->conn, vm->def) < 0) {
-        virObjectUnlock(vm);
-        return -1;
-    }
+    if (virDomainMigrateConfirm3ParamsEnsureACL(domain->conn, vm->def) < 0)
+        goto cleanup;
 
-    return libxlDomainMigrationConfirm(driver, vm, flags, cancelled);
+    ret = libxlDomainMigrationConfirm(driver, vm, flags, cancelled);
+
+ cleanup:
+    virDomainObjEndAPI(&vm);
+    return ret;
 }
 
 static int libxlNodeGetSecurityModel(virConnectPtr conn,
index 4b848c920041b4be4051ae7cf0968a9c8801b2a8..42a84bd3582952c849153416de589de89c2a9dae 100644 (file)
@@ -1392,7 +1392,8 @@ libxlDomainMigrationConfirm(libxlDriverPrivatePtr driver,
 
     if (!vm->persistent || (flags & VIR_MIGRATE_UNDEFINE_SOURCE)) {
         virDomainObjListRemove(driver->domains, vm);
-        vm = NULL;
+        /* Caller passed a locked vm and expects the same on return */
+        virObjectLock(vm);
     }
 
     ret = 0;
@@ -1400,8 +1401,6 @@ libxlDomainMigrationConfirm(libxlDriverPrivatePtr driver,
  cleanup:
     if (event)
         libxlDomainEventQueue(driver, event);
-    if (vm)
-        virObjectUnlock(vm);
     virObjectUnref(cfg);
     return ret;
 }