From: wangliangzz@126.com
To: qemu-devel@nongnu.org, qemu-block@nongnu.org, wangliangzz@126.com
Cc: kwolf@redhat.com, hreitz@redhat.com, eesposit@redhat.com,
Wang Liang <wangliangzz@inspur.com>
Subject: [PATCH] block/monitor/block-hmp-cmds.c: Fix crash when execute hmp_commit
Date: Sun, 23 Apr 2023 19:02:54 +0800 [thread overview]
Message-ID: <20230423110254.35672-1-wangliangzz@126.com> (raw)
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
next reply other threads:[~2023-04-23 11:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-23 11:02 wangliangzz [this message]
2023-04-24 8:15 ` [PATCH] block/monitor/block-hmp-cmds.c: Fix crash when execute hmp_commit Emanuele Giuseppe Esposito
2023-04-24 8:36 ` Emanuele Giuseppe Esposito
2023-04-24 9:25 ` Wang Liang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230423110254.35672-1-wangliangzz@126.com \
--to=wangliangzz@126.com \
--cc=eesposit@redhat.com \
--cc=hreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=wangliangzz@inspur.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).