[libvirt] [PATCH 1/6] conf: Split FindBy{UUID|Name} into locked helpers
John Ferlan
jferlan at redhat.com
Thu May 3 13:01:15 UTC 2018
On 05/03/2018 06:38 AM, Erik Skultety wrote:
> On Tue, Apr 24, 2018 at 08:28:04AM -0400, John Ferlan wrote:
>> Create helpers virDomainObjListFindByUUIDLocked and
>> virDomainObjListFindByNameLocked to avoid the need
>> to lock the domain object list leaving that task
>> for the caller.
>>
>> Signed-off-by: John Ferlan <jferlan at redhat.com>
>> ---
>> src/conf/virdomainobjlist.c | 58 ++++++++++++++++++++++++++++++++++++++-------
>> 1 file changed, 49 insertions(+), 9 deletions(-)
>>
>> diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c
>> index d57ed10a5f..9aa2abd8c3 100644
>> --- a/src/conf/virdomainobjlist.c
>> +++ b/src/conf/virdomainobjlist.c
>> @@ -133,19 +133,16 @@ virDomainObjListFindByID(virDomainObjListPtr doms,
>> }
>>
>>
>> -virDomainObjPtr
>> -virDomainObjListFindByUUID(virDomainObjListPtr doms,
>> - const unsigned char *uuid)
>> +static virDomainObjPtr
>> +virDomainObjListFindByUUIDLocked(virDomainObjListPtr doms,
>> + const unsigned char *uuid)
>> {
>> char uuidstr[VIR_UUID_STRING_BUFLEN];
>> virDomainObjPtr obj;
>>
>> - virObjectRWLockRead(doms);
>> virUUIDFormat(uuid, uuidstr);
>> -
>> obj = virHashLookup(doms->objs, uuidstr);
>> virObjectRef(obj);
>> - virObjectRWUnlock(doms);
>> if (obj) {
>> virObjectLock(obj);
>> if (obj->removing) {
>> @@ -158,15 +155,36 @@ virDomainObjListFindByUUID(virDomainObjListPtr doms,
>> }
>>
>>
>> -virDomainObjPtr virDomainObjListFindByName(virDomainObjListPtr doms,
>> - const char *name)
>> +/**
>> + * @doms: Locked domain object list
>
> ^It's not, you actually lock it here...I guess you sort of wanted to attach the
> commentary to the *Locked version of the function but then changed your mind
> and combined your thoughts from both? :)...same for the other function.
>
> Reviewed-by: Erik Skultety <eskultet at redhat.com>
>
oh, right - exactly what I did - the comment was above the Locked
functions, but then I moved it. I changed both : s/Locked d/D/
Tks -
John
More information about the libvir-list
mailing list