diff options
author | Kevin Wolf <kwolf@redhat.com> | 2023-05-25 14:47:02 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2023-05-30 17:21:23 +0200 |
commit | dea97c1fbd4e1bc36d776ff949ce568b7a435e71 (patch) | |
tree | 615c2748695fcaac496078ee5ac16f4aac7d975e /block/block-backend.c | |
parent | aa9bbd865502ed517624ab6fe7d4b5d89ca95e43 (diff) |
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>
Diffstat (limited to 'block/block-backend.c')
-rw-r--r-- | block/block-backend.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/block/block-backend.c b/block/block-backend.c index ca537cd0ad..26447664ab 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2394,9 +2394,14 @@ void blk_op_unblock_all(BlockBackend *blk, Error *reason) AioContext *blk_get_aio_context(BlockBackend *blk) { - BlockDriverState *bs = blk_bs(blk); + BlockDriverState *bs; IO_CODE(); + if (!blk) { + return qemu_get_aio_context(); + } + + bs = blk_bs(blk); if (bs) { AioContext *ctx = bdrv_get_aio_context(blk_bs(blk)); assert(ctx == blk->ctx); |