* [PATCH] migration/dirtyrate: Fix segmentation fault
@ 2024-04-23 6:19 Masato Imai
2024-04-23 7:12 ` Yong Huang
0 siblings, 1 reply; 2+ messages in thread
From: Masato Imai @ 2024-04-23 6:19 UTC (permalink / raw)
To: qemu-devel; +Cc: Masato Imai, Hyman Huang, Peter Xu, Fabiano Rosas
When the KVM acceleration parameter is not set, executing calc_dirty_rate
with the -r option results in a segmentation fault due to accessing a
null kvm_state pointer in the kvm_dirty_rate_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 | 2 ++
1 file changed, 2 insertions(+)
diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c
index 1d2e85746f..4c1579c6e9 100644
--- a/migration/dirtyrate.c
+++ b/migration/dirtyrate.c
@@ -800,6 +800,8 @@ void qmp_calc_dirty_rate(int64_t calc_time,
* on the contrary, dirty bitmap mode is not.
*/
if (((mode == DIRTY_RATE_MEASURE_MODE_DIRTY_RING) &&
+ !kvm_enabled()) ||
+ ((mode == DIRTY_RATE_MEASURE_MODE_DIRTY_RING) &&
!kvm_dirty_ring_enabled()) ||
((mode == DIRTY_RATE_MEASURE_MODE_DIRTY_BITMAP) &&
kvm_dirty_ring_enabled())) {
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] migration/dirtyrate: Fix segmentation fault
2024-04-23 6:19 [PATCH] migration/dirtyrate: Fix segmentation fault Masato Imai
@ 2024-04-23 7:12 ` Yong Huang
0 siblings, 0 replies; 2+ messages in thread
From: Yong Huang @ 2024-04-23 7:12 UTC (permalink / raw)
To: Masato Imai; +Cc: qemu-devel, Peter Xu, Fabiano Rosas
[-- Attachment #1: Type: text/plain, Size: 1562 bytes --]
On Tue, Apr 23, 2024 at 2:19 PM Masato Imai <mii@sfc.wide.ad.jp> wrote:
> When the KVM acceleration parameter is not set, executing calc_dirty_rate
> with the -r option results in a segmentation fault due to accessing a
> null kvm_state pointer in the kvm_dirty_rate_enabled function.
>
s/kvm_dirty_rate_enabled/kvm_dirty_ring_enabled/
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 | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c
> index 1d2e85746f..4c1579c6e9 100644
> --- a/migration/dirtyrate.c
> +++ b/migration/dirtyrate.c
> @@ -800,6 +800,8 @@ void qmp_calc_dirty_rate(int64_t calc_time,
> * on the contrary, dirty bitmap mode is not.
> */
if (((mode == DIRTY_RATE_MEASURE_MODE_DIRTY_RING) &&
> + !kvm_enabled()) ||
> + ((mode == DIRTY_RATE_MEASURE_MODE_DIRTY_RING) &&
!kvm_dirty_ring_enabled()) ||
> ((mode == DIRTY_RATE_MEASURE_MODE_DIRTY_BITMAP) &&
kvm_dirty_ring_enabled())) {
>
This path may result in segmentation fault likewise, we can fix it together
by adding the following logic before this code:
if (!kvm_enabled() &&
(mode == DIRTY_RATE_MEASURE_MODE_DIRTY_RING ||
mode == DIRTY_RATE_MEASURE_MODE_DIRTY_BITMAP)) {
error_setg(errp, ...
return;
}
> --
> 2.34.1
>
>
Thanks for your work,
Yong
--
Best regards
[-- Attachment #2: Type: text/html, Size: 4543 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-04-23 13:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-23 6:19 [PATCH] migration/dirtyrate: Fix segmentation fault Masato Imai
2024-04-23 7:12 ` Yong Huang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.