kvmclock: fix clock_is_reliable on migration from QEMU < 2.9
PATCH RESEND 1/1 kvmclock: fix clock_is_reliable on migration from QEMU < 2.9
When migrating from a pre-2.9 QEMU, no clock_is_reliable flag is transferred. We should assume that the source host has an unreliable KVM_GET_CLOCK, rather than using whatever was determined locally, to ensure that any drift from the TSC-based value calculated by the guest is corrected.
---
Resent due to missing CCs.
hw/i386/kvm/clock.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
hw/i386/kvm/clock.c +14 -0
@@ -241,6 +241,19 @@ static const VMStateDescription kvmclock_reliable_get_clock = { } }; +/* +* When migrating, assume the source has an unreliable +* KVM_GET_CLOCK unless told otherwise. +*/ +static int kvmclock_pre_load (void *opaque) +{ +KVMClockState *s = opaque; + + s->clock_is_reliable = false; + +return 0 ; +} +/* * When migrating, read the clock just before migration, * so that the guest clock counts during the events
@@ -268,6 +281,7 @@ static const VMStateDescription kvmclock_vmsd = { .name = "kvmclock", .version_id = 1, .minimum_version_id = 1, + .pre_load = kvmclock_pre_load, .pre_save = kvmclock_pre_save, .fields = (VMStateField []) {VMSTATE_UINT64 (clock, KVMClockState),
Signature · 1 line
2.14.3
Paolo Bonzini
AppliedQuoted 39 lines · Michael Chapman
When migrating from a pre-2.9 QEMU, no
clock_is_reliableflag is transferred. We should assume that the source host has an unreliableKVM_GET_CLOCK, rather than using whatever was determined locally, to ensure that any drift from the TSC-based value calculated by the guest is corrected.Signed-off-by Michael Chapman <[email protected]>---
Resent due to missing CCs.hw/i386/kvm/clock.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)hw/i386/kvm/clock.c +13
-0@@ -241,6 +241,19 @@ static const VMStateDescription kvmclock_reliable_get_clock = { } }; +/* +* When migrating, assume the source has an unreliable +* KVM_GET_CLOCK unless told otherwise. +*/ +static int kvmclock_pre_load (void *opaque) +{ +KVMClockState *s = opaque; + + s->clock_is_reliable = false; + +return 0 ; +} +/* * When migrating, read the clock just before migration, * so that the guest clock counts during the events
hw/i386/kvm/clock.c static const VMStateDescription kvmclock_vmsd = { · line 287
Quoted 7 lines
hw/i386/kvm/clock.c +1
-0@@ -268,6 +281,7 @@ static const VMStateDescription kvmclock_vmsd = { .name = "kvmclock", .version_id = 1, .minimum_version_id = 1, + .pre_load = kvmclock_pre_load, .pre_save = kvmclock_pre_save, .fields = (VMStateField []) {VMSTATE_UINT64 (clock, KVMClockState),
Queued, thanks.
Paolo