Re: [PATCH 1/6] conf: Split FindBy{UUID|Name} into locked helpers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
> ---
>  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@xxxxxxxxxx>

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux