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