On Wed, Apr 27, 2022 at 03:08:29PM +0200, Paolo Bonzini wrote: > Because qemu_co_queue_restart_all does not release the lock, it should > be used only in coroutine context. Introduce a new function that, > like qemu_co_enter_next, does release the lock, and use it whenever > qemu_co_queue_restart_all was used outside coroutine context. > > Signed-off-by: Paolo Bonzini <[email protected]> > --- > include/qemu/coroutine.h | 13 +++++++++++++ > ui/console.c | 2 +- > util/qemu-coroutine-lock.c | 7 +++++++ > 3 files changed, 21 insertions(+), 1 deletion(-) > > diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h > index c23d41e1ff..e5954635f6 100644 > --- a/include/qemu/coroutine.h > +++ b/include/qemu/coroutine.h > @@ -234,6 +234,19 @@ void qemu_co_queue_restart_all(CoQueue *queue); > qemu_co_enter_next_impl(queue, QEMU_MAKE_LOCKABLE(lock)) > bool qemu_co_enter_next_impl(CoQueue *queue, QemuLockable *lock); > > +/** > + * Empties the CoQueue, waking the waiting coroutine one at a time. Unlike
maybe s/coroutine/coroutine(s)/ > + * qemu_co_queue_all, this function releases the lock during aio_co_wake > + * because it is meant to be used outside coroutine context; in that case, > the > + * coroutine is entered immediately, before qemu_co_enter_all returns. > + * > + * If used in coroutine context, qemu_co_enter_all is equivalent to > + * qemu_co_queue_all. > + */ > +#define qemu_co_enter_all(queue, lock) \ > + qemu_co_enter_all_impl(queue, QEMU_MAKE_LOCKABLE(lock)) > +void qemu_co_enter_all_impl(CoQueue *queue, QemuLockable *lock); > + Reviewed-by: Eric Blake <[email protected]> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
