From nobody Tue May 7 16:07:11 2024 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=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1567112943; cv=none; d=zoho.com; s=zohoarc; b=UyMxRfFjvRgmUtQqE2+fpyo3rvNue+rKvVo1GrTC0+v6/xvFHbWzwm5NFe0iZvSgfNHTBT7HraZ8gJHkGADTieOy86FZuiELq9alc5g9kh+SBZhWWHNKJ1DMTR6L0vHYrm6O1nOVJakIf4asd8W5R34yfHlT+ZzfoBV+5fwFxVQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567112943; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=hlce4DZcJMw+VwxkPuWj0e+zH2qfgt1UZsdh5b6XD20=; b=WmlX77yTGeS4BOXMa7c5/gOkadag7ffZ8cPHPJeL5jL57/zeoLEqG5O0LNrre21IKszUBUO5M0Z2vB5UGAQTnNf8MJATHAIYVan6A9VKKG+eb3sRQCnFLSopocT8dSZTuGVYfJ5rYwJw6gHFlE5CEaX9vF3/fNInDCfJJlXMO54= 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 1567112943061668.8365989807401; Thu, 29 Aug 2019 14:09:03 -0700 (PDT) Received: from localhost ([::1]:54686 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i3Rf4-0005T5-Vt for importer@patchew.org; Thu, 29 Aug 2019 17:08:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42770) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i3Re3-000523-5g for qemu-devel@nongnu.org; Thu, 29 Aug 2019 17:07:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i3Re1-0001F9-Vj for qemu-devel@nongnu.org; Thu, 29 Aug 2019 17:07:51 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:1340) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i3Re1-0001Dl-ND for qemu-devel@nongnu.org; Thu, 29 Aug 2019 17:07:49 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x7TL1rdH003432; Thu, 29 Aug 2019 17:07:47 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 2upp2d8kdx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Aug 2019 17:07:46 -0400 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.27/8.16.0.27) with SMTP id x7TL1vFa003799; Thu, 29 Aug 2019 17:07:46 -0400 Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 2upp2d8kcm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Aug 2019 17:07:46 -0400 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x7TL58f3025947; Thu, 29 Aug 2019 21:07:44 GMT Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by ppma04wdc.us.ibm.com with ESMTP id 2ujvv6xs5j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Aug 2019 21:07:44 +0000 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x7TL7ifJ16187876 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Aug 2019 21:07:44 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0534AAC065; Thu, 29 Aug 2019 21:07:44 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F2A0EAC062; Thu, 29 Aug 2019 21:07:41 +0000 (GMT) Received: from maxibm.ibmuc.com (unknown [9.85.226.103]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 29 Aug 2019 21:07:41 +0000 (GMT) From: "Maxiwell S. Garcia" To: qemu-devel@nongnu.org Date: Thu, 29 Aug 2019 18:07:11 -0300 Message-Id: <20190829210711.6570-1-maxiwell@linux.ibm.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-08-29_08:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908290212 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH] 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: ehabkost@redhat.com, mst@redhat.com, "Maxiwell S. Garcia" , pbonzini@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Marcelo Tosatti --- 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.20.1