diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c index 1d027a43cd9365bcf2cf67d3abd5f3a474378f3a..9bc6603353b9eb4b58aa5834dbdd9c9369ebaf12 100644 --- a/src/conf/virdomainobjlist.c +++ b/src/conf/virdomainobjlist.c @@ -118,7 +118,7 @@ virDomainObjListFindByIDInternal(virDomainObjListPtr doms, bool ref) { virDomainObjPtr obj; - virObjectLockRead(doms); + virObjectRWLockRead(doms); obj = virHashSearch(doms->objs, virDomainObjListSearchID, &id, NULL); if (ref) { virObjectRef(obj); @@ -160,7 +160,7 @@ virDomainObjListFindByUUIDInternal(virDomainObjListPtr doms, char uuidstr[VIR_UUID_STRING_BUFLEN]; virDomainObjPtr obj; - virObjectLockRead(doms); + virObjectRWLockRead(doms); virUUIDFormat(uuid, uuidstr); obj = virHashLookup(doms->objs, uuidstr); @@ -204,7 +204,7 @@ virDomainObjPtr virDomainObjListFindByName(virDomainObjListPtr doms, { virDomainObjPtr obj; - virObjectLockRead(doms); + virObjectRWLockRead(doms); obj = virHashLookup(doms->objsName, name); virObjectRef(obj); virObjectUnlock(doms); @@ -653,7 +653,7 @@ virDomainObjListNumOfDomains(virDomainObjListPtr doms, virConnectPtr conn) { struct virDomainObjListData data = { filter, conn, active, 0 }; - virObjectLockRead(doms); + virObjectRWLockRead(doms); virHashForEach(doms->objs, virDomainObjListCount, &data); virObjectUnlock(doms); return data.count; @@ -697,7 +697,7 @@ virDomainObjListGetActiveIDs(virDomainObjListPtr doms, { struct virDomainIDData data = { filter, conn, 0, maxids, ids }; - virObjectLockRead(doms); + virObjectRWLockRead(doms); virHashForEach(doms->objs, virDomainObjListCopyActiveIDs, &data); virObjectUnlock(doms); return data.numids; @@ -751,7 +751,7 @@ virDomainObjListGetInactiveNames(virDomainObjListPtr doms, struct virDomainNameData data = { filter, conn, 0, 0, maxnames, names }; size_t i; - virObjectLockRead(doms); + virObjectRWLockRead(doms); virHashForEach(doms->objs, virDomainObjListCopyInactiveNames, &data); virObjectUnlock(doms); if (data.oom) { @@ -792,7 +792,7 @@ virDomainObjListForEach(virDomainObjListPtr doms, struct virDomainListIterData data = { callback, opaque, 0, }; - virObjectLockRead(doms); + virObjectRWLockRead(doms); virHashForEach(doms->objs, virDomainObjListHelper, &data); virObjectUnlock(doms); return data.ret; @@ -925,7 +925,7 @@ virDomainObjListCollect(virDomainObjListPtr domlist, { struct virDomainListData data = { NULL, 0 }; - virObjectLockRead(domlist); + virObjectRWLockRead(domlist); sa_assert(domlist->objs); if (VIR_ALLOC_N(data.vms, virHashSize(domlist->objs)) < 0) { virObjectUnlock(domlist); @@ -962,7 +962,7 @@ virDomainObjListConvert(virDomainObjListPtr domlist, *nvms = 0; *vms = NULL; - virObjectLockRead(domlist); + virObjectRWLockRead(domlist); for (i = 0; i < ndoms; i++) { virDomainPtr dom = doms[i]; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 4f1ad2a0ccd257051058ae8acfd5741d3ea2396b..b5fc31a64f6f0a9a9af920c0a6988bec12a42097 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2308,10 +2308,10 @@ virObjectListFree; virObjectListFreeCount; virObjectLock; virObjectLockableNew; -virObjectLockRead; virObjectNew; virObjectRef; virObjectRWLockableNew; +virObjectRWLockRead; virObjectUnlock; virObjectUnref; diff --git a/src/util/virobject.c b/src/util/virobject.c index b1bb378b461043184200f4ebf8b5b1b837da02dc..b97f251afd0670f591ca720263b538f0a87d5c3d 100644 --- a/src/util/virobject.c +++ b/src/util/virobject.c @@ -399,7 +399,7 @@ virObjectLock(void *anyobj) /** - * virObjectLockRead: + * virObjectRWLockRead: * @anyobj: any instance of virObjectRWLockable * * Acquire a read lock on @anyobj. The lock must be @@ -409,9 +409,14 @@ virObjectLock(void *anyobj) * on the object before locking it (eg virObjectRef). * The object must be unlocked before releasing this * reference. + * + * NB: It's possible to return without the lock if + * @anyobj was invalid - this has been considered + * a programming error rather than something that + * should be checked. */ void -virObjectLockRead(void *anyobj) +virObjectRWLockRead(void *anyobj) { if (virObjectIsClass(anyobj, virObjectRWLockableClass)) { virObjectRWLockablePtr obj = anyobj; @@ -429,7 +434,7 @@ virObjectLockRead(void *anyobj) * @anyobj: any instance of virObjectLockable or virObjectRWLockable * * Release a lock on @anyobj. The lock must have been acquired by - * virObjectLock or virObjectLockRead. + * virObjectLock or virObjectRWLockRead. */ void virObjectUnlock(void *anyobj) diff --git a/src/util/virobject.h b/src/util/virobject.h index 5985fadb2de62c46f287e76fe38d2edce1d95df5..e7ca983921f38522aa96083dd938e9a900f9c094 100644 --- a/src/util/virobject.h +++ b/src/util/virobject.h @@ -125,7 +125,7 @@ virObjectLock(void *lockableobj) ATTRIBUTE_NONNULL(1); void -virObjectLockRead(void *lockableobj) +virObjectRWLockRead(void *lockableobj) ATTRIBUTE_NONNULL(1); void