]> git.proxmox.com Git - mirror_qemu.git/commit
coroutine-lock: qemu_co_queue_next is a coroutine-only qemu_co_enter_next
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 27 Apr 2022 13:08:28 +0000 (15:08 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 12 May 2022 10:29:44 +0000 (12:29 +0200)
commit248af9e80a04c5ab4ffec789aa24345d3d86b42b
tree3f1fbd4ff264301762319ef3d0413dae224e8b17
parentbf2f69d08bf158bfdbbe251357452f9576489b6d
coroutine-lock: qemu_co_queue_next is a coroutine-only qemu_co_enter_next

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 <pbonzini@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20220427130830.150180-2-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
include/qemu/coroutine.h
util/qemu-coroutine-lock.c