aboutsummaryrefslogtreecommitdiff
path: root/hw/core/qdev-properties-system.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2023-06-05 10:57:02 +0200
committerKevin Wolf <kwolf@redhat.com>2023-06-28 08:46:05 +0200
commit415275aed959cd5c766a98b9f0eba54278a7adf5 (patch)
tree0575f3c24fa60275931b912d9a2ce2f4a8572036 /hw/core/qdev-properties-system.c
parent23e6c3c41b4f44d2e42a21846981bb70b9ff6d8a (diff)
qdev-properties-system: Lock AioContext for blk_insert_bs()
blk_insert_bs() requires that callers hold the AioContext lock for the node that should be inserted. Take it. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-ID: <20230605085711.21261-3-kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw/core/qdev-properties-system.c')
-rw-r--r--hw/core/qdev-properties-system.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index d42493f630..6d5d43eda2 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -143,11 +143,15 @@ static void set_drive_helper(Object *obj, Visitor *v, const char *name,
* aware of iothreads require their BlockBackends to be in the main
* AioContext.
*/
- ctx = iothread ? bdrv_get_aio_context(bs) : qemu_get_aio_context();
- blk = blk_new(ctx, 0, BLK_PERM_ALL);
+ ctx = bdrv_get_aio_context(bs);
+ blk = blk_new(iothread ? ctx : qemu_get_aio_context(),
+ 0, BLK_PERM_ALL);
blk_created = true;
+ aio_context_acquire(ctx);
ret = blk_insert_bs(blk, bs, errp);
+ aio_context_release(ctx);
+
if (ret < 0) {
goto fail;
}