test: Use virDomainObjListFindByUUIDRef

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>
This commit is contained in:
John Ferlan 2018-03-09 10:37:52 -05:00
parent 7f8ac4bbc4
commit ea90e0fbb9

View File

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