[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 09/27] block: Fix locking in media change monitor commands
From: |
Kevin Wolf |
Subject: |
[PULL 09/27] block: Fix locking in media change monitor commands |
Date: |
Tue, 31 Oct 2023 19:59:00 +0100 |
blk_insert_bs() requires that the caller holds the AioContext lock for
the node to be inserted. Since commit c066e808e11, neglecting to do so
causes a crash when the child has to be moved to a different AioContext
to attach it to the BlockBackend.
This fixes qmp_blockdev_insert_anon_medium(), which is called for the
QMP commands 'blockdev-insert-medium' and 'blockdev-change-medium', to
correctly take the lock.
Cc: qemu-stable@nongnu.org
Fixes: https://issues.redhat.com/browse/RHEL-3922
Fixes: c066e808e11a5c181b625537b6c78e0de27a4801
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20231013153302.39234-2-kwolf@redhat.com>
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/qapi-sysemu.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/block/qapi-sysemu.c b/block/qapi-sysemu.c
index 3f614cbc04..1618cd225a 100644
--- a/block/qapi-sysemu.c
+++ b/block/qapi-sysemu.c
@@ -237,6 +237,7 @@ static void qmp_blockdev_insert_anon_medium(BlockBackend
*blk,
BlockDriverState *bs, Error **errp)
{
Error *local_err = NULL;
+ AioContext *ctx;
bool has_device;
int ret;
@@ -258,7 +259,11 @@ static void qmp_blockdev_insert_anon_medium(BlockBackend
*blk,
return;
}
+ ctx = bdrv_get_aio_context(bs);
+ aio_context_acquire(ctx);
ret = blk_insert_bs(blk, bs, errp);
+ aio_context_release(ctx);
+
if (ret < 0) {
return;
}
--
2.41.0
- [PULL 05/27] qemu-img: rebase: avoid unnecessary COW operations, (continued)
- [PULL 05/27] qemu-img: rebase: avoid unnecessary COW operations, Kevin Wolf, 2023/10/31
- [PULL 06/27] iotests/{024, 271}: add testcases for qemu-img rebase, Kevin Wolf, 2023/10/31
- [PULL 16/27] virtio: use defer_call() in virtio_irqfd_notify(), Kevin Wolf, 2023/10/31
- [PULL 15/27] util/defer-call: move defer_call() to util/, Kevin Wolf, 2023/10/31
- [PULL 21/27] block/mirror: determine copy_to_target only once, Kevin Wolf, 2023/10/31
- [PULL 19/27] block/mirror: set actively_synced even after the job is ready, Kevin Wolf, 2023/10/31
- [PULL 20/27] block/mirror: move dirty bitmap to filter, Kevin Wolf, 2023/10/31
- [PULL 17/27] virtio-blk: remove batch notification BH, Kevin Wolf, 2023/10/31
- [PULL 13/27] blockdev: mirror: avoid potential deadlock when using iothread, Kevin Wolf, 2023/10/31
- [PULL 18/27] blockjob: introduce block-job-change QMP command, Kevin Wolf, 2023/10/31
- [PULL 09/27] block: Fix locking in media change monitor commands,
Kevin Wolf <=
- [PULL 11/27] blockjob: drop AioContext lock before calling bdrv_graph_wrlock(), Kevin Wolf, 2023/10/31
- [PULL 25/27] blockjob: query driver-specific info via a new 'query' driver method, Kevin Wolf, 2023/10/31
- [PULL 12/27] block: avoid potential deadlock during bdrv_graph_wrlock() in bdrv_close(), Kevin Wolf, 2023/10/31
- [PULL 14/27] block: rename blk_io_plug_call() API to defer_call(), Kevin Wolf, 2023/10/31
- [PULL 10/27] iotests: Test media change with iothreads, Kevin Wolf, 2023/10/31
- [PULL 23/27] qapi/block-core: use JobType for BlockJobInfo's type, Kevin Wolf, 2023/10/31
- [PULL 22/27] mirror: implement mirror_change method, Kevin Wolf, 2023/10/31
- [PULL 26/27] mirror: return mirror-specific information upon query, Kevin Wolf, 2023/10/31
- [PULL 27/27] iotests: add test for changing mirror's copy_mode, Kevin Wolf, 2023/10/31
- [PULL 24/27] qapi/block-core: turn BlockJobInfo into a union, Kevin Wolf, 2023/10/31