]> git.proxmox.com Git - mirror_qemu.git/commit
coroutine-lock: qemu_co_queue_restart_all is a coroutine-only qemu_co_enter_all
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 27 Apr 2022 13:08:30 +0000 (15:08 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 12 May 2022 10:29:44 +0000 (12:29 +0200)
commitf0d43b1ecef04105e0d0f55658182510b4e0f58e
tree4111e660ac9f48f89b00e440332dcbc8891b088f
parentd6ee15adec5a2345e88c680cd15ed48796c89c14
coroutine-lock: qemu_co_queue_restart_all is a coroutine-only qemu_co_enter_all

qemu_co_queue_restart_all is basically the same as qemu_co_enter_all
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_restart_all 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 to qemu_co_queue_restart_all and to its sole
non-coroutine_fn caller; it then reimplements the function in terms of
qemu_co_enter_all_impl, to remove duplicated code and to clarify that the
latter also works in coroutine context.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20220427130830.150180-4-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
block/io.c
include/qemu/coroutine.h
util/qemu-coroutine-lock.c