On Wed, Apr 27, 2022 at 03:08:28PM +0200, Paolo Bonzini wrote:
> qemu_co_queue_next is basically the same as qemu_co_enter_next but
> without a QemuLockable argument.  That's perfectly fine, but only
> as long as the function is marked coroutine_fn.  If used outside
> coroutine context, qemu_co_queue_wait will attempt to take the lock
> and that is just broken: if you are calling qemu_co_queue_next outside
> coroutine context, the lock is going to be a QemuMutex which cannot be
> taken twice by the same thread.
> 
> The patch adds the marker and reimplements qemu_co_queue_next in terms of
> qemu_co_enter_next_impl, to remove duplicated code and to clarify that the
> latter also works in coroutine context.
> 
> Signed-off-by: Paolo Bonzini <[email protected]>
> ---
>  include/qemu/coroutine.h   |  7 ++++---
>  util/qemu-coroutine-lock.c | 21 +++++++--------------
>  2 files changed, 11 insertions(+), 17 deletions(-)

Reviewed-by: Eric Blake <[email protected]>

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


Reply via email to