From: Yong Huang <yong.huang@smartx.com>
To: Peter Xu <peterx@redhat.com>
Cc: Masato Imai <mii@sfc.wide.ad.jp>,
qemu-devel@nongnu.org, Fabiano Rosas <farosas@suse.de>
Subject: Re: [PATCH v2 1/1] migration/dirtyrate: Fix segmentation fault
Date: Wed, 24 Apr 2024 09:28:08 +0800 [thread overview]
Message-ID: <CAK9dgmaOOgQ3i2Er5GWz0i0917puSj_4Wt+1KZdJyV2KoazyMw@mail.gmail.com> (raw)
In-Reply-To: <Zie5Fr3m9BquVpp3@x1n>
[-- Attachment #1: Type: text/plain, Size: 1766 bytes --]
On Tue, Apr 23, 2024 at 9:35 PM Peter Xu <peterx@redhat.com> wrote:
> On Tue, Apr 23, 2024 at 09:13:08AM +0000, Masato Imai wrote:
> > When the KVM acceleration parameter is not set, executing calc_dirty_rate
> > with the -r or -b option results in a segmentation fault due to accessing
> > a null kvm_state pointer in the kvm_dirty_ring_enabled function.
> > This commit adds a check for kvm_enabled to prevent segmentation faults.
> >
> > Signed-off-by: Masato Imai <mii@sfc.wide.ad.jp>
> > ---
> > migration/dirtyrate.c | 7 +++++++
> > 1 file changed, 7 insertions(+)
> >
> > diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c
> > index 1d2e85746f..2a7df52519 100644
> > --- a/migration/dirtyrate.c
> > +++ b/migration/dirtyrate.c
> > @@ -799,6 +799,13 @@ void qmp_calc_dirty_rate(int64_t calc_time,
> > * dirty ring mode only works when kvm dirty ring is enabled.
> > * on the contrary, dirty bitmap mode is not.
> > */
> > + if (!kvm_enabled() &&
> > + (mode == DIRTY_RATE_MEASURE_MODE_DIRTY_RING ||
> > + mode == DIRTY_RATE_MEASURE_MODE_DIRTY_BITMAP)) {
> > + error_setg(errp, "mode %s requires kvm to be enabled.",
> > + DirtyRateMeasureMode_str(mode));
> > + return;
> > + }
>
> Logically dirty bitmap should work with tcg. So the other option is to let
> kvm_dirty_ring_enabled() check kvm_state too and return false if
> kvm_state==NULL?
>
Agree, better solution
> > if (((mode == DIRTY_RATE_MEASURE_MODE_DIRTY_RING) &&
> > !kvm_dirty_ring_enabled()) ||
> > ((mode == DIRTY_RATE_MEASURE_MODE_DIRTY_BITMAP) &&
> > --
> > 2.34.1
> >
>
> --
> Peter Xu
>
>
Thanks,
Yong
--
Best regards
[-- Attachment #2: Type: text/html, Size: 3212 bytes --]
next prev parent reply other threads:[~2024-04-24 1:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-23 9:13 [PATCH v2 0/1] migration/dirtyrate: Fix segmentation fault Masato Imai
2024-04-23 9:13 ` [PATCH v2 1/1] " Masato Imai
2024-04-23 13:35 ` Peter Xu
2024-04-24 1:28 ` Yong Huang [this message]
2024-04-24 4:52 ` mii
2024-04-24 7:17 ` Zhijian Li (Fujitsu) via
2024-04-29 1:51 ` Yong Huang
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=CAK9dgmaOOgQ3i2Er5GWz0i0917puSj_4Wt+1KZdJyV2KoazyMw@mail.gmail.com \
--to=yong.huang@smartx.com \
--cc=farosas@suse.de \
--cc=mii@sfc.wide.ad.jp \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).