From nobody Wed Nov 12 03:45:32 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1567546711; cv=none; d=zoho.com; s=zohoarc; b=f4Kybh35DNjdgIhXcpqH2kt+Io1Qnn/j0PuWkEKcBsZoId4ZKFEQmkIAyKMWyh4elpsNRvO5GBuGPSzA2CyddC+PoEWSzHatAJ6kee+gnW6Wpkb6lpVj22JuWOWVA/B2JZsvOQ/WdU0Gb7ff+ud+DPxBlFZ7OOXrdrKbOo6UaPM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567546711; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=xK9bFNQ/h+0Xm/+7k37+S+7ojpMeyNjweD57B3RkAE4=; b=QfyanrmMEIgEyoSJRROKj51UpyZea/aSrGJYccj3MvdtDjexUteSmejiFGwgolxxg9W9KLbpDQKDv6YCZ+bePA0/m8boKrCfdG2HJZ7j7rIEAPeaYt1iM+m5ScORhmMIknhE/aqdLruDtdCOKMJz0RGarvVTE7mjlfwuPpEhNBU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1567546711221932.268580329442; Tue, 3 Sep 2019 14:38:31 -0700 (PDT) Received: from localhost ([::1]:51890 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5GVR-0003AT-Pa for importer@patchew.org; Tue, 03 Sep 2019 17:38:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57033) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Fwj-0004Ua-OF for qemu-devel@nongnu.org; Tue, 03 Sep 2019 17:02:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5Fwi-0001UQ-IG for qemu-devel@nongnu.org; Tue, 03 Sep 2019 17:02:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52452) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5Fwi-0001U3-DC for qemu-devel@nongnu.org; Tue, 03 Sep 2019 17:02:36 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B088510C6352; Tue, 3 Sep 2019 21:02:35 +0000 (UTC) Received: from localhost (ovpn-116-55.gru2.redhat.com [10.97.116.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 485D11001956; Tue, 3 Sep 2019 21:02:35 +0000 (UTC) From: Eduardo Habkost To: Paolo Bonzini , Igor Mammedov , Peter Maydell , Richard Henderson , Marcel Apfelbaum , qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 18:02:01 -0300 Message-Id: <20190903210201.14627-14-ehabkost@redhat.com> In-Reply-To: <20190903210201.14627-1-ehabkost@redhat.com> References: <20190903210201.14627-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.64]); Tue, 03 Sep 2019 21:02:35 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 13/13] migration: Do not re-read the clock on pre_save in case of paused guest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marcelo Tosatti , "Maxiwell S. Garcia" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: "Maxiwell S. Garcia" The clock move makes the guest knows about the paused time between the 'stop' and 'migrate' commands. This is an issue in an already-paused VM because some side effects, like process stalls, could happen after migration. So, this patch checks the runstate of guest in the pre_save handler and do not re-reads the clock in case of paused state (cold migration). Signed-off-by: Maxiwell S. Garcia Message-Id: <20190829210711.6570-1-maxiwell@linux.ibm.com> Reviewed-by: Marcelo Tosatti Signed-off-by: Eduardo Habkost --- hw/i386/kvm/clock.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c index 80c133a724..2c59b6894b 100644 --- a/hw/i386/kvm/clock.c +++ b/hw/i386/kvm/clock.c @@ -41,6 +41,9 @@ typedef struct KVMClockState { uint64_t clock; bool clock_valid; =20 + /* whether the 'clock' value was obtained in the 'paused' state */ + bool runstate_paused; + /* whether machine type supports reliable KVM_GET_CLOCK */ bool mach_use_reliable_get_clock; =20 @@ -202,6 +205,8 @@ static void kvmclock_vm_state_change(void *opaque, int = running, return; } =20 + s->runstate_paused =3D runstate_check(RUN_STATE_PAUSED); + kvm_synchronize_all_tsc(); =20 kvm_update_clock(s); @@ -260,9 +265,9 @@ static int kvmclock_pre_load(void *opaque) } =20 /* - * When migrating, read the clock just before migration, - * so that the guest clock counts during the events - * between: + * When migrating a running guest, read the clock just + * before migration, so that the guest clock counts + * during the events between: * * * vm_stop() * * @@ -277,7 +282,9 @@ static int kvmclock_pre_save(void *opaque) { KVMClockState *s =3D opaque; =20 - kvm_update_clock(s); + if (!s->runstate_paused) { + kvm_update_clock(s); + } =20 return 0; } --=20 2.21.0