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

View File

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