block-coroutine-wrapper: Take AioContext lock in no_co_wrappers
commitdea97c1fbd4e1bc36d776ff949ce568b7a435e71
authorKevin Wolf <kwolf@redhat.com>
Thu, 25 May 2023 12:47:02 +0000 (25 14:47 +0200)
committerKevin Wolf <kwolf@redhat.com>
Tue, 30 May 2023 15:21:23 +0000 (30 17:21 +0200)
tree615c2748695fcaac496078ee5ac16f4aac7d975e
parentaa9bbd865502ed517624ab6fe7d4b5d89ca95e43
block-coroutine-wrapper: Take AioContext lock in no_co_wrappers

All of the functions that currently take a BlockDriverState, BdrvChild
or BlockBackend as their first parameter expect the associated
AioContext to be locked when they are called. In the case of
no_co_wrappers, they are called from bottom halves directly in the main
loop, so no other caller can be expected to take the lock for them. This
can result in assertion failures because a lock that isn't taken is
released in nested event loops.

Looking at the first parameter is already done by co_wrappers to decide
where the coroutine should run, so doing the same in no_co_wrappers is
only consistent. Take the lock in the generated bottom halves to fix the
problem.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20230525124713.401149-2-kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/block-backend.c
include/block/block-common.h
scripts/block-coroutine-wrapper.py