mirror of
https://github.com/mii443/qemu.git
synced 2025-09-01 14:49:23 +00:00
block/monitor: Fix crash when executing HMP commit
hmp_commit() calls blk_is_available() from a non-coroutine context (and
in the main loop). blk_is_available() is a co_wrapper_mixed_bdrv_rdlock
function, and in the non-coroutine context it calls AIO_WAIT_WHILE(),
which crashes if the aio_context lock is not taken before.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1615
Signed-off-by: Wang Liang <wangliangzz@inspur.com>
Message-Id: <20230424103902.45265-1-wangliangzz@126.com>
Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 8c1e8fb2e7
)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
This commit is contained in:
committed by
Michael Tokarev
parent
76326210e4
commit
747c801f51
@ -214,15 +214,17 @@ void hmp_commit(Monitor *mon, const QDict *qdict)
|
|||||||
error_report("Device '%s' not found", device);
|
error_report("Device '%s' not found", device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!blk_is_available(blk)) {
|
|
||||||
error_report("Device '%s' has no medium", device);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bs = bdrv_skip_implicit_filters(blk_bs(blk));
|
bs = bdrv_skip_implicit_filters(blk_bs(blk));
|
||||||
aio_context = bdrv_get_aio_context(bs);
|
aio_context = bdrv_get_aio_context(bs);
|
||||||
aio_context_acquire(aio_context);
|
aio_context_acquire(aio_context);
|
||||||
|
|
||||||
|
if (!blk_is_available(blk)) {
|
||||||
|
error_report("Device '%s' has no medium", device);
|
||||||
|
aio_context_release(aio_context);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ret = bdrv_commit(bs);
|
ret = bdrv_commit(bs);
|
||||||
|
|
||||||
aio_context_release(aio_context);
|
aio_context_release(aio_context);
|
||||||
|
Reference in New Issue
Block a user