Use virDomainObjEndAPI() more

Instead of explicit virObjectUnlock(obj) + virObjectUnref(obj)
combo the virDomainObjEndAPI() can be used.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Michal Privoznik 2021-11-10 09:52:23 +01:00
parent 7f90b137bf
commit 2d5b403cff
2 changed files with 8 additions and 19 deletions

View File

@ -119,11 +119,8 @@ virDomainObjListFindByID(virDomainObjList *doms,
virObjectRWUnlock(doms);
if (obj) {
virObjectLock(obj);
if (obj->removing) {
virObjectUnlock(obj);
virObjectUnref(obj);
obj = NULL;
}
if (obj->removing)
virDomainObjEndAPI(&obj);
}
return obj;
@ -165,11 +162,8 @@ virDomainObjListFindByUUID(virDomainObjList *doms,
obj = virDomainObjListFindByUUIDLocked(doms, uuid);
virObjectRWUnlock(doms);
if (obj && obj->removing) {
virObjectUnlock(obj);
virObjectUnref(obj);
obj = NULL;
}
if (obj && obj->removing)
virDomainObjEndAPI(&obj);
return obj;
}
@ -208,11 +202,8 @@ virDomainObjListFindByName(virDomainObjList *doms,
obj = virDomainObjListFindByNameLocked(doms, name);
virObjectRWUnlock(doms);
if (obj && obj->removing) {
virObjectUnlock(obj);
virObjectUnref(obj);
obj = NULL;
}
if (obj && obj->removing)
virDomainObjEndAPI(&obj);
return obj;
}
@ -953,8 +944,7 @@ virDomainObjListFilter(virDomainObj ***list,
if (vm->removing ||
(filter && !filter(conn, vm->def)) ||
!virDomainObjMatchFilter(vm, flags)) {
virObjectUnlock(vm);
virObjectUnref(vm);
virDomainObjEndAPI(&vm);
VIR_DELETE_ELEMENT(*list, i, *nvms);
continue;
}

View File

@ -461,8 +461,7 @@ libxlReconnectDomain(virDomainObj *vm,
cleanup:
libxl_dominfo_dispose(&d_info);
virObjectUnlock(vm);
virObjectUnref(vm);
virDomainObjEndAPI(&vm);
virObjectUnref(cfg);
return ret;