aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2023-05-25 14:47:04 +0200
committerKevin Wolf <kwolf@redhat.com>2023-05-30 17:21:23 +0200
commitc6e0a6de62c5fa99ef06a9bb49c8072bcf93f431 (patch)
treef5d9f4d7fa1c9df9acc4906f84a7676ffa122e3e /block
parentae400dbb8f439021bca5b8a7f60907bbd2cf5291 (diff)
downloadqemu-c6e0a6de62c5fa99ef06a9bb49c8072bcf93f431.zip
qemu-c6e0a6de62c5fa99ef06a9bb49c8072bcf93f431.tar.gz
qemu-c6e0a6de62c5fa99ef06a9bb49c8072bcf93f431.tar.bz2
block: Take main AioContext lock when calling bdrv_open()
The function documentation already says that all callers must hold the main AioContext lock, but not all of them do. This can cause assertion failures when functions called by bdrv_open() try to drop the lock. Fix a few more callers to take the lock before calling bdrv_open(). Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20230525124713.401149-4-kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/block-backend.c2
-rw-r--r--block/qapi-sysemu.c3
2 files changed, 5 insertions, 0 deletions
diff --git a/block/block-backend.c b/block/block-backend.c
index 2644766..1d89fab 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -452,7 +452,9 @@ BlockBackend *blk_new_open(const char *filename, const char *reference,
}
blk = blk_new(qemu_get_aio_context(), perm, shared);
+ aio_context_acquire(qemu_get_aio_context());
bs = bdrv_open(filename, reference, options, flags, errp);
+ aio_context_release(qemu_get_aio_context());
if (!bs) {
blk_unref(blk);
return NULL;
diff --git a/block/qapi-sysemu.c b/block/qapi-sysemu.c
index cec3c1a..ef07151 100644
--- a/block/qapi-sysemu.c
+++ b/block/qapi-sysemu.c
@@ -362,7 +362,10 @@ void qmp_blockdev_change_medium(const char *device,
qdict_put_str(options, "driver", format);
}
+ aio_context_acquire(qemu_get_aio_context());
medium_bs = bdrv_open(filename, NULL, options, bdrv_flags, errp);
+ aio_context_release(qemu_get_aio_context());
+
if (!medium_bs) {
goto fail;
}