]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
block: Fix AioContext locking in qmp_block_resize()
authorKevin Wolf <kwolf@redhat.com>
Fri, 8 Dec 2023 12:43:52 +0000 (13:43 +0100)
committerMichael Tokarev <mjt@tls.msk.ru>
Thu, 14 Dec 2023 07:11:59 +0000 (10:11 +0300)
The AioContext must be unlocked before calling blk_co_unref(), because
it takes the AioContext lock internally in blk_unref_bh(), which is
scheduled in the main thread. If we don't unlock, the AioContext is
locked twice and nested event loops such as in bdrv_graph_wrlock() will
deadlock.

Cc: <qemu-stable@nongnu.org>
Fixes: https://issues.redhat.com/browse/RHEL-15965
Fixes: 0c7d204f50c382c6baac8c94bd57af4a022b3888
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20231208124352.30295-1-kwolf@redhat.com>
(cherry picked from commit 755ae3811fec77d94e92398632cbfe23c4ecffd5)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
blockdev.c

index e6eba61484a7c0268aa84fc34c0f374b68de5bb0..c28462a6337c9cb6b0df81de993d3c75fe08dbf7 100644 (file)
@@ -2361,8 +2361,9 @@ void coroutine_fn qmp_block_resize(const char *device, const char *node_name,
 
     bdrv_co_lock(bs);
     bdrv_drained_end(bs);
-    blk_co_unref(blk);
     bdrv_co_unlock(bs);
+
+    blk_co_unref(blk);
 }
 
 void qmp_block_stream(const char *job_id, const char *device,