]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
libxl: Use virDomainObjListFindBy{UUID|ID}Ref
authorJohn Ferlan <jferlan@redhat.com>
Fri, 9 Mar 2018 16:48:00 +0000 (11:48 -0500)
committerJim Fehlig <jfehlig@suse.com>
Fri, 16 Mar 2018 20:26:00 +0000 (14:26 -0600)
For libxlDomainLookupByID and libxlDomainLookupByUUID let's
return a locked and referenced @vm object so that callers can
then use the common and more consistent virDomainObjEndAPI in
order to handle cleanup rather than needing to know that the
returned object is locked and calling virObjectUnlock.

The LookupByName already returns the ref counted and locked object,
so this will make things more consistent.

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

index f0ff215fcc68af7951e221e5ee88e3dd0db26276..89432d03c6ffc56604ae4b9a9a1956036c149e85 100644 (file)
@@ -1090,7 +1090,7 @@ libxlDomainLookupByID(virConnectPtr conn, int id)
     virDomainObjPtr vm;
     virDomainPtr dom = NULL;
 
-    vm = virDomainObjListFindByID(driver->domains, id);
+    vm = virDomainObjListFindByIDRef(driver->domains, id);
     if (!vm) {
         virReportError(VIR_ERR_NO_DOMAIN, NULL);
         goto cleanup;
@@ -1102,8 +1102,7 @@ libxlDomainLookupByID(virConnectPtr conn, int id)
     dom = virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id);
 
  cleanup:
-    if (vm)
-        virObjectUnlock(vm);
+    virDomainObjEndAPI(&vm);
     return dom;
 }
 
@@ -1114,7 +1113,7 @@ libxlDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
     virDomainObjPtr vm;
     virDomainPtr dom = NULL;
 
-    vm = virDomainObjListFindByUUID(driver->domains, uuid);
+    vm = virDomainObjListFindByUUIDRef(driver->domains, uuid);
     if (!vm) {
         virReportError(VIR_ERR_NO_DOMAIN, NULL);
         goto cleanup;
@@ -1126,8 +1125,7 @@ libxlDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
     dom = virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id);
 
  cleanup:
-    if (vm)
-        virObjectUnlock(vm);
+    virDomainObjEndAPI(&vm);
     return dom;
 }