From nobody Tue Oct 28 01:56:38 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1522992931090293.63237325554724; Thu, 5 Apr 2018 22:35:31 -0700 (PDT) Received: from localhost ([::1]:55374 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f4K1x-0007Zd-D2 for importer@patchew.org; Fri, 06 Apr 2018 01:35:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37021) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f4K0w-0006xE-6p for qemu-devel@nongnu.org; Fri, 06 Apr 2018 01:34:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f4K0s-0000sz-9s for qemu-devel@nongnu.org; Fri, 06 Apr 2018 01:34:18 -0400 Received: from [101.0.100.17] (port=30408 helo=bulkhead.engineroom.anchor.net.au) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f4K0r-0000rZ-VP for qemu-devel@nongnu.org; Fri, 06 Apr 2018 01:34:14 -0400 Received: from ogopogo.bridge.anchor.net.au (ogopogo.bridge.anchor.net.au [10.108.254.11]) by bulkhead.engineroom.anchor.net.au (Postfix) with ESMTP id 047B31572946; Fri, 6 Apr 2018 15:34:07 +1000 (AEST) Received: by ogopogo.bridge.anchor.net.au (Postfix, from userid 1000) id 9D4B6BF7F5; Fri, 6 Apr 2018 15:34:06 +1000 (AEST) From: Michael Chapman To: qemu-devel@nongnu.org Date: Fri, 6 Apr 2018 15:34:06 +1000 Message-Id: <20180406053406.774-1-mike@very.puzzling.org> X-Mailer: git-send-email 2.14.3 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-Received-From: 101.0.100.17 Subject: [Qemu-devel] [PATCH resend] kvmclock: fix clock_is_reliable on migration from QEMU < 2.9 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- Resent due to missing CCs. hw/i386/kvm/clock.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 @@ -241,6 +241,19 @@ static const VMStateDescription kvmclock_reliable_get_= clock =3D { } }; =20 +/* + * When migrating, assume the source has an unreliable + * KVM_GET_CLOCK unless told otherwise. + */ +static int kvmclock_pre_load(void *opaque) +{ + KVMClockState *s =3D opaque; + + s->clock_is_reliable =3D 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 =3D { .name =3D "kvmclock", .version_id =3D 1, .minimum_version_id =3D 1, + .pre_load =3D kvmclock_pre_load, .pre_save =3D kvmclock_pre_save, .fields =3D (VMStateField[]) { VMSTATE_UINT64(clock, KVMClockState), --=20 2.14.3