* [PATCH] block/monitor/block-hmp-cmds.c: Fix crash when execute hmp_commit
@ 2023-04-23 11:02 wangliangzz
2023-04-24 8:15 ` Emanuele Giuseppe Esposito
0 siblings, 1 reply; 4+ messages in thread
From: wangliangzz @ 2023-04-23 11:02 UTC (permalink / raw)
To: qemu-devel, qemu-block, wangliangzz; +Cc: kwolf, hreitz, eesposit, Wang Liang
From: Wang Liang <wangliangzz@inspur.com>
We need to get the aio_context before calling the blk_is_available.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1615
Signed-off-by: Wang Liang <wangliangzz@inspur.com>
---
block/monitor/block-hmp-cmds.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
index 2846083546..ca2599de44 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -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);
--
2.27.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] block/monitor/block-hmp-cmds.c: Fix crash when execute hmp_commit
2023-04-23 11:02 [PATCH] block/monitor/block-hmp-cmds.c: Fix crash when execute hmp_commit wangliangzz
@ 2023-04-24 8:15 ` Emanuele Giuseppe Esposito
2023-04-24 8:36 ` Emanuele Giuseppe Esposito
0 siblings, 1 reply; 4+ messages in thread
From: Emanuele Giuseppe Esposito @ 2023-04-24 8:15 UTC (permalink / raw)
To: wangliangzz, qemu-devel, qemu-block; +Cc: kwolf, hreitz, Wang Liang
Am 23/04/2023 um 13:02 schrieb wangliangzz@126.com:
> From: Wang Liang <wangliangzz@inspur.com>
>
> We need to get the aio_context before calling the blk_is_available.
>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1615
> Signed-off-by: Wang Liang <wangliangzz@inspur.com>
>
Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block/monitor/block-hmp-cmds.c: Fix crash when execute hmp_commit
2023-04-24 8:15 ` Emanuele Giuseppe Esposito
@ 2023-04-24 8:36 ` Emanuele Giuseppe Esposito
2023-04-24 9:25 ` Wang Liang
0 siblings, 1 reply; 4+ messages in thread
From: Emanuele Giuseppe Esposito @ 2023-04-24 8:36 UTC (permalink / raw)
To: wangliangzz, qemu-devel, qemu-block; +Cc: kwolf, hreitz, Wang Liang
Am 24/04/2023 um 10:15 schrieb Emanuele Giuseppe Esposito:
>
>
> Am 23/04/2023 um 13:02 schrieb wangliangzz@126.com:
>> From: Wang Liang <wangliangzz@inspur.com>
>>
>> We need to get the aio_context before calling the blk_is_available.
>>
>> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1615
>> Signed-off-by: Wang Liang <wangliangzz@inspur.com>
>>
>
>
> Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
>
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block/monitor/block-hmp-cmds.c: Fix crash when execute hmp_commit
2023-04-24 8:36 ` Emanuele Giuseppe Esposito
@ 2023-04-24 9:25 ` Wang Liang
0 siblings, 0 replies; 4+ messages in thread
From: Wang Liang @ 2023-04-24 9:25 UTC (permalink / raw)
To: Emanuele Giuseppe Esposito, qemu-devel, qemu-block
Cc: kwolf, hreitz, Wang Liang
On Mon, 2023-04-24 at 10:36 +0200, Emanuele Giuseppe Esposito wrote:
>
> Am 24/04/2023 um 10:15 schrieb Emanuele Giuseppe Esposito:
> >
> > Am 23/04/2023 um 13:02 schrieb wangliangzz@126.com:
> > > From: Wang Liang <wangliangzz@inspur.com>
> > >
> > > We need to get the aio_context before calling the
> > > blk_is_available.
> > >
> > > Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1615
> > > Signed-off-by: Wang Liang <wangliangzz@inspur.com>
> > >
> >
> > Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
> >
>
> 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
Thanks for the detailed explanation. I'll resend the patch.
Wang Liang
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-04-24 9:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-23 11:02 [PATCH] block/monitor/block-hmp-cmds.c: Fix crash when execute hmp_commit wangliangzz
2023-04-24 8:15 ` Emanuele Giuseppe Esposito
2023-04-24 8:36 ` Emanuele Giuseppe Esposito
2023-04-24 9:25 ` Wang Liang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).