mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 01:34:11 +03:00
test: Use virDomainObjListFindByIDRef
Rather than using virDomainObjListFindByID, 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:
parent
ea90e0fbb9
commit
608938419b
@ -1720,16 +1720,14 @@ static virDomainPtr testDomainLookupByID(virConnectPtr conn,
|
||||
virDomainPtr ret = NULL;
|
||||
virDomainObjPtr dom;
|
||||
|
||||
if (!(dom = virDomainObjListFindByID(privconn->domains, id))) {
|
||||
if (!(dom = virDomainObjListFindByIDRef(privconn->domains, id))) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user