block/monitor/block-hmp-cmds.c: Fix crash when execute hmp_commit
PATCH 1/1 block/monitor/block-hmp-cmds.c: Fix crash when execute hmp_commit
From: Wang Liang <[email protected]>
We need to get the aio_context before calling the blk_is_available.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1615
--- block/monitor/block-hmp-cmds.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
block/monitor/block-hmp-cmds.c +6 -4
@@ -214,15 +214,17 @@ void hmp_commit(Monitor *mon, const QDict *qdict)error_report ("Device '%s' not found" , device);return ; } -if (!blk_is_available (blk)) { -error_report ("Device '%s' has no medium" , device); -return ; - } bs =bdrv_skip_implicit_filters (blk_bs (blk)); aio_context =bdrv_get_aio_context (bs);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);aio_context_release (aio_context);
Signature · 1 line
2.27.0
Am 23/04/2023 um 13:02 schrieb [email protected]:
Quoted 7 lines
From: Wang Liang <[email protected]>
We need to get the
aio_contextbefore calling theblk_is_available.Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1615
Signed-off-by Wang Liang <[email protected]>
Am 24/04/2023 um 10:15 schrieb Emanuele Giuseppe Esposito:
Quoted 5 lines
Am 23/04/2023 um 13:02 schrieb [email protected]:
Quoted 2 lines
From: Wang Liang <[email protected]>
Quoted 9 lines
Quoted 5 lines
We need to get the
aio_contextbefore calling theblk_is_available.Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1615
Signed-off-by Wang Liang <[email protected]>Reviewed-by Emanuele Giuseppe Esposito <[email protected]>
Sorry I forgot, if you need to resend can you add the cause of this issue in the commit message?
Something along the lines of:
"hmp_commit() calls blk_is_available() from a non-coroutine context (and in the main loop). Since this is a co_wrapper_mixed_bdrv_rdlock function, in this case it calls AIO_WAIT_WHILE(), which crashes if the aio_context lock is not taken before"
Thank you,
Emanuele
Quoted 26 lines · Emanuele Giuseppe Esposito
Am 24/04/2023 um 10:15 schrieb Emanuele Giuseppe Esposito:
Quoted 4 lines
Am 23/04/2023 um 13:02 schrieb [email protected]:
Quoted 2 lines
From: Wang Liang <[email protected]>
Quoted 9 lines
Quoted 6 lines
We need to get the
aio_contextbefore calling theblk_is_available.Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1615
Signed-off-by Wang Liang <[email protected]>Reviewed-by Emanuele Giuseppe Esposito <[email protected]>Sorry I forgot, if you need to resend can you add the cause of this issue in the commit message?
Something along the lines of:
"hmp_commit()callsblk_is_available()from a non-coroutine context (and
in the main loop). Since this is aco_wrapper_mixed_bdrv_rdlockfunction, in this case it callsAIO_WAIT_WHILE(), which crashes if theaio_contextlock is not taken before"
Quoted 2 lines
Thank you,
Emanuele
Thanks for the detailed explanation. I'll resend the patch.
Wang Liang