qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v2 5/5] blkdebug: protect rules and suspended_reqs with a loc


From: Eric Blake
Subject: Re: [PATCH v2 5/5] blkdebug: protect rules and suspended_reqs with a lock
Date: Fri, 7 May 2021 10:29:18 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1

On 5/7/21 10:12 AM, Emanuele Giuseppe Esposito wrote:
> Co-developed-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
> ---
>  block/blkdebug.c | 32 +++++++++++++++++++++++++++++++-
>  1 file changed, 31 insertions(+), 1 deletion(-)
> 

> @@ -929,11 +956,14 @@ static bool 
> blkdebug_debug_is_suspended(BlockDriverState *bs, const char *tag)
>      BDRVBlkdebugState *s = bs->opaque;
>      BlkdebugSuspendedReq *r;
>  
> +    qemu_mutex_lock(&s->lock);
>      QLIST_FOREACH(r, &s->suspended_reqs, next) {
>          if (!strcmp(r->tag, tag)) {
> +            qemu_mutex_unlock(&s->lock);
>              return true;
>          }
>      }
> +    qemu_mutex_unlock(&s->lock);
>      return false;

Would code like this be easier to write by using QEMU_LOCK_GUARD from
lockable.h?

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




reply via email to

[Prev in Thread] Current Thread [Next in Thread]