summary refs log tree commit diff stats
path: root/hw/i386/kvm/clock.c
diff options
context:
space:
mode:
authorMichael Chapman <mike@very.puzzling.org>2018-04-06 15:34:06 +1000
committerPaolo Bonzini <pbonzini@redhat.com>2018-04-09 16:36:39 +0200
commitc2b01cfec1f1426d95c27abacc3ea5b5fbb9a57e (patch)
tree8b70046af10290f8a0d5a4e9290ad2684795dd16 /hw/i386/kvm/clock.c
parent4968a2c6edb7b46b127c19a8426575d23b55ab1f (diff)
downloadfocaccia-qemu-c2b01cfec1f1426d95c27abacc3ea5b5fbb9a57e.tar.gz
focaccia-qemu-c2b01cfec1f1426d95c27abacc3ea5b5fbb9a57e.zip
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.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
Message-Id: <20180406053406.774-1-mike@very.puzzling.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/i386/kvm/clock.c')
-rw-r--r--hw/i386/kvm/clock.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c
index 1707434db3..7dac319403 100644
--- a/hw/i386/kvm/clock.c
+++ b/hw/i386/kvm/clock.c
@@ -242,6 +242,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
  * between:
@@ -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),