提交 fe51dbda 编写于 作者: J John Ferlan 提交者: Jim Fehlig

libxl: Use virDomainObjListFindBy{UUID|ID}Ref

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: NJohn Ferlan <jferlan@redhat.com>
Reviewed-by: NJim Fehlig <jfehlig@suse.com>
上级 4e6fcdb6
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册