]> xenbits.xensource.com Git - libvirt.git/commitdiff
test: Use virDomainObjListFindByUUIDRef
authorJohn Ferlan <jferlan@redhat.com>
Fri, 9 Mar 2018 15:37:52 +0000 (10:37 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 4 Apr 2018 10:53:38 +0000 (06:53 -0400)
Rather than using virDomainObjListFindByUUID, let's be more consistent
and return a reffed and locked object. Since we're using the Ref API,
use virDomainObjEndAPI on @dom and not just virObjectUnlock.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
src/test/test_driver.c

index 35ee19bc10ea7ae1915e5b766cac78da92b561c6..0bfc7974005dd6bffffefd3c3b104f490d7e67d8 100644 (file)
@@ -1740,16 +1740,14 @@ static virDomainPtr testDomainLookupByUUID(virConnectPtr conn,
     virDomainPtr ret = NULL;
     virDomainObjPtr dom;
 
-    if (!(dom = virDomainObjListFindByUUID(privconn->domains, uuid))) {
+    if (!(dom = virDomainObjListFindByUUIDRef(privconn->domains, uuid))) {
         virReportError(VIR_ERR_NO_DOMAIN, NULL);
-        goto cleanup;
+        return NULL;
     }
 
     ret = virGetDomain(conn, dom->def->name, dom->def->uuid, dom->def->id);
 
- cleanup:
-    if (dom)
-        virObjectUnlock(dom);
+    virDomainObjEndAPI(&dom);
     return ret;
 }