From nobody Tue May 14 13:13:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1704312478; cv=none; d=zohomail.com; s=zohoarc; b=Tsuc3piYLamQXMfuc1BMXtkfKZ/To+YAo4AAnrb5kvDvnvz7oGAiR2Pz2UmYKFJyyE0CMmbcBD+Un8WnkoORoPl86Ggfzon2JplZcJ9MriWGUeJ2zWoX2q47ggY1LNV58WrWv84LS5cjOME9VspFBG2zHdjVEtUPVw25w0ghuPc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704312478; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=54WE3zIc9WakuDR0Wl+eRiPQLJuKyyI4IJzRdInpsHI=; b=Y5WiNcF3r4vGOD58f4GCm1I06G9WlGO6qY9ygEz0OFj+FWpG11o9nBJVPopooc4suiOSKwduP7GF3PRS6/swK2SQBl4JT//upPZjb2wjTNiQQ3EU0tLpRlaTWVcMexxnWETvGC/SpGWzS1VjXHZ2765uvJ3xaEEy2Mt9adzERuc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704312478451726.560284676398; Wed, 3 Jan 2024 12:07:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rL7VH-0004qA-Dz; Wed, 03 Jan 2024 15:06:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rL7VA-0004i7-0Y for qemu-devel@nongnu.org; Wed, 03 Jan 2024 15:06:08 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rL7V8-0002FA-H6 for qemu-devel@nongnu.org; Wed, 03 Jan 2024 15:06:07 -0500 Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 403JXQ4J003045; Wed, 3 Jan 2024 20:05:46 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3vab8d5sxg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Jan 2024 20:05:46 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 403K21XF013612; Wed, 3 Jan 2024 20:05:45 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3vddsvtbcf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Jan 2024 20:05:45 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 403K2UZd020511; Wed, 3 Jan 2024 20:05:44 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3vddsvtba4-2; Wed, 03 Jan 2024 20:05:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=54WE3zIc9WakuDR0Wl+eRiPQLJuKyyI4IJzRdInpsHI=; b=ixpqY5MC/xBrl0OfvvuFAtfA3QrjlBXhemvV9GIad+HaHvsm89ga0933885088HSenTC +ZxYfD1brf/F66ekVuBoTkWVcVU0CyGNEkLh3XgQrfmtsXFwFQxzAaulUf8FGfIcClz9 1Vd5pQaRdk48x2fHrbJFICRYTVrPnhdEwtFDPMw01PeNsBP4HWMdPumEZDv368ETpQna AUgHbwI+jnJdHCh7cU84KvXiYbEdVsqPC8iCzG8EM3NTeJ6f53ZH/iuStAO4eQQ7ua4J BPqifpVSVrN/ycFX0NTyNQsfZStiowoRB3eOo6MoqqH2J5Dlocmi7cidmLgL2vu9cBdZ Ug== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Peter Xu , Paolo Bonzini , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fabiano Rosas , Leonardo Bras , Markus Armbruster , Anthony PERARD , Stefan Berger , Gerd Hoffmann , Stefano Stabellini , Paul Durrant , Eric Blake , Richard Henderson , Steve Sistare Subject: [PATCH V9 01/12] cpus: vm_was_suspended Date: Wed, 3 Jan 2024 12:05:30 -0800 Message-Id: <1704312341-66640-2-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1704312341-66640-1-git-send-email-steven.sistare@oracle.com> References: <1704312341-66640-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-03_08,2024-01-03_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 suspectscore=0 mlxscore=0 adultscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401030162 X-Proofpoint-GUID: jJRKgnP5r1ZGlXdKu-2vh6n7wANj51Qo X-Proofpoint-ORIG-GUID: jJRKgnP5r1ZGlXdKu-2vh6n7wANj51Qo Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1704312479473100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a state variable to remember if a vm previously transitioned into a suspended state. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu --- include/sysemu/runstate.h | 2 ++ system/cpus.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h index c8c2bd8..88a67e2 100644 --- a/include/sysemu/runstate.h +++ b/include/sysemu/runstate.h @@ -51,6 +51,8 @@ int vm_prepare_start(bool step_pending); int vm_stop(RunState state); int vm_stop_force_state(RunState state); int vm_shutdown(void); +void vm_set_suspended(bool suspended); +bool vm_get_suspended(void); =20 typedef enum WakeupReason { /* Always keep QEMU_WAKEUP_REASON_NONE =3D 0 */ diff --git a/system/cpus.c b/system/cpus.c index a444a74..9f631ab 100644 --- a/system/cpus.c +++ b/system/cpus.c @@ -259,6 +259,21 @@ void cpu_interrupt(CPUState *cpu, int mask) } } =20 +/* + * True if the vm was previously suspended, and has not been woken or rese= t. + */ +static int vm_was_suspended; + +void vm_set_suspended(bool suspended) +{ + vm_was_suspended =3D suspended; +} + +bool vm_get_suspended(void) +{ + return vm_was_suspended; +} + static int do_vm_stop(RunState state, bool send_stop) { int ret =3D 0; --=20 1.8.3.1 From nobody Tue May 14 13:13:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1704312591; cv=none; d=zohomail.com; s=zohoarc; b=CHCRtSRHEvOsVfCWGg9DVCC47Qmta2SmeSvAhTA30IgAUnZkpbvUiRNsfBW1hUP+JIuWteERrh9IS4n03I1vJCqlmMa8zrrjt4+KIsQOVnqsqy1XR41XNVEJPih1FPjeqHD1VZbNTfZKIygn5Ue0OOQfERO0Ty/N5l2zEhmDigk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704312591; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=x+u+GMacxwrn64ie5Ex4xyhexUAdtayAFySg/cuy1nU=; b=MGR793zbjSreye3P+CpMj6ZnPbrzRXXS256OJt1um4pK4I6kB/Z8s85NEDXIMMN6Z1SAgNASqR6OfA+hTS3RUa9lkGXC9581EOoMPKAA7YP785XvxgGwSmr56gIedlRque5If78Rnv1HiBF0fIOvX7C9OwcE7FyHIHjRt86Oe70= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704312591519411.81875741417923; Wed, 3 Jan 2024 12:09:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rL7YP-0002rE-Sn; Wed, 03 Jan 2024 15:09:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rL7YN-0002nc-OQ for qemu-devel@nongnu.org; Wed, 03 Jan 2024 15:09:27 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rL7YL-00030u-Sc for qemu-devel@nongnu.org; Wed, 03 Jan 2024 15:09:27 -0500 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 403JXUsC027022; Wed, 3 Jan 2024 20:05:47 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3vaatu5qsv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Jan 2024 20:05:47 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 403K2519014127; Wed, 3 Jan 2024 20:05:46 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3vddsvtbdr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Jan 2024 20:05:45 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 403K2UZf020511; Wed, 3 Jan 2024 20:05:45 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3vddsvtba4-3; Wed, 03 Jan 2024 20:05:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=x+u+GMacxwrn64ie5Ex4xyhexUAdtayAFySg/cuy1nU=; b=JMn3aIknH1/t0BLXjYeLQDymo3QaEvSIemG2+jMgR7hFhIFr6iWqQYOYsEjy501r6UAm 0Wr4TcW2pzETpB2oDvGvm30ii8IduWjHniHH6twUWFBN0XsP9+UgKjVWs5jnXZdJ2C9r X26oILjd4lledhbpGHYgpo5N2HlhencGTN1iOflIXLseiBsvvXWfTk07iT8tRG6cCscn J5l5PBKdltN2fiTZVeLVfdE67z/a7sisxshUDZ4lI5Et72YP5rFEplUWQfbo73RY0cuz Qy4ZfFKJmT5lTa4Cjb4bM+PxRVL/dubu0CrlWJOh6fU5Gos7XFvbNZY13pesl5LEIuDK hQ== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Peter Xu , Paolo Bonzini , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fabiano Rosas , Leonardo Bras , Markus Armbruster , Anthony PERARD , Stefan Berger , Gerd Hoffmann , Stefano Stabellini , Paul Durrant , Eric Blake , Richard Henderson , Steve Sistare Subject: [PATCH V9 02/12] cpus: stop vm in suspended runstate Date: Wed, 3 Jan 2024 12:05:31 -0800 Message-Id: <1704312341-66640-3-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1704312341-66640-1-git-send-email-steven.sistare@oracle.com> References: <1704312341-66640-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-03_08,2024-01-03_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 suspectscore=0 mlxscore=0 adultscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401030162 X-Proofpoint-GUID: _wOUPE0ha4-x2mJ6GpzyFFjod0Ycl5FD X-Proofpoint-ORIG-GUID: _wOUPE0ha4-x2mJ6GpzyFFjod0Ycl5FD Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1704312591798100005 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Currently, a vm in the suspended state is not completely stopped. The VCPUs have been paused, but the cpu clock still runs, and runstate notifiers for the transition to stopped have not been called. This causes problems for live migration. Stale cpu timers_state is saved to the migration stream, causing time errors in the guest when it wakes from suspend, and state that would have been modified by runstate notifiers is wrong. Modify vm_stop to completely stop the vm if the current state is suspended, transition to RUN_STATE_PAUSED, and remember that the machine was suspended. Modify vm_start to restore the suspended state. This affects all callers of vm_stop and vm_start, notably, the qapi stop and cont commands: old behavior: RUN_STATE_SUSPENDED --> stop --> RUN_STATE_SUSPENDED new behavior: RUN_STATE_SUSPENDED --> stop --> RUN_STATE_PAUSED RUN_STATE_PAUSED --> cont --> RUN_STATE_SUSPENDED For example: (qemu) info status VM status: paused (suspended) (qemu) stop (qemu) info status VM status: paused (qemu) system_wakeup Error: Unable to wake up: guest is not in suspended state (qemu) cont (qemu) info status VM status: paused (suspended) (qemu) system_wakeup (qemu) info status VM status: running Suggested-by: Peter Xu Signed-off-by: Steve Sistare Reviewed-by: Peter Xu --- include/sysemu/runstate.h | 9 +++++++++ qapi/misc.json | 11 +++++++++-- qapi/run-state.json | 6 +++--- system/cpus.c | 23 +++++++++++++++-------- system/runstate.c | 3 +++ 5 files changed, 39 insertions(+), 13 deletions(-) diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h index 88a67e2..618eb49 100644 --- a/include/sysemu/runstate.h +++ b/include/sysemu/runstate.h @@ -40,6 +40,15 @@ static inline bool shutdown_caused_by_guest(ShutdownCaus= e cause) return cause >=3D SHUTDOWN_CAUSE_GUEST_SHUTDOWN; } =20 +/* + * In a "live" state, the vcpu clock is ticking, and the runstate notifiers + * think we are running. + */ +static inline bool runstate_is_live(RunState state) +{ + return state =3D=3D RUN_STATE_RUNNING || state =3D=3D RUN_STATE_SUSPEN= DED; +} + void vm_start(void); =20 /** diff --git a/qapi/misc.json b/qapi/misc.json index cda2eff..3622d98 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -134,7 +134,7 @@ ## # @stop: # -# Stop all guest VCPU execution. +# Stop guest VM execution. # # Since: 0.14 # @@ -143,6 +143,9 @@ # the guest remains paused once migration finishes, as if the -S # option was passed on the command line. # +# In the "suspended" state, it will completely stop the VM and +# cause a transition to the "paused" state. (Since 9.0) +# # Example: # # -> { "execute": "stop" } @@ -153,7 +156,7 @@ ## # @cont: # -# Resume guest VCPU execution. +# Resume guest VM execution. # # Since: 0.14 # @@ -165,6 +168,10 @@ # guest starts once migration finishes, removing the effect of the # -S command line option if it was passed. # +# If the VM was previously suspended, and not been reset or woken, +# this command will transition back to the "suspended" state. +# (Since 9.0) +# # Example: # # -> { "execute": "cont" } diff --git a/qapi/run-state.json b/qapi/run-state.json index f216ba5..ca05502 100644 --- a/qapi/run-state.json +++ b/qapi/run-state.json @@ -102,7 +102,7 @@ ## # @StatusInfo: # -# Information about VCPU run state +# Information about VM run state # # @running: true if all VCPUs are runnable, false if not runnable # @@ -130,9 +130,9 @@ ## # @query-status: # -# Query the run status of all VCPUs +# Query the run status of the VM # -# Returns: @StatusInfo reflecting all VCPUs +# Returns: @StatusInfo reflecting the VM # # Since: 0.14 # diff --git a/system/cpus.c b/system/cpus.c index 9f631ab..f162435 100644 --- a/system/cpus.c +++ b/system/cpus.c @@ -277,11 +277,15 @@ bool vm_get_suspended(void) static int do_vm_stop(RunState state, bool send_stop) { int ret =3D 0; + RunState oldstate =3D runstate_get(); =20 - if (runstate_is_running()) { + if (runstate_is_live(oldstate)) { + vm_was_suspended =3D (oldstate =3D=3D RUN_STATE_SUSPENDED); runstate_set(state); cpu_disable_ticks(); - pause_all_vcpus(); + if (oldstate =3D=3D RUN_STATE_RUNNING) { + pause_all_vcpus(); + } vm_state_notify(0, state); if (send_stop) { qapi_event_send_stop(); @@ -694,11 +698,13 @@ int vm_stop(RunState state) =20 /** * Prepare for (re)starting the VM. - * Returns -1 if the vCPUs are not to be restarted (e.g. if they are alrea= dy - * running or in case of an error condition), 0 otherwise. + * Returns 0 if the vCPUs should be restarted, -1 on an error condition, + * and 1 otherwise. */ int vm_prepare_start(bool step_pending) { + int ret =3D vm_was_suspended ? 1 : 0; + RunState state =3D vm_was_suspended ? RUN_STATE_SUSPENDED : RUN_STATE_= RUNNING; RunState requested; =20 qemu_vmstop_requested(&requested); @@ -729,9 +735,10 @@ int vm_prepare_start(bool step_pending) qapi_event_send_resume(); =20 cpu_enable_ticks(); - runstate_set(RUN_STATE_RUNNING); - vm_state_notify(1, RUN_STATE_RUNNING); - return 0; + runstate_set(state); + vm_state_notify(1, state); + vm_was_suspended =3D false; + return ret; } =20 void vm_start(void) @@ -745,7 +752,7 @@ void vm_start(void) current state is forgotten forever */ int vm_stop_force_state(RunState state) { - if (runstate_is_running()) { + if (runstate_is_live(runstate_get())) { return vm_stop(state); } else { int ret; diff --git a/system/runstate.c b/system/runstate.c index ea9d6c2..e2fa204 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -108,6 +108,7 @@ static const RunStateTransition runstate_transitions_de= f[] =3D { { RUN_STATE_PAUSED, RUN_STATE_POSTMIGRATE }, { RUN_STATE_PAUSED, RUN_STATE_PRELAUNCH }, { RUN_STATE_PAUSED, RUN_STATE_COLO}, + { RUN_STATE_PAUSED, RUN_STATE_SUSPENDED}, =20 { RUN_STATE_POSTMIGRATE, RUN_STATE_RUNNING }, { RUN_STATE_POSTMIGRATE, RUN_STATE_FINISH_MIGRATE }, @@ -161,6 +162,7 @@ static const RunStateTransition runstate_transitions_de= f[] =3D { { RUN_STATE_SUSPENDED, RUN_STATE_FINISH_MIGRATE }, { RUN_STATE_SUSPENDED, RUN_STATE_PRELAUNCH }, { RUN_STATE_SUSPENDED, RUN_STATE_COLO}, + { RUN_STATE_SUSPENDED, RUN_STATE_PAUSED}, =20 { RUN_STATE_WATCHDOG, RUN_STATE_RUNNING }, { RUN_STATE_WATCHDOG, RUN_STATE_FINISH_MIGRATE }, @@ -502,6 +504,7 @@ void qemu_system_reset(ShutdownCause reason) qapi_event_send_reset(shutdown_caused_by_guest(reason), reason); } cpu_synchronize_all_post_reset(); + vm_set_suspended(false); } =20 /* --=20 1.8.3.1 From nobody Tue May 14 13:13:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1704312429; cv=none; d=zohomail.com; s=zohoarc; b=AQdBnGI4GRJrzJjLL9OmoKw3mxCG4RRK04SBqWjWFrxMlZa3g/NkHKMkkPW2P6v1fo0fSa3EhEI1hTXe6uLjO6a6H3VSk87r11xPSpFq5hBjqo6ZaFXrBEqEEzHiSA+3ldwq1opnYT6QqvDBii1f2SpDKtx7ICEKe4OaQGUJCVs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704312429; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=GnVeRbOAl6rLN2jYjXl8d0jSztnXvyn1ynEEBiEsVjk=; b=eEZLUeDaWQzIdL5UFZO8oeCdThyJQVN5/HdNi2lQ+ibfQynBfG0Vr1Ie+SkZATZaEHZStKPvoAQ2BCvdraxBaV1A856PbNCjMQsCnbD6wzI06IiSJ1d8amkc1sJE5n1cHFSH6yhFyWt0CfQS7XHZKmvqmPnssdWj/Ua0rc5OQuY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704312429795112.77749876737084; Wed, 3 Jan 2024 12:07:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rL7VG-0004oD-P9; Wed, 03 Jan 2024 15:06:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rL7V5-0004gP-4H for qemu-devel@nongnu.org; Wed, 03 Jan 2024 15:06:04 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rL7V2-0002C8-As for qemu-devel@nongnu.org; Wed, 03 Jan 2024 15:06:02 -0500 Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 403JXQJI003046; Wed, 3 Jan 2024 20:05:48 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3vab8d5sxj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Jan 2024 20:05:47 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 403K2160013632; Wed, 3 Jan 2024 20:05:47 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3vddsvtbej-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Jan 2024 20:05:46 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 403K2UZh020511; Wed, 3 Jan 2024 20:05:46 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3vddsvtba4-4; Wed, 03 Jan 2024 20:05:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=GnVeRbOAl6rLN2jYjXl8d0jSztnXvyn1ynEEBiEsVjk=; b=DbQHB/i54Mv7P53XPWsTXnC0slCOVKJt/q7DKJ94PWTLp5O0AsAE4WtHIfoKFD8gxdX0 5mlk6Sz5nann9A0NZg/xe/O6qSKcAmMFzcNuooo/oElL5Cf3GX2yxQblsiFQvbbJPpDu snkYFeaNUSS+4iI/VV177+cpfbJHB4X5lxxnbCZU1DJG2gmD9ekqamhiELXloYqlBu2T vA+Z6sUePICFSoc8jNpr9eS886te5mP16wID/3kS7sq2frrKfdSIT8rtpeZe7Knr4YHp 2BNGsv/5oM1lidh153iUvxmLWy6h60LPWdySewl5U+JOgFGFiRpbepkQ+hq0RBS9od+p Vw== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Peter Xu , Paolo Bonzini , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fabiano Rosas , Leonardo Bras , Markus Armbruster , Anthony PERARD , Stefan Berger , Gerd Hoffmann , Stefano Stabellini , Paul Durrant , Eric Blake , Richard Henderson , Steve Sistare Subject: [PATCH V9 03/12] cpus: check running not RUN_STATE_RUNNING Date: Wed, 3 Jan 2024 12:05:32 -0800 Message-Id: <1704312341-66640-4-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1704312341-66640-1-git-send-email-steven.sistare@oracle.com> References: <1704312341-66640-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-03_08,2024-01-03_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 suspectscore=0 mlxscore=0 adultscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401030162 X-Proofpoint-GUID: 8BvJxfWCSAsufEI1Tm6Fu1bi-ejisHc3 X-Proofpoint-ORIG-GUID: 8BvJxfWCSAsufEI1Tm6Fu1bi-ejisHc3 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1704312431280100007 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When a vm transitions from running to suspended, runstate notifiers are not called, so the notifiers still think the vm is running. Hence, when we call vm_start to restore the suspended state, we call vm_state_notify with running=3D1. However, some notifiers check for RUN_STATE_RUNNING. They must check the running boolean instead. No functional change. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu --- backends/tpm/tpm_emulator.c | 2 +- hw/usb/hcd-ehci.c | 2 +- hw/usb/redirect.c | 2 +- hw/xen/xen-hvm-common.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backends/tpm/tpm_emulator.c b/backends/tpm/tpm_emulator.c index f7f1b4a..254fce7 100644 --- a/backends/tpm/tpm_emulator.c +++ b/backends/tpm/tpm_emulator.c @@ -904,7 +904,7 @@ static void tpm_emulator_vm_state_change(void *opaque, = bool running, =20 trace_tpm_emulator_vm_state_change(running, state); =20 - if (!running || state !=3D RUN_STATE_RUNNING || !tpm_emu->relock_stora= ge) { + if (!running || !tpm_emu->relock_storage) { return; } =20 diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index 19b4534..10c82ce 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -2451,7 +2451,7 @@ static void usb_ehci_vm_state_change(void *opaque, bo= ol running, RunState state) * USB-devices which have async handled packages have a packet in the * ep queue to match the completion with. */ - if (state =3D=3D RUN_STATE_RUNNING) { + if (running) { ehci_advance_async_state(ehci); } =20 diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index c9893df..3785bb0 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -1403,7 +1403,7 @@ static void usbredir_vm_state_change(void *priv, bool= running, RunState state) { USBRedirDevice *dev =3D priv; =20 - if (state =3D=3D RUN_STATE_RUNNING && dev->parser !=3D NULL) { + if (running && dev->parser !=3D NULL) { usbredirparser_do_write(dev->parser); /* Flush any pending writes = */ } } diff --git a/hw/xen/xen-hvm-common.c b/hw/xen/xen-hvm-common.c index 565dc39..47e6cb1 100644 --- a/hw/xen/xen-hvm-common.c +++ b/hw/xen/xen-hvm-common.c @@ -623,7 +623,7 @@ void xen_hvm_change_state_handler(void *opaque, bool ru= nning, =20 xen_set_ioreq_server_state(xen_domid, state->ioservid, - (rstate =3D=3D RUN_STATE_RUNNING)); + running); } =20 void xen_exit_notifier(Notifier *n, void *data) --=20 1.8.3.1 From nobody Tue May 14 13:13:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1704312381; cv=none; d=zohomail.com; s=zohoarc; b=m+FaybSB91Tay52KgxzqziV3BmG58Ly113fCbMvhp0IVh0Ui28tYJwTM2epVaEU6dHH8blb3h0cF6VWHjxw+C3PYSHp2kILdZuk6xBOX+Q7x3iAC7PPNaN8OwiUWLFYDztMRN0p9bqoISEYO84WclfenBNCTqlWJaHZdhgrzjAU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704312381; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Q74Kutq/s1A83wS9uUJES8vX5GoYWvwZa96hIBR5kLA=; b=SoSQQ8VsyTAVCpN8xhPPqu/QVyh0Te5Ma7tuUtVDznT2pNSM2BVRPrU6f8kdShTJD4vKvsteMqq8PYXol9GfZBi1DFIc6kbloXiEFEAq0qnP47vnrJByYAXE75B1plnQN/lyxrPrF6vvr2fJ8zpD+SEE+ea/4mFhTgBpUk93cgQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704312381883584.8122449619146; Wed, 3 Jan 2024 12:06:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rL7VB-0004hw-OB; Wed, 03 Jan 2024 15:06:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rL7V3-0004eF-Rj for qemu-devel@nongnu.org; Wed, 03 Jan 2024 15:06:02 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rL7V2-0002Bo-9j for qemu-devel@nongnu.org; Wed, 03 Jan 2024 15:06:01 -0500 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 403JYW2m028565; Wed, 3 Jan 2024 20:05:49 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3vaatu5qsy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Jan 2024 20:05:48 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 403K22Ug013685; Wed, 3 Jan 2024 20:05:48 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3vddsvtbff-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Jan 2024 20:05:47 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 403K2UZj020511; Wed, 3 Jan 2024 20:05:47 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3vddsvtba4-5; Wed, 03 Jan 2024 20:05:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=Q74Kutq/s1A83wS9uUJES8vX5GoYWvwZa96hIBR5kLA=; b=hCCKVXBp+oHH7bV539bRKeE+Xjdu0Q4MsiS8+s8cTOQ6KAAOxAbGR9Cn9ZLCUUc7AmL6 6Gw+EJcjNRelImFx8R4qmYqV8WLylawKD7Yz4f6qgZ8F68jbwO/AJhYQgiaHEPOWnHQm Yn6hpLv7z9XarkTDogsIyBzbATIUueDqMwrP9oBRP8Y9ipkixnmnpvbB1OzYUnQbdAb1 Ozpuvbbe8FWpY40LMOJJRwR9Y+JM/RGYDzw9qkMl41F0PpCiof3m4QnXqHYOkIw+XliC EZL20amxR+S/8/beMdde4aLjtgUPZBxW4yAftAK/czAY4Il505HLhzE6igN9qyX3J0fb cw== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Peter Xu , Paolo Bonzini , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fabiano Rosas , Leonardo Bras , Markus Armbruster , Anthony PERARD , Stefan Berger , Gerd Hoffmann , Stefano Stabellini , Paul Durrant , Eric Blake , Richard Henderson , Steve Sistare Subject: [PATCH V9 04/12] cpus: vm_resume Date: Wed, 3 Jan 2024 12:05:33 -0800 Message-Id: <1704312341-66640-5-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1704312341-66640-1-git-send-email-steven.sistare@oracle.com> References: <1704312341-66640-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-03_08,2024-01-03_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 suspectscore=0 mlxscore=0 adultscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401030162 X-Proofpoint-GUID: gqVmwTxsH-W1ylrRJKz5SMaAOnSZZPSV X-Proofpoint-ORIG-GUID: gqVmwTxsH-W1ylrRJKz5SMaAOnSZZPSV Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1704312383319100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Define the vm_resume helper, for use in subsequent patches. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu --- include/sysemu/runstate.h | 9 +++++++++ system/cpus.c | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h index 618eb49..0117d24 100644 --- a/include/sysemu/runstate.h +++ b/include/sysemu/runstate.h @@ -57,6 +57,15 @@ void vm_start(void); * @step_pending: whether any of the CPUs is about to be single-stepped by= gdb */ int vm_prepare_start(bool step_pending); + +/** + * vm_resume: If @state is a live state, start the vm and set the state, + * else just set the state. + * + * @state: the state to restore + */ +void vm_resume(RunState state); + int vm_stop(RunState state); int vm_stop_force_state(RunState state); int vm_shutdown(void); diff --git a/system/cpus.c b/system/cpus.c index f162435..7d2c28b 100644 --- a/system/cpus.c +++ b/system/cpus.c @@ -748,6 +748,15 @@ void vm_start(void) } } =20 +void vm_resume(RunState state) +{ + if (runstate_is_live(state)) { + vm_start(); + } else { + runstate_set(state); + } +} + /* does a state transition even if the VM is already stopped, current state is forgotten forever */ int vm_stop_force_state(RunState state) --=20 1.8.3.1 From nobody Tue May 14 13:13:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1704312433; cv=none; d=zohomail.com; s=zohoarc; b=hwTnWjt7lLVRROWqVVv7sFhWGpDhbZBT10MOyzi+gTE+AnPpKvWdy/Qw/fRrJXNEr/LSHsrtGj/qFqp/vZM5/oU1UitY5j8ZOh02uNfMlCYqDUJNdiin2vDQzKjJ6EdBXMK2IWaJIPcTYHR1Gj69Rea+sVmT3QMJ/JWZGcthYJU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704312433; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Mihr5Jscizpg8a8FDyULvmE7P2qbwqkKtvgvSdWyiBc=; b=dpy9ymIrf0nqbP1LLbzL9R+c2HvgLKqjIXA1k+VBlSY8W0Prp5k1RAuCOZdqUaDX6ySXA70keUOZe0mtYfwGqKo2kAPQt2RrwMk5+eOSN9apL7sfRk5xoCvyc+0HnOWmbiyjogd/PDofcOoqRCl6U9AXBu7xJQuvMM+Q4qu3B6g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704312433446748.6535248968377; Wed, 3 Jan 2024 12:07:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rL7Vy-0005Jw-Oh; Wed, 03 Jan 2024 15:07:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rL7VP-00057g-7P for qemu-devel@nongnu.org; Wed, 03 Jan 2024 15:06:24 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rL7VM-0002ID-NH for qemu-devel@nongnu.org; Wed, 03 Jan 2024 15:06:22 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 403JXJuX017171; Wed, 3 Jan 2024 20:05:50 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3vaa03wt2t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Jan 2024 20:05:50 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 403K23WB013830; Wed, 3 Jan 2024 20:05:48 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3vddsvtbg9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Jan 2024 20:05:48 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 403K2UZl020511; Wed, 3 Jan 2024 20:05:48 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3vddsvtba4-6; Wed, 03 Jan 2024 20:05:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=Mihr5Jscizpg8a8FDyULvmE7P2qbwqkKtvgvSdWyiBc=; b=iLueuJt5TpHdebtOkH3EvCKhCeLYTUch2v1oKgWWkuvlDkwTM5oSS02LITx7hpMH7Mj6 rQiXfNADm9YzPDUUk50MWuCIgLRefVIIdqJIaEMEbWlJb7LbF12eVZzG7PMD36pQH1+K LSyy/wgXWetLjP/EnnDvgq5VuX6XI8JKIKCWg1XvtVgjukGe2/ulLpsXh+ebZV7oropj N3QHjb3NGvwA8zV4JqMgql5ifwryffUSAkv3qGg0uuwPNYtaKJQOtS3MwekJj0NI5e/V lO5AZQxXdiMXRgpVAxe2RyHHjXDJk+E1K05SfSHUoN22sw4j8hcwSZg9MacKYp3eXL4T ug== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Peter Xu , Paolo Bonzini , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fabiano Rosas , Leonardo Bras , Markus Armbruster , Anthony PERARD , Stefan Berger , Gerd Hoffmann , Stefano Stabellini , Paul Durrant , Eric Blake , Richard Henderson , Steve Sistare Subject: [PATCH V9 05/12] migration: propagate suspended runstate Date: Wed, 3 Jan 2024 12:05:34 -0800 Message-Id: <1704312341-66640-6-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1704312341-66640-1-git-send-email-steven.sistare@oracle.com> References: <1704312341-66640-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-03_08,2024-01-03_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 suspectscore=0 mlxscore=0 adultscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401030162 X-Proofpoint-ORIG-GUID: geF1ZIgjUlyfAIWcrwFDwe5Zpa516rhY X-Proofpoint-GUID: geF1ZIgjUlyfAIWcrwFDwe5Zpa516rhY Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1704312435287100015 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If the outgoing machine was previously suspended, propagate that to the incoming side via global_state, so a subsequent vm_start restores the suspended state. To maintain backward and forward compatibility, reclaim some space from the runstate member. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu --- migration/global_state.c | 47 +++++++++++++++++++++++++++-----------------= --- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/migration/global_state.c b/migration/global_state.c index 4e2a9d8..64a573c 100644 --- a/migration/global_state.c +++ b/migration/global_state.c @@ -22,7 +22,16 @@ =20 typedef struct { uint32_t size; - uint8_t runstate[100]; + + /* + * runstate was 100 bytes, zero padded, but we trimmed it to add a + * few fields and maintain backwards compatibility. + */ + uint8_t runstate[32]; + uint8_t has_vm_was_suspended; + uint8_t vm_was_suspended; + uint8_t unused[66]; + RunState state; bool received; } GlobalState; @@ -35,6 +44,10 @@ static void global_state_do_store(RunState state) assert(strlen(state_str) < sizeof(global_state.runstate)); strpadcpy((char *)global_state.runstate, sizeof(global_state.runstate), state_str, '\0'); + global_state.has_vm_was_suspended =3D true; + global_state.vm_was_suspended =3D vm_get_suspended(); + + memset(global_state.unused, 0, sizeof(global_state.unused)); } =20 void global_state_store(void) @@ -59,24 +72,7 @@ RunState global_state_get_runstate(void) =20 static bool global_state_needed(void *opaque) { - GlobalState *s =3D opaque; - char *runstate =3D (char *)s->runstate; - - /* If it is not optional, it is mandatory */ - - if (migrate_get_current()->store_global_state) { - return true; - } - - /* If state is running or paused, it is not needed */ - - if (strcmp(runstate, "running") =3D=3D 0 || - strcmp(runstate, "paused") =3D=3D 0) { - return false; - } - - /* for any other state it is needed */ - return true; + return migrate_get_current()->store_global_state; } =20 static int global_state_post_load(void *opaque, int version_id) @@ -93,7 +89,7 @@ static int global_state_post_load(void *opaque, int versi= on_id) sizeof(s->runstate)) =3D=3D sizeof(s->runstate)) { /* * This condition should never happen during migration, because - * all runstate names are shorter than 100 bytes (the size of + * all runstate names are shorter than 32 bytes (the size of * s->runstate). However, a malicious stream could overflow * the qapi_enum_parse() call, so we force the last character * to a NUL byte. @@ -110,6 +106,14 @@ static int global_state_post_load(void *opaque, int ve= rsion_id) } s->state =3D r; =20 + /* + * global_state is saved on the outgoing side before forcing a stopped + * state, so it may have saved state=3Dsuspended and vm_was_suspended= =3D0. + * Now we are in a paused state, and when we later call vm_start, it m= ust + * restore the suspended state, so we must set vm_was_suspended=3D1 he= re. + */ + vm_set_suspended(s->vm_was_suspended || r =3D=3D RUN_STATE_SUSPENDED); + return 0; } =20 @@ -134,6 +138,9 @@ static const VMStateDescription vmstate_globalstate =3D= { .fields =3D (VMStateField[]) { VMSTATE_UINT32(size, GlobalState), VMSTATE_BUFFER(runstate, GlobalState), + VMSTATE_UINT8(has_vm_was_suspended, GlobalState), + VMSTATE_UINT8(vm_was_suspended, GlobalState), + VMSTATE_BUFFER(unused, GlobalState), VMSTATE_END_OF_LIST() }, }; --=20 1.8.3.1 From nobody Tue May 14 13:13:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1704312451; cv=none; d=zohomail.com; s=zohoarc; b=g60qhzQK4VW/lYOL2jic9cQw4948ly5ODTIlRBGtAobp0eXbUJHCJGoN70kvfuuFZTAVcigndZCLtdLpKGiXIg8r4KzbIJW9HH8lX8R/iL9Hvpg2cogZpLGAQ0kzamPX9Q0yVDQfVfRQ3Ix6e6GovxZRm5OHMd4Eqcg5na8vADg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704312451; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Tdz/0665DIlKQYsKJPHoEEW9YQgWa4jTt33Mn6oJUDU=; b=lI/ILzKXP/gpPFX4WbjiLaixRngCKKVyKMMRGbIorcBv97fFuWyrE1TvLpBB9arUSfsASpPNBIJwj2C+WFQNRGejatOD06M9RMI4cmlmAzuSLpO3odQvJ4Ql/Xy4uPEyFI5s9LuHXFIhqUEvyXiZDnkKtwrGa8AM6vwufpXojl0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704312451732359.4000441340411; Wed, 3 Jan 2024 12:07:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rL7VH-0004rJ-Rf; Wed, 03 Jan 2024 15:06:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rL7VG-0004mT-8w for qemu-devel@nongnu.org; Wed, 03 Jan 2024 15:06:14 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rL7VD-0002GB-SJ for qemu-devel@nongnu.org; Wed, 03 Jan 2024 15:06:13 -0500 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 403JXMKa030829; Wed, 3 Jan 2024 20:05:51 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3va9me5qq2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Jan 2024 20:05:50 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 403K22g3013704; Wed, 3 Jan 2024 20:05:49 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3vddsvtbgv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Jan 2024 20:05:49 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 403K2UZn020511; Wed, 3 Jan 2024 20:05:49 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3vddsvtba4-7; Wed, 03 Jan 2024 20:05:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=Tdz/0665DIlKQYsKJPHoEEW9YQgWa4jTt33Mn6oJUDU=; b=C4i3B+Al7zeK7mwoSVh3DZR5iw244G7srCHtkJqI8M9D+VNp5PH/W0C0HTZmQRutqjFV khs76DVDMd4tJXiRVBEXf3zhIsbfN1aYKM8a91cRtqglHAJjEzokBjzqakDNrR/wCW+f +Tbvuaj0hyONQffc+ekxjAgthK85JVaExcRyuEcsllGMmKQOE99DFODR1hpOndcDgGR9 jjQV2MSEkdOABuYABwyLUSzN52Bxi2t6ko6Kw4Q/mt0aF02h1iBav41yn8z2Ni6Eqazj 84dYJtIHU6R3afE+E2snavjzPSgBtbqaCqWPNt6AT1JhlxDxvdpGI9lliXn7jKXm7lWa 8A== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Peter Xu , Paolo Bonzini , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fabiano Rosas , Leonardo Bras , Markus Armbruster , Anthony PERARD , Stefan Berger , Gerd Hoffmann , Stefano Stabellini , Paul Durrant , Eric Blake , Richard Henderson , Steve Sistare Subject: [PATCH V9 06/12] migration: preserve suspended runstate Date: Wed, 3 Jan 2024 12:05:35 -0800 Message-Id: <1704312341-66640-7-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1704312341-66640-1-git-send-email-steven.sistare@oracle.com> References: <1704312341-66640-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-03_08,2024-01-03_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 suspectscore=0 mlxscore=0 adultscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401030162 X-Proofpoint-ORIG-GUID: j7j69EdrP-f_-mXLXGYyq3OdMxiD7bnG X-Proofpoint-GUID: j7j69EdrP-f_-mXLXGYyq3OdMxiD7bnG Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1704312453370100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" A guest that is migrated in the suspended state automaticaly wakes and continues execution. This is wrong; the guest should end migration in the same state it started. The root cause is that the outgoing migration code automatically wakes the guest, then saves the RUNNING runstate in global_state_store(), hence the incoming migration code thinks the guest is running and continues the guest if autostart is true. On the outgoing side, delete the call to qemu_system_wakeup_request(). Now that vm_stop completely stops a vm in the suspended state (from the preceding patches), the existing call to vm_stop_force_state is sufficient to correctly migrate all vmstate. On the incoming side, call vm_start if the pre-migration state was running or suspended. For the latter, vm_start correctly restores the suspended state, and a future system_wakeup monitor request will cause the vm to resume running. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu --- migration/migration.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 3ce04b2..8124811 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -604,7 +604,7 @@ static void process_incoming_migration_bh(void *opaque) */ if (!migrate_late_block_activate() || (autostart && (!global_state_received() || - global_state_get_runstate() =3D=3D RUN_STATE_RUNNING))) { + runstate_is_live(global_state_get_runstate())))) { /* Make sure all file formats throw away their mutable metadata. * If we get an error here, just don't restart the VM yet. */ bdrv_activate_all(&local_err); @@ -628,7 +628,7 @@ static void process_incoming_migration_bh(void *opaque) dirty_bitmap_mig_before_vm_start(); =20 if (!global_state_received() || - global_state_get_runstate() =3D=3D RUN_STATE_RUNNING) { + runstate_is_live(global_state_get_runstate())) { if (autostart) { vm_start(); } else { @@ -2416,7 +2416,6 @@ static int postcopy_start(MigrationState *ms, Error *= *errp) =20 migration_downtime_start(ms); =20 - qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL); global_state_store(); ret =3D migration_stop_vm(RUN_STATE_FINISH_MIGRATE); if (ret < 0) { @@ -2615,7 +2614,6 @@ static int migration_completion_precopy(MigrationStat= e *s, =20 qemu_mutex_lock_iothread(); migration_downtime_start(s); - qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL); =20 s->vm_old_state =3D runstate_get(); global_state_store(); @@ -3136,7 +3134,7 @@ static void migration_iteration_finish(MigrationState= *s) case MIGRATION_STATUS_FAILED: case MIGRATION_STATUS_CANCELLED: case MIGRATION_STATUS_CANCELLING: - if (s->vm_old_state =3D=3D RUN_STATE_RUNNING) { + if (runstate_is_live(s->vm_old_state)) { if (!runstate_check(RUN_STATE_SHUTDOWN)) { vm_start(); } --=20 1.8.3.1 From nobody Tue May 14 13:13:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1704312427; cv=none; d=zohomail.com; s=zohoarc; b=SKK3abD4dqEBM88RPQ6OLiZU/Ve8u0a6d3gNnG7iK4bFZAOlJjR1A094TXf3hBGg+3ocYyudEMBJvSN9y3OihyjzftnWcIKKX/DlrLHvzLxjA7ktZzyt3+NEEOqCYjdJx4C1gUqnSklCkajaPQaYNvEUANI4PSQa2GuUW5pg6is= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704312427; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=h4YP699pHqFu+oZKrSGgYwEFMoMb4DP9/SgUZkepa4k=; b=a/1pY5WoMfFm7yIBkn4HoTWghOXVwAH7pyOtR5/OF6LG/M/WPN9Ks4OwbBHHnqwifXgUJ8o/AeNsILrroe+v8SSJ+2oO1pzeMA+0WeaOX4rT8pA8y5fSW/dhRSn5cGWYLmFQTmp6hQCKF3kcGfqj9Fh9+LObDZj5/ZETmmif1wQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704312427126881.2005946146335; Wed, 3 Jan 2024 12:07:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rL7VR-00057e-In; Wed, 03 Jan 2024 15:06:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rL7VM-0004xo-Vp for qemu-devel@nongnu.org; Wed, 03 Jan 2024 15:06:21 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rL7VJ-0002HZ-TD for qemu-devel@nongnu.org; Wed, 03 Jan 2024 15:06:19 -0500 Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 403JXQEv003044; Wed, 3 Jan 2024 20:05:52 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3vab8d5sxr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Jan 2024 20:05:51 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 403K22AT013703; Wed, 3 Jan 2024 20:05:50 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3vddsvtbht-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Jan 2024 20:05:50 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 403K2UZp020511; Wed, 3 Jan 2024 20:05:50 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3vddsvtba4-8; Wed, 03 Jan 2024 20:05:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=h4YP699pHqFu+oZKrSGgYwEFMoMb4DP9/SgUZkepa4k=; b=mM9Su54jq4HKZ7ajiz8HS+4Pxn6/4i6wTnhtZD1viQCsXsb+FzP/DwKWMiMtJYrZs0qL MK5asGmfSKZTyFHLEx83MJzTA7VGhCQ7AnIOWeLDmAosOSj69irSVONhR6fIBlZagAVd ycP3dimLP8kU5ooKitv8VxvRn0nHL41qyCVzeTYfdlkaMEGbRDi2PRk/fPb6jl/Y7lz7 yfMubfW04crE1wqn5DKNOmU+lGnRLD7D0T2NUXScIRUU6Keu08S0q8Ib8pI2Z+rGCRUS MPPNtPXZClEbPksoh127OukmFYVMevTfMqSLBMsZPwTqSC80/dwr/prX7wcjHjZJDY4L Fg== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Peter Xu , Paolo Bonzini , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fabiano Rosas , Leonardo Bras , Markus Armbruster , Anthony PERARD , Stefan Berger , Gerd Hoffmann , Stefano Stabellini , Paul Durrant , Eric Blake , Richard Henderson , Steve Sistare Subject: [PATCH V9 07/12] migration: preserve suspended for snapshot Date: Wed, 3 Jan 2024 12:05:36 -0800 Message-Id: <1704312341-66640-8-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1704312341-66640-1-git-send-email-steven.sistare@oracle.com> References: <1704312341-66640-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-03_08,2024-01-03_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 suspectscore=0 mlxscore=0 adultscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401030162 X-Proofpoint-GUID: 5ktBXcL-dxg4RmUblXzJGQipREGorCZi X-Proofpoint-ORIG-GUID: 5ktBXcL-dxg4RmUblXzJGQipREGorCZi Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1704312429309100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Restoring a snapshot can break a suspended guest. Snapshots suffer from the same suspended-state issues that affect live migration, plus they must handle an additional problematic scenario, which is that a running vm must remain running if it loads a suspended snapshot. To save, the existing vm_stop call now completely stops the suspended state. Finish with vm_resume to leave the vm in the state it had prior to the save, correctly restoring the suspended state. To load, if the snapshot is not suspended, then vm_stop + vm_resume correctly handles all states, and leaves the vm in the state it had prior to the load. However, if the snapshot is suspended, restoration is trickier. First, call vm_resume to restore the state to suspended so the current state matches the saved state. Then, if the pre-load state is running, call wakeup to resume running. Prior to these changes, the vm_stop to RUN_STATE_SAVE_VM and RUN_STATE_RESTORE_VM did not change runstate if the current state was suspended, but now it does, so allow these transitions. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu --- include/migration/snapshot.h | 7 +++++++ migration/migration-hmp-cmds.c | 8 +++++--- migration/savevm.c | 23 +++++++++++++---------- system/runstate.c | 5 +++++ system/vl.c | 2 ++ 5 files changed, 32 insertions(+), 13 deletions(-) diff --git a/include/migration/snapshot.h b/include/migration/snapshot.h index e72083b..9e4dcaa 100644 --- a/include/migration/snapshot.h +++ b/include/migration/snapshot.h @@ -16,6 +16,7 @@ #define QEMU_MIGRATION_SNAPSHOT_H =20 #include "qapi/qapi-builtin-types.h" +#include "qapi/qapi-types-run-state.h" =20 /** * save_snapshot: Save an internal snapshot. @@ -61,4 +62,10 @@ bool delete_snapshot(const char *name, bool has_devices, strList *devices, Error **errp); =20 +/** + * load_snapshot_resume: Restore runstate after loading snapshot. + * @state: state to restore + */ +void load_snapshot_resume(RunState state); + #endif diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c index 99710c8..740a219 100644 --- a/migration/migration-hmp-cmds.c +++ b/migration/migration-hmp-cmds.c @@ -399,15 +399,17 @@ void hmp_info_migrate_parameters(Monitor *mon, const = QDict *qdict) =20 void hmp_loadvm(Monitor *mon, const QDict *qdict) { - int saved_vm_running =3D runstate_is_running(); + RunState saved_state =3D runstate_get(); + const char *name =3D qdict_get_str(qdict, "name"); Error *err =3D NULL; =20 vm_stop(RUN_STATE_RESTORE_VM); =20 - if (load_snapshot(name, NULL, false, NULL, &err) && saved_vm_running) { - vm_start(); + if (load_snapshot(name, NULL, false, NULL, &err)) { + load_snapshot_resume(saved_state); } + hmp_handle_error(mon, err); } =20 diff --git a/migration/savevm.c b/migration/savevm.c index 1b9ab7b..74f915f 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -3046,7 +3046,7 @@ bool save_snapshot(const char *name, bool overwrite, = const char *vmstate, QEMUSnapshotInfo sn1, *sn =3D &sn1; int ret =3D -1, ret2; QEMUFile *f; - int saved_vm_running; + RunState saved_state =3D runstate_get(); uint64_t vm_state_size; g_autoptr(GDateTime) now =3D g_date_time_new_now_local(); =20 @@ -3092,8 +3092,6 @@ bool save_snapshot(const char *name, bool overwrite, = const char *vmstate, return false; } =20 - saved_vm_running =3D runstate_is_running(); - global_state_store(); vm_stop(RUN_STATE_SAVE_VM); =20 @@ -3147,9 +3145,7 @@ bool save_snapshot(const char *name, bool overwrite, = const char *vmstate, the_end: bdrv_drain_all_end(); =20 - if (saved_vm_running) { - vm_start(); - } + vm_resume(saved_state); return ret =3D=3D 0; } =20 @@ -3317,6 +3313,14 @@ err_drain: return false; } =20 +void load_snapshot_resume(RunState state) +{ + vm_resume(state); + if (state =3D=3D RUN_STATE_RUNNING && runstate_get() =3D=3D RUN_STATE_= SUSPENDED) { + qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, &error_abort); + } +} + bool delete_snapshot(const char *name, bool has_devices, strList *devices, Error **errp) { @@ -3381,16 +3385,15 @@ static void snapshot_load_job_bh(void *opaque) { Job *job =3D opaque; SnapshotJob *s =3D container_of(job, SnapshotJob, common); - int orig_vm_running; + RunState orig_state =3D runstate_get(); =20 job_progress_set_remaining(&s->common, 1); =20 - orig_vm_running =3D runstate_is_running(); vm_stop(RUN_STATE_RESTORE_VM); =20 s->ret =3D load_snapshot(s->tag, s->vmstate, true, s->devices, s->errp= ); - if (s->ret && orig_vm_running) { - vm_start(); + if (s->ret) { + load_snapshot_resume(orig_state); } =20 job_progress_update(&s->common, 1); diff --git a/system/runstate.c b/system/runstate.c index e2fa204..ca9eb54 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -77,6 +77,7 @@ typedef struct { =20 static const RunStateTransition runstate_transitions_def[] =3D { { RUN_STATE_PRELAUNCH, RUN_STATE_INMIGRATE }, + { RUN_STATE_PRELAUNCH, RUN_STATE_SUSPENDED }, =20 { RUN_STATE_DEBUG, RUN_STATE_RUNNING }, { RUN_STATE_DEBUG, RUN_STATE_FINISH_MIGRATE }, @@ -132,6 +133,7 @@ static const RunStateTransition runstate_transitions_de= f[] =3D { =20 { RUN_STATE_RESTORE_VM, RUN_STATE_RUNNING }, { RUN_STATE_RESTORE_VM, RUN_STATE_PRELAUNCH }, + { RUN_STATE_RESTORE_VM, RUN_STATE_SUSPENDED }, =20 { RUN_STATE_COLO, RUN_STATE_RUNNING }, { RUN_STATE_COLO, RUN_STATE_PRELAUNCH }, @@ -150,6 +152,7 @@ static const RunStateTransition runstate_transitions_de= f[] =3D { { RUN_STATE_RUNNING, RUN_STATE_COLO}, =20 { RUN_STATE_SAVE_VM, RUN_STATE_RUNNING }, + { RUN_STATE_SAVE_VM, RUN_STATE_SUSPENDED }, =20 { RUN_STATE_SHUTDOWN, RUN_STATE_PAUSED }, { RUN_STATE_SHUTDOWN, RUN_STATE_FINISH_MIGRATE }, @@ -163,6 +166,8 @@ static const RunStateTransition runstate_transitions_de= f[] =3D { { RUN_STATE_SUSPENDED, RUN_STATE_PRELAUNCH }, { RUN_STATE_SUSPENDED, RUN_STATE_COLO}, { RUN_STATE_SUSPENDED, RUN_STATE_PAUSED}, + { RUN_STATE_SUSPENDED, RUN_STATE_SAVE_VM }, + { RUN_STATE_SUSPENDED, RUN_STATE_RESTORE_VM }, =20 { RUN_STATE_WATCHDOG, RUN_STATE_RUNNING }, { RUN_STATE_WATCHDOG, RUN_STATE_FINISH_MIGRATE }, diff --git a/system/vl.c b/system/vl.c index 6b87bfa..1eec5f6 100644 --- a/system/vl.c +++ b/system/vl.c @@ -2710,7 +2710,9 @@ void qmp_x_exit_preconfig(Error **errp) qemu_machine_creation_done(); =20 if (loadvm) { + RunState state =3D autostart ? RUN_STATE_RUNNING : runstate_get(); load_snapshot(loadvm, NULL, false, NULL, &error_fatal); + load_snapshot_resume(state); } if (replay_mode !=3D REPLAY_MODE_NONE) { replay_vmstate_init(); --=20 1.8.3.1 From nobody Tue May 14 13:13:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1704312431; cv=none; d=zohomail.com; s=zohoarc; b=ionJEA2d5lunizeeA0XF4IeiI0sgbmbKCJvyCxLsYSNvptOlBW5mEevlAQLteHxA4aCMBql71DxXETdvYIH6S/1bmClDDT1lJB5PP7oojSfV6cSu3XkhqwVcM/Yn0w8cOr0Ry/Xat6ZhZRJ6GkkB32LE12smhPur0lRuh3u6ZiU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704312431; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=16Hz/0QpTsbArtLyqdF3glLAD2N1aY4+squSC785lPc=; b=MxLWqGdIPiiSjwYWNYV08y6ZETpfXguCAOby/PvGDw8SJNNLOfZv97kMCgbvsf5KqP76Av7H9QNrNLlY+KG0m3nXi1B8+cjYFGFVEl9Vt+5RzcEIZLb1YPe/Cm5LLUETDhpRfT5+BRSZZHRE85Eq0S3Gp1ELfSyPkvurysu68M0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704312431105826.0119772216384; Wed, 3 Jan 2024 12:07:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rL7VJ-0004uG-Qp; Wed, 03 Jan 2024 15:06:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rL7VH-0004qj-Ja for qemu-devel@nongnu.org; Wed, 03 Jan 2024 15:06:15 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rL7VG-0002GU-0T for qemu-devel@nongnu.org; Wed, 03 Jan 2024 15:06:15 -0500 Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 403JXQ4N003045; Wed, 3 Jan 2024 20:05:53 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3vab8d5sxt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Jan 2024 20:05:52 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 403K1v6l013568; Wed, 3 Jan 2024 20:05:51 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3vddsvtbjp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Jan 2024 20:05:51 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 403K2UZr020511; Wed, 3 Jan 2024 20:05:51 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3vddsvtba4-9; Wed, 03 Jan 2024 20:05:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=16Hz/0QpTsbArtLyqdF3glLAD2N1aY4+squSC785lPc=; b=UVv/OtT11H3IesolPSsgbEpgDmY+ly+Dj1LEwqL0ymfPTpk3BWrCAeQpCtU+27NxESP2 FyQjwF9PhJGrQOSLhJxBcmy33/3Uy6i7xkLOhR4G4f2whiHEldwHaArJpUpmsGGFCjVU prJOPI7k7R42KYX4OJ0YEGyEL2b+aqWrheiRjWf1k8nbZVZyfOW0/GfPU+lvASBZK5eg 9pN//4PLdVrvP3iTkkRs5a21JjTjFXF7Yh0KKFSsGe/VOToUwkvY04CXUupibxPwaSd1 6FmjbTC8mtzH7qkQj4+nMbey8ShYzK2rsZxnh6FjpTPx2RY1IgfhL1JGkqvafbH6XbfE ew== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Peter Xu , Paolo Bonzini , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fabiano Rosas , Leonardo Bras , Markus Armbruster , Anthony PERARD , Stefan Berger , Gerd Hoffmann , Stefano Stabellini , Paul Durrant , Eric Blake , Richard Henderson , Steve Sistare Subject: [PATCH V9 08/12] migration: preserve suspended for bg_migration Date: Wed, 3 Jan 2024 12:05:37 -0800 Message-Id: <1704312341-66640-9-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1704312341-66640-1-git-send-email-steven.sistare@oracle.com> References: <1704312341-66640-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-03_08,2024-01-03_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 suspectscore=0 mlxscore=0 adultscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401030162 X-Proofpoint-GUID: KmU-KxlWY72OVsEh5RnRswDJNJ1WNbec X-Proofpoint-ORIG-GUID: KmU-KxlWY72OVsEh5RnRswDJNJ1WNbec Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1704312433295100011 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Do not wake a suspended guest during bg_migration, and restore the prior state at finish rather than unconditionally running. Allow the additional state transitions that occur. Signed-off-by: Steve Sistare Reviewed-by: Fabiano Rosas Reviewed-by: Peter Xu --- migration/migration.c | 7 +------ system/runstate.c | 1 + 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 8124811..2cc7e2a 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3390,7 +3390,7 @@ static void bg_migration_vm_start_bh(void *opaque) qemu_bh_delete(s->vm_start_bh); s->vm_start_bh =3D NULL; =20 - vm_start(); + vm_resume(s->vm_old_state); migration_downtime_end(s); } =20 @@ -3462,11 +3462,6 @@ static void *bg_migration_thread(void *opaque) =20 qemu_mutex_lock_iothread(); =20 - /* - * If VM is currently in suspended state, then, to make a valid runsta= te - * transition in vm_stop_force_state() we need to wakeup it up. - */ - qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL); s->vm_old_state =3D runstate_get(); =20 global_state_store(); diff --git a/system/runstate.c b/system/runstate.c index ca9eb54..621a023 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -168,6 +168,7 @@ static const RunStateTransition runstate_transitions_de= f[] =3D { { RUN_STATE_SUSPENDED, RUN_STATE_PAUSED}, { RUN_STATE_SUSPENDED, RUN_STATE_SAVE_VM }, { RUN_STATE_SUSPENDED, RUN_STATE_RESTORE_VM }, + { RUN_STATE_SUSPENDED, RUN_STATE_SHUTDOWN }, =20 { RUN_STATE_WATCHDOG, RUN_STATE_RUNNING }, { RUN_STATE_WATCHDOG, RUN_STATE_FINISH_MIGRATE }, --=20 1.8.3.1 From nobody Tue May 14 13:13:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1704312439; cv=none; d=zohomail.com; s=zohoarc; b=ZpmVMfMJdFQ4AyHNmqZbeDnb5GffyXQt7cm1zZhXVB+alPJAU/tW0GaB7B6aZQNY8iZHnOxH+lOhzWMiODH4iuTeqMOmFiG2FgnxTzH6csuhrPguKKpBhrVvh61EurQeAbWRGr1bmIrIFGUBgL90qOIWmslzMYfAMRSkvq6sce0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704312439; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vwbj1FNVKJTh+/LF/PLtvyJP+rwdtxG3LTztrqi92U4=; b=lh3S67stQBfic/CGM70+D0iQcpvjnPm7Lv7rzRo1HIRWLlI+/6rAqc3uDhKssCo/UxGt9brQasCMKdSyRACqL6iDv6TIprgapnbcAKgsEb00cULDvTQ494wwPma5ixg4JwoIxSI0DIUS/edQFHOlQtRU48gatIaSXh5JrWtaM38= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704312439429619.0449100803298; Wed, 3 Jan 2024 12:07:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rL7VT-0005B3-RR; Wed, 03 Jan 2024 15:06:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rL7VP-00057h-7y for qemu-devel@nongnu.org; Wed, 03 Jan 2024 15:06:24 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rL7VM-0002IO-Mc for qemu-devel@nongnu.org; Wed, 03 Jan 2024 15:06:22 -0500 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 403JXM0P030826; Wed, 3 Jan 2024 20:05:54 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3va9me5qq5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Jan 2024 20:05:53 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 403K21XJ013612; Wed, 3 Jan 2024 20:05:52 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3vddsvtbkd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Jan 2024 20:05:52 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 403K2UZt020511; Wed, 3 Jan 2024 20:05:52 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3vddsvtba4-10; Wed, 03 Jan 2024 20:05:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2023-11-20; bh=vwbj1FNVKJTh+/LF/PLtvyJP+rwdtxG3LTztrqi92U4=; b=NJta1chcJblDEXBbaxgT63BtY0tg+b5Mo4jYfRSE0Tm3gWbW+V3j1espUky75VvpVHSu PpXH9bhc7Ml5Z+6gvlSsIoe2RR37uEUxtWLbqU/NEVobhnELT/GN4tCvuC3N1h19YRj/ vtme5yiheZ9LdSP/w3mPU3ti6atRYETWMNIOORZiLIVnE2wvkyLeQi+SE9tcPR9wOLFY YIf2/PvPRkzHBXN20k7No3I5ZW0r/Vbmd5P28VEIx0kexUA4YqBxtILuMa4ExR5v8HMW t0L5+yrxL47vuj+xU3qYI/9svb0YY0aTeuwuAPpEmFkLslZMUsGvvrsgT+79POI8nAEA WQ== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Peter Xu , Paolo Bonzini , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fabiano Rosas , Leonardo Bras , Markus Armbruster , Anthony PERARD , Stefan Berger , Gerd Hoffmann , Stefano Stabellini , Paul Durrant , Eric Blake , Richard Henderson , Steve Sistare Subject: [PATCH V9 09/12] tests/qtest: migration events Date: Wed, 3 Jan 2024 12:05:38 -0800 Message-Id: <1704312341-66640-10-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1704312341-66640-1-git-send-email-steven.sistare@oracle.com> References: <1704312341-66640-1-git-send-email-steven.sistare@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-03_08,2024-01-03_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 suspectscore=0 mlxscore=0 adultscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401030162 X-Proofpoint-ORIG-GUID: Ear32jksWHMGGgJxajr7I5idw50a1Ll0 X-Proofpoint-GUID: Ear32jksWHMGGgJxajr7I5idw50a1Ll0 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1704312441333100003 Define a state object to capture events seen by migration tests, to allow more events to be captured in a subsequent patch, and simplify event checking in wait_for_migration_pass. No functional change. Signed-off-by: Steve Sistare Reviewed-by: Fabiano Rosas Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/qtest/migration-helpers.c | 24 ++++------- tests/qtest/migration-helpers.h | 9 ++-- tests/qtest/migration-test.c | 91 +++++++++++++++++++------------------= ---- 3 files changed, 56 insertions(+), 68 deletions(-) diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helper= s.c index 24fb7b3..fd3b94e 100644 --- a/tests/qtest/migration-helpers.c +++ b/tests/qtest/migration-helpers.c @@ -24,26 +24,16 @@ */ #define MIGRATION_STATUS_WAIT_TIMEOUT 120 =20 -bool migrate_watch_for_stop(QTestState *who, const char *name, - QDict *event, void *opaque) -{ - bool *seen =3D opaque; - - if (g_str_equal(name, "STOP")) { - *seen =3D true; - return true; - } - - return false; -} - -bool migrate_watch_for_resume(QTestState *who, const char *name, +bool migrate_watch_for_events(QTestState *who, const char *name, QDict *event, void *opaque) { - bool *seen =3D opaque; + QTestMigrationState *state =3D opaque; =20 - if (g_str_equal(name, "RESUME")) { - *seen =3D true; + if (g_str_equal(name, "STOP")) { + state->stop_seen =3D true; + return true; + } else if (g_str_equal(name, "RESUME")) { + state->resume_seen =3D true; return true; } =20 diff --git a/tests/qtest/migration-helpers.h b/tests/qtest/migration-helper= s.h index e31dc85..3d32699 100644 --- a/tests/qtest/migration-helpers.h +++ b/tests/qtest/migration-helpers.h @@ -15,9 +15,12 @@ =20 #include "libqtest.h" =20 -bool migrate_watch_for_stop(QTestState *who, const char *name, - QDict *event, void *opaque); -bool migrate_watch_for_resume(QTestState *who, const char *name, +typedef struct QTestMigrationState { + bool stop_seen; + bool resume_seen; +} QTestMigrationState; + +bool migrate_watch_for_events(QTestState *who, const char *name, QDict *event, void *opaque); =20 G_GNUC_PRINTF(3, 4) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index d520c58..41fc837 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -43,8 +43,8 @@ unsigned start_address; unsigned end_address; static bool uffd_feature_thread_id; -static bool got_src_stop; -static bool got_dst_resume; +static QTestMigrationState src_state; +static QTestMigrationState dst_state; =20 /* * An initial 3 MB offset is used as that corresponds @@ -230,6 +230,20 @@ static void wait_for_serial(const char *side) } while (true); } =20 +static void wait_for_stop(QTestState *who, QTestMigrationState *state) +{ + if (!state->stop_seen) { + qtest_qmp_eventwait(who, "STOP"); + } +} + +static void wait_for_resume(QTestState *who, QTestMigrationState *state) +{ + if (!state->resume_seen) { + qtest_qmp_eventwait(who, "RESUME"); + } +} + /* * It's tricky to use qemu's migration event capability with qtest, * events suddenly appearing confuse the qmp()/hmp() responses. @@ -277,21 +291,19 @@ static void read_blocktime(QTestState *who) qobject_unref(rsp_return); } =20 +/* + * Wait for two changes in the migration pass count, but bail if we stop. + */ static void wait_for_migration_pass(QTestState *who) { - uint64_t initial_pass =3D get_migration_pass(who); - uint64_t pass; + uint64_t pass, prev_pass =3D 0, changes =3D 0; =20 - /* Wait for the 1st sync */ - while (!got_src_stop && !initial_pass) { - usleep(1000); - initial_pass =3D get_migration_pass(who); - } - - do { + while (changes < 2 && !src_state.stop_seen) { usleep(1000); pass =3D get_migration_pass(who); - } while (pass =3D=3D initial_pass && !got_src_stop); + changes +=3D (pass !=3D prev_pass); + prev_pass =3D pass; + } } =20 static void check_guests_ram(QTestState *who) @@ -617,10 +629,7 @@ static void migrate_postcopy_start(QTestState *from, Q= TestState *to) { qtest_qmp_assert_success(from, "{ 'execute': 'migrate-start-postcopy' = }"); =20 - if (!got_src_stop) { - qtest_qmp_eventwait(from, "STOP"); - } - + wait_for_stop(from, &src_state); qtest_qmp_eventwait(to, "RESUME"); } =20 @@ -756,8 +765,8 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, } } =20 - got_src_stop =3D false; - got_dst_resume =3D false; + dst_state =3D (QTestMigrationState) { }; + src_state =3D (QTestMigrationState) { }; if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { memory_size =3D "150M"; =20 @@ -848,8 +857,8 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, if (!args->only_target) { *from =3D qtest_init_with_env(QEMU_ENV_SRC, cmd_source); qtest_qmp_set_event_callback(*from, - migrate_watch_for_stop, - &got_src_stop); + migrate_watch_for_events, + &src_state); } =20 cmd_target =3D g_strdup_printf("-accel kvm%s -accel tcg " @@ -869,8 +878,8 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, ignore_stderr); *to =3D qtest_init_with_env(QEMU_ENV_DST, cmd_target); qtest_qmp_set_event_callback(*to, - migrate_watch_for_resume, - &got_dst_resume); + migrate_watch_for_events, + &dst_state); =20 /* * Remove shmem file immediately to avoid memory leak in test failed c= ase. @@ -1717,9 +1726,7 @@ static void test_precopy_common(MigrateCommon *args) */ if (args->result =3D=3D MIG_TEST_SUCCEED) { qtest_qmp_assert_success(from, "{ 'execute' : 'stop'}"); - if (!got_src_stop) { - qtest_qmp_eventwait(from, "STOP"); - } + wait_for_stop(from, &src_state); migrate_ensure_converge(from); } } @@ -1765,9 +1772,8 @@ static void test_precopy_common(MigrateCommon *args) */ wait_for_migration_complete(from); =20 - if (!got_src_stop) { - qtest_qmp_eventwait(from, "STOP"); - } + wait_for_stop(from, &src_state); + } else { wait_for_migration_complete(from); /* @@ -1780,9 +1786,7 @@ static void test_precopy_common(MigrateCommon *args) qtest_qmp_assert_success(to, "{ 'execute' : 'cont'}"); } =20 - if (!got_dst_resume) { - qtest_qmp_eventwait(to, "RESUME"); - } + wait_for_resume(to, &dst_state); =20 wait_for_serial("dest_serial"); } @@ -1821,9 +1825,7 @@ static void test_file_common(MigrateCommon *args, boo= l stop_src) =20 if (stop_src) { qtest_qmp_assert_success(from, "{ 'execute' : 'stop'}"); - if (!got_src_stop) { - qtest_qmp_eventwait(from, "STOP"); - } + wait_for_stop(from, &src_state); } =20 if (args->result =3D=3D MIG_TEST_QMP_ERROR) { @@ -1844,10 +1846,7 @@ static void test_file_common(MigrateCommon *args, bo= ol stop_src) if (stop_src) { qtest_qmp_assert_success(to, "{ 'execute' : 'cont'}"); } - - if (!got_dst_resume) { - qtest_qmp_eventwait(to, "RESUME"); - } + wait_for_resume(to, &dst_state); =20 wait_for_serial("dest_serial"); =20 @@ -1966,9 +1965,7 @@ static void test_ignore_shared(void) =20 migrate_wait_for_dirty_mem(from, to); =20 - if (!got_src_stop) { - qtest_qmp_eventwait(from, "STOP"); - } + wait_for_stop(from, &src_state); =20 qtest_qmp_eventwait(to, "RESUME"); =20 @@ -2503,7 +2500,7 @@ static void test_migrate_auto_converge(void) break; } usleep(20); - g_assert_false(got_src_stop); + g_assert_false(src_state.stop_seen); } while (true); /* The first percentage of throttling should be at least init_pct */ g_assert_cmpint(percentage, >=3D, init_pct); @@ -2842,9 +2839,7 @@ static void test_multifd_tcp_cancel(void) =20 migrate_ensure_converge(from); =20 - if (!got_src_stop) { - qtest_qmp_eventwait(from, "STOP"); - } + wait_for_stop(from, &src_state); qtest_qmp_eventwait(to2, "RESUME"); =20 wait_for_serial("dest_serial"); @@ -3177,7 +3172,7 @@ static void test_migrate_dirty_limit(void) throttle_us_per_full =3D read_migrate_property_int(from, "dirty-limit-throttle-time-per-rou= nd"); usleep(100); - g_assert_false(got_src_stop); + g_assert_false(src_state.stop_seen); } =20 /* Now cancel migrate and wait for dirty limit throttle switch off */ @@ -3189,7 +3184,7 @@ static void test_migrate_dirty_limit(void) throttle_us_per_full =3D read_migrate_property_int(from, "dirty-limit-throttle-time-per-rou= nd"); usleep(100); - g_assert_false(got_src_stop); + g_assert_false(src_state.stop_seen); } while (throttle_us_per_full !=3D 0 && --max_try_count); =20 /* Assert dirty limit is not in service */ @@ -3218,7 +3213,7 @@ static void test_migrate_dirty_limit(void) throttle_us_per_full =3D read_migrate_property_int(from, "dirty-limit-throttle-time-per-rou= nd"); usleep(100); - g_assert_false(got_src_stop); + g_assert_false(src_state.stop_seen); } =20 /* --=20 1.8.3.1 From nobody Tue May 14 13:13:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1704312443; cv=none; d=zohomail.com; s=zohoarc; b=iZYWJGovsfLDfx9b1cuBiPUaUVJ+D2qDWiAeZnWzfmoX/Xuer5nAOfl+JY6O3njhgVbZKTllnsIcPihWNe4bXqpJOPqjASf7qq83/5K2WGX638Mn0nvJAQOP3OTiXy6Fg3xmxArrJUWZ6eTrUaA3J+STqLeV1ZLSW5t8vD4hoeA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704312443; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8iTZBQ+L4IocD6DvgOzcUZKcozm1YvazMNDfv4SSwt8=; b=IKT5wXoxOaV2eJAUB/9BiOwGLiGG5mkFb2kwSVkivxjBq+tCKd9sg4SfTLUjBBdf11LhaXQLfmuRkfWt3Y6xNxnMVVkdGrn9Zshj4LHyUBnV6XpkK05pf1ME42jE3vu9yg8Cx74VIR5wsoIFbXylV3pcA+S0UN5PHYC/gmHQBQ0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17043124438948.103104296157653; Wed, 3 Jan 2024 12:07:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rL7VI-0004tX-UE; Wed, 03 Jan 2024 15:06:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rL7V5-0004gN-2z for qemu-devel@nongnu.org; Wed, 03 Jan 2024 15:06:04 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rL7V2-0002C3-2y for qemu-devel@nongnu.org; Wed, 03 Jan 2024 15:06:02 -0500 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 403JXM0R030826; Wed, 3 Jan 2024 20:05:55 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3va9me5qq7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Jan 2024 20:05:54 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 403K23o7013831; Wed, 3 Jan 2024 20:05:53 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3vddsvtbm9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Jan 2024 20:05:53 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 403K2UZv020511; Wed, 3 Jan 2024 20:05:53 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3vddsvtba4-11; Wed, 03 Jan 2024 20:05:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=8iTZBQ+L4IocD6DvgOzcUZKcozm1YvazMNDfv4SSwt8=; b=EudXp7z1QYZLSk137MuArgyrgTca8JnV1i7EDQw7BTJGHe/EEQWEEAQDP+uBXNAxJehY ANo1OBfrzDnnFfRVqIpbwUoNn1teziCaK0axu2bUfXY5OZQlhrcAl5zXojwFFu8MbZl5 0+j13EUwC8cqCPa1HE2B+Crh/e7lnoOhQ04+yW+k8r1CaVYwQHETGLB+h/eTTaQdT0aT Ho757vVSqzBdnAeC4YrKrSbKBi/A67VurN8mLJIN+QXsnZeULumfCjg28b71xUaOgJ7y tae0URaGhuaavpSnq7RoSjTAVDZNQdSIg+iHJN07Br1oKyMHJazY7eFlBzL1I6j2W4sH YA== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Peter Xu , Paolo Bonzini , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fabiano Rosas , Leonardo Bras , Markus Armbruster , Anthony PERARD , Stefan Berger , Gerd Hoffmann , Stefano Stabellini , Paul Durrant , Eric Blake , Richard Henderson , Steve Sistare Subject: [PATCH V9 10/12] tests/qtest: option to suspend during migration Date: Wed, 3 Jan 2024 12:05:39 -0800 Message-Id: <1704312341-66640-11-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1704312341-66640-1-git-send-email-steven.sistare@oracle.com> References: <1704312341-66640-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-03_08,2024-01-03_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 suspectscore=0 mlxscore=0 adultscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401030162 X-Proofpoint-ORIG-GUID: GOspUNsx2GP5SV7qAGLm83OiF0_PLNkM X-Proofpoint-GUID: GOspUNsx2GP5SV7qAGLm83OiF0_PLNkM Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1704312445373100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add an option to suspend the src in a-b-bootblock.S, which puts the guest in S3 state after one round of writing to memory. The option is enabled by poking a 1 into the suspend_me word in the boot block prior to starting the src vm. Generate symbol offsets in a-b-bootblock.h so that the suspend_me offset is known. Generate the bootblock for each test, because suspend_me may differ for each. Signed-off-by: Steve Sistare Acked-by: Peter Xu Reviewed-by: Fabiano Rosas --- tests/migration/i386/Makefile | 5 ++-- tests/migration/i386/a-b-bootblock.S | 50 ++++++++++++++++++++++++++++++++= +--- tests/migration/i386/a-b-bootblock.h | 26 +++++++++++++------ tests/qtest/migration-test.c | 12 ++++++--- 4 files changed, 77 insertions(+), 16 deletions(-) diff --git a/tests/migration/i386/Makefile b/tests/migration/i386/Makefile index 5c03241..37a72ae 100644 --- a/tests/migration/i386/Makefile +++ b/tests/migration/i386/Makefile @@ -4,9 +4,10 @@ .PHONY: all clean all: a-b-bootblock.h =20 -a-b-bootblock.h: x86.bootsect +a-b-bootblock.h: x86.bootsect x86.o echo "$$__note" > header.tmp xxd -i $< | sed -e 's/.*int.*//' >> header.tmp + nm x86.o | awk '{print "#define SYM_"$$3" 0x"$$1}' >> header.tmp mv header.tmp $@ =20 x86.bootsect: x86.boot @@ -16,7 +17,7 @@ x86.boot: x86.o $(CROSS_PREFIX)objcopy -O binary $< $@ =20 x86.o: a-b-bootblock.S - $(CROSS_PREFIX)gcc -m32 -march=3Di486 -c $< -o $@ + $(CROSS_PREFIX)gcc -I.. -m32 -march=3Di486 -c $< -o $@ =20 clean: @rm -rf *.boot *.o *.bootsect diff --git a/tests/migration/i386/a-b-bootblock.S b/tests/migration/i386/a-= b-bootblock.S index 6bb9999..6f39eb6 100644 --- a/tests/migration/i386/a-b-bootblock.S +++ b/tests/migration/i386/a-b-bootblock.S @@ -9,6 +9,23 @@ # # Author: dgilbert@redhat.com =20 +#include "migration-test.h" + +#define ACPI_ENABLE 0xf1 +#define ACPI_PORT_SMI_CMD 0xb2 +#define ACPI_PM_BASE 0x600 +#define PM1A_CNT_OFFSET 4 + +#define ACPI_SCI_ENABLE 0x0001 +#define ACPI_SLEEP_TYPE 0x0400 +#define ACPI_SLEEP_ENABLE 0x2000 +#define SLEEP (ACPI_SCI_ENABLE + ACPI_SLEEP_TYPE + ACPI_SLEEP_ENABLE) + +#define LOW_ADDR X86_TEST_MEM_START +#define HIGH_ADDR X86_TEST_MEM_END + +/* Save the suspended status at an address that is not written in the loop= . */ +#define suspended (X86_TEST_MEM_START + 4) =20 .code16 .org 0x7c00 @@ -35,8 +52,8 @@ start: # at 0x7c00 ? mov %eax,%ds =20 # Start from 1MB -.set TEST_MEM_START, (1024*1024) -.set TEST_MEM_END, (100*1024*1024) +.set TEST_MEM_START, X86_TEST_MEM_START +.set TEST_MEM_END, X86_TEST_MEM_END =20 mov $65,%ax mov $0x3f8,%dx @@ -69,7 +86,30 @@ innerloop: mov $0x3f8,%dx outb %al,%dx =20 - jmp mainloop + # should this test suspend? + mov (suspend_me),%eax + cmp $0,%eax + je mainloop + + # are we waking after suspend? do not suspend again. + mov $suspended,%eax + mov (%eax),%eax + cmp $1,%eax + je mainloop + + # enable acpi + mov $ACPI_ENABLE,%al + outb %al,$ACPI_PORT_SMI_CMD + + # suspend to ram + mov $suspended,%eax + movl $1,(%eax) + mov $SLEEP,%ax + mov $(ACPI_PM_BASE + PM1A_CNT_OFFSET),%dx + outw %ax,%dx + # not reached. The wakeup causes reset and restart at 0x7c00, and= we + # do not save and restore registers as a real kernel would do. + =20 # GDT magic from old (GPLv2) Grub startup.S .p2align 2 /* force 4-byte alignment */ @@ -95,6 +135,10 @@ gdtdesc: .word 0x27 /* limit */ .long gdt /* addr */ =20 + /* test launcher can poke a 1 here to exercise suspend */ +suspend_me: + .int 0 + /* I'm a bootable disk */ .org 0x7dfe .byte 0x55 diff --git a/tests/migration/i386/a-b-bootblock.h b/tests/migration/i386/a-= b-bootblock.h index 5b52391..c83f871 100644 --- a/tests/migration/i386/a-b-bootblock.h +++ b/tests/migration/i386/a-b-bootblock.h @@ -4,7 +4,7 @@ * the header and the assembler differences in your patch submission. */ unsigned char x86_bootsect[] =3D { - 0xfa, 0x0f, 0x01, 0x16, 0x8c, 0x7c, 0x66, 0xb8, 0x01, 0x00, 0x00, 0x00, + 0xfa, 0x0f, 0x01, 0x16, 0xb8, 0x7c, 0x66, 0xb8, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x22, 0xc0, 0x66, 0xea, 0x20, 0x7c, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe4, 0x92, 0x0c, 0x02, 0xe6, 0x92, 0xb8, 0x10, 0x00, 0x00, 0x00, 0x8e, 0xd8, 0x66, 0xb8, 0x41, @@ -13,13 +13,13 @@ unsigned char x86_bootsect[] =3D { 0x40, 0x06, 0x7c, 0xf1, 0xb8, 0x00, 0x00, 0x10, 0x00, 0xfe, 0x00, 0x05, 0x00, 0x10, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x40, 0x06, 0x7c, 0xf2, 0xfe, 0xc3, 0x80, 0xe3, 0x3f, 0x75, 0xe6, 0x66, 0xb8, 0x42, 0x00, 0x66, 0xba, - 0xf8, 0x03, 0xee, 0xeb, 0xdb, 0x8d, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x9a, 0xcf, 0x00, - 0xff, 0xff, 0x00, 0x00, 0x00, 0x92, 0xcf, 0x00, 0x27, 0x00, 0x74, 0x7c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xf8, 0x03, 0xee, 0xa1, 0xbe, 0x7c, 0x00, 0x00, 0x83, 0xf8, 0x00, 0x74, + 0xd3, 0xb8, 0x04, 0x00, 0x10, 0x00, 0x8b, 0x00, 0x83, 0xf8, 0x01, 0x74, + 0xc7, 0xb0, 0xf1, 0xe6, 0xb2, 0xb8, 0x04, 0x00, 0x10, 0x00, 0xc7, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x66, 0xb8, 0x01, 0x24, 0x66, 0xba, 0x04, 0x06, + 0x66, 0xef, 0x66, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x9a, 0xcf, 0x00, 0xff, 0xff, 0x00, 0x00, + 0x00, 0x92, 0xcf, 0x00, 0x27, 0x00, 0xa0, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -49,3 +49,13 @@ unsigned char x86_bootsect[] =3D { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa }; =20 +#define SYM_do_zero 0x00007c3d +#define SYM_gdt 0x00007ca0 +#define SYM_gdtdesc 0x00007cb8 +#define SYM_innerloop 0x00007c51 +#define SYM_mainloop 0x00007c4c +#define SYM_pre_zero 0x00007c38 +#define SYM_start 0x00007c00 +#define SYM_suspend_me 0x00007cbe +#define SYM_TEST_MEM_END 0x06400000 +#define SYM_TEST_MEM_START 0x00100000 diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 41fc837..2e2ab6a 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -133,7 +133,7 @@ static char *bootpath; #include "tests/migration/aarch64/a-b-kernel.h" #include "tests/migration/s390x/a-b-bios.h" =20 -static void bootfile_create(char *dir) +static void bootfile_create(char *dir, bool suspend_me) { const char *arch =3D qtest_get_arch(); unsigned char *content; @@ -143,6 +143,7 @@ static void bootfile_create(char *dir) if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { /* the assembled x86 boot sector should be exactly one sector larg= e */ g_assert(sizeof(x86_bootsect) =3D=3D 512); + x86_bootsect[SYM_suspend_me - SYM_start] =3D suspend_me; content =3D x86_bootsect; len =3D sizeof(x86_bootsect); } else if (g_str_equal(arch, "s390x")) { @@ -646,6 +647,8 @@ typedef struct { bool use_dirty_ring; const char *opts_source; const char *opts_target; + /* suspend the src before migrating to dest. */ + bool suspend_me; } MigrateStart; =20 /* @@ -767,6 +770,8 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, =20 dst_state =3D (QTestMigrationState) { }; src_state =3D (QTestMigrationState) { }; + bootfile_create(tmpfs, args->suspend_me); + if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { memory_size =3D "150M"; =20 @@ -2980,7 +2985,9 @@ static int64_t get_limit_rate(QTestState *who) static QTestState *dirtylimit_start_vm(void) { QTestState *vm =3D NULL; - g_autofree gchar * + g_autofree gchar *cmd =3D NULL; + + bootfile_create(tmpfs, false); cmd =3D g_strdup_printf("-accel kvm,dirty-ring-size=3D4096 " "-name dirtylimit-test,debug-threads=3Don " "-m 150M -smp 1 " @@ -3329,7 +3336,6 @@ int main(int argc, char **argv) g_get_tmp_dir(), err->message); } g_assert(tmpfs); - bootfile_create(tmpfs); =20 module_call_init(MODULE_INIT_QOM); =20 --=20 1.8.3.1 From nobody Tue May 14 13:13:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1704312588; cv=none; d=zohomail.com; s=zohoarc; b=mw1bvy4HG6emNdVgmhWB2pOZD/6L+g9wUfXjaoXDY2inUliaXqybmznpu4/7Udog929TNQ5dfi1hABvoZZSu2BwUJ5BCfvbKsp6hcMByY4BTAgM4xPN0bvx2AvgtJedpnKU8pRfVcWZYpo/mhkHhi5xLG+L4Nx4itOd1AJaNysU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704312588; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WOx16+Qz+oIai3FaefU+mhmYaviyvUmdvn/+rSLkfkU=; b=JuOdHyq0xacbk3JpIYdhR7ctw9KdFkBf6d0KHsf8oAnf7BvR8cG/HxlpEvsh+/Nsr52wgdSvI+xFwecNODudhu+ob7Mb9oQAnLCyepyLaCGLiKRJ0OBC+w3bWfv90/WsWitrXLmhRt2MRJb4kMIKDI4QW0cwUsxVUKzQiowPoMk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704312588426635.4618555190139; Wed, 3 Jan 2024 12:09:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rL7YR-0002sx-90; Wed, 03 Jan 2024 15:09:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rL7YO-0002q9-Lf for qemu-devel@nongnu.org; Wed, 03 Jan 2024 15:09:29 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rL7YM-00030z-LH for qemu-devel@nongnu.org; Wed, 03 Jan 2024 15:09:28 -0500 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 403JXXkI006835; Wed, 3 Jan 2024 20:05:55 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3vabrv5s8f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Jan 2024 20:05:55 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 403K22g9013704; Wed, 3 Jan 2024 20:05:54 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3vddsvtbna-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Jan 2024 20:05:54 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 403K2UZx020511; Wed, 3 Jan 2024 20:05:54 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3vddsvtba4-12; Wed, 03 Jan 2024 20:05:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=WOx16+Qz+oIai3FaefU+mhmYaviyvUmdvn/+rSLkfkU=; b=WNpZHN8IYv4+ikM76mfUkzE9ClUQ8o2OPr1k+1b9oh6Qc+BzOZUKHVf3bmugL6/rX6zS PRFwp5luBehnF/2vlYj7kj743LUFttXlLIf3R7kEOSie5qnZ+rHWnjwie6q3NYXg6vU2 gWvZrth4CKEY8vRxy1LQQXkM8HmyBMduaKCK8d2VdF/sU0WPNEIKzkXofiBfTJW/mu1N 8EOny4KGIdhwORkdYGrZ/eMWkDEw6vIv1mzAXtlCJM0RsHSTemmw4MFoYwzFi76Bd+S6 SN0CRhMsVElz5EEiX3FjvIPDgCPubFKMg0gMvZZBaw1WFwDZBxU0Jel1u38EhFB1DTWj MA== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Peter Xu , Paolo Bonzini , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fabiano Rosas , Leonardo Bras , Markus Armbruster , Anthony PERARD , Stefan Berger , Gerd Hoffmann , Stefano Stabellini , Paul Durrant , Eric Blake , Richard Henderson , Steve Sistare Subject: [PATCH V9 11/12] tests/qtest: precopy migration with suspend Date: Wed, 3 Jan 2024 12:05:40 -0800 Message-Id: <1704312341-66640-12-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1704312341-66640-1-git-send-email-steven.sistare@oracle.com> References: <1704312341-66640-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-03_08,2024-01-03_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 suspectscore=0 mlxscore=0 adultscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401030162 X-Proofpoint-ORIG-GUID: Y-6Pr8GkJaXmMlnF4m9x9UgLH130Lh9j X-Proofpoint-GUID: Y-6Pr8GkJaXmMlnF4m9x9UgLH130Lh9j Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.220.165.32; envelope-from=steven.sistare@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1704312589765100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a test case to verify that the suspended state is handled correctly during live migration precopy. The test suspends the src, migrates, then wakes the dest. Signed-off-by: Steve Sistare Reviewed-by: Fabiano Rosas Reviewed-by: Peter Xu --- tests/qtest/migration-helpers.c | 3 ++ tests/qtest/migration-helpers.h | 2 ++ tests/qtest/migration-test.c | 62 +++++++++++++++++++++++++++++++++++++= ++-- 3 files changed, 64 insertions(+), 3 deletions(-) diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helper= s.c index fd3b94e..37e8e81 100644 --- a/tests/qtest/migration-helpers.c +++ b/tests/qtest/migration-helpers.c @@ -32,6 +32,9 @@ bool migrate_watch_for_events(QTestState *who, const char= *name, if (g_str_equal(name, "STOP")) { state->stop_seen =3D true; return true; + } else if (g_str_equal(name, "SUSPEND")) { + state->suspend_seen =3D true; + return true; } else if (g_str_equal(name, "RESUME")) { state->resume_seen =3D true; return true; diff --git a/tests/qtest/migration-helpers.h b/tests/qtest/migration-helper= s.h index 3d32699..b478549 100644 --- a/tests/qtest/migration-helpers.h +++ b/tests/qtest/migration-helpers.h @@ -18,6 +18,8 @@ typedef struct QTestMigrationState { bool stop_seen; bool resume_seen; + bool suspend_seen; + bool suspend_me; } QTestMigrationState; =20 bool migrate_watch_for_events(QTestState *who, const char *name, diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 2e2ab6a..a3bfbf2 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -178,7 +178,7 @@ static void bootfile_delete(void) /* * Wait for some output in the serial output file, * we get an 'A' followed by an endless string of 'B's - * but on the destination we won't have the A. + * but on the destination we won't have the A (unless we enabled suspend/r= esume) */ static void wait_for_serial(const char *side) { @@ -245,6 +245,13 @@ static void wait_for_resume(QTestState *who, QTestMigr= ationState *state) } } =20 +static void wait_for_suspend(QTestState *who, QTestMigrationState *state) +{ + if (state->suspend_me && !state->suspend_seen) { + qtest_qmp_eventwait(who, "SUSPEND"); + } +} + /* * It's tricky to use qemu's migration event capability with qtest, * events suddenly appearing confuse the qmp()/hmp() responses. @@ -299,7 +306,7 @@ static void wait_for_migration_pass(QTestState *who) { uint64_t pass, prev_pass =3D 0, changes =3D 0; =20 - while (changes < 2 && !src_state.stop_seen) { + while (changes < 2 && !src_state.stop_seen && !src_state.suspend_seen)= { usleep(1000); pass =3D get_migration_pass(who); changes +=3D (pass !=3D prev_pass); @@ -584,6 +591,12 @@ static void migrate_wait_for_dirty_mem(QTestState *fro= m, usleep(1000 * 10); } while (qtest_readq(to, marker_address) !=3D MAGIC_MARKER); =20 + + /* If suspended, src only iterates once, and watch_byte may never chan= ge */ + if (src_state.suspend_me) { + return; + } + /* * Now ensure that already transferred bytes are * dirty again from the guest workload. Note the @@ -771,6 +784,7 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, dst_state =3D (QTestMigrationState) { }; src_state =3D (QTestMigrationState) { }; bootfile_create(tmpfs, args->suspend_me); + src_state.suspend_me =3D args->suspend_me; =20 if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { memory_size =3D "150M"; @@ -1717,6 +1731,7 @@ static void test_precopy_common(MigrateCommon *args) /* Wait for the first serial output from the source */ if (args->result =3D=3D MIG_TEST_SUCCEED) { wait_for_serial("src_serial"); + wait_for_suspend(from, &src_state); } =20 if (args->live) { @@ -1793,6 +1808,11 @@ static void test_precopy_common(MigrateCommon *args) =20 wait_for_resume(to, &dst_state); =20 + if (args->start.suspend_me) { + /* wakeup succeeds only if guest is suspended */ + qtest_qmp_assert_success(to, "{'execute': 'system_wakeup'}"); + } + wait_for_serial("dest_serial"); } =20 @@ -1879,6 +1899,34 @@ static void test_precopy_unix_plain(void) test_precopy_common(&args); } =20 +static void test_precopy_unix_suspend_live(void) +{ + g_autofree char *uri =3D g_strdup_printf("unix:%s/migsocket", tmpfs); + MigrateCommon args =3D { + .listen_uri =3D uri, + .connect_uri =3D uri, + /* + * despite being live, the test is fast because the src + * suspends immediately. + */ + .live =3D true, + .start.suspend_me =3D true, + }; + + test_precopy_common(&args); +} + +static void test_precopy_unix_suspend_notlive(void) +{ + g_autofree char *uri =3D g_strdup_printf("unix:%s/migsocket", tmpfs); + MigrateCommon args =3D { + .listen_uri =3D uri, + .connect_uri =3D uri, + .start.suspend_me =3D true, + }; + + test_precopy_common(&args); +} =20 static void test_precopy_unix_dirty_ring(void) { @@ -3279,7 +3327,7 @@ static bool kvm_dirty_ring_supported(void) int main(int argc, char **argv) { bool has_kvm, has_tcg; - bool has_uffd; + bool has_uffd, is_x86; const char *arch; g_autoptr(GError) err =3D NULL; const char *qemu_src =3D getenv(QEMU_ENV_SRC); @@ -3309,6 +3357,7 @@ int main(int argc, char **argv) =20 has_uffd =3D ufd_version_check(); arch =3D qtest_get_arch(); + is_x86 =3D !strcmp(arch, "i386") || !strcmp(arch, "x86_64"); =20 /* * On ppc64, the test only works with kvm-hv, but not with kvm-pr and = TCG @@ -3339,6 +3388,13 @@ int main(int argc, char **argv) =20 module_call_init(MODULE_INIT_QOM); =20 + if (is_x86) { + qtest_add_func("/migration/precopy/unix/suspend/live", + test_precopy_unix_suspend_live); + qtest_add_func("/migration/precopy/unix/suspend/notlive", + test_precopy_unix_suspend_notlive); + } + if (has_uffd) { qtest_add_func("/migration/postcopy/plain", test_postcopy); qtest_add_func("/migration/postcopy/recovery/plain", --=20 1.8.3.1 From nobody Tue May 14 13:13:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1704312383; cv=none; d=zohomail.com; s=zohoarc; b=PkbTKNFj7TkGSlfLlAHHQTzAceSNEz7LKiUtmTuCOBAwcO7tXWzjaRPR/nWnojWmTLQXTldCefpdSq3Ov28sRK287UU0zL6s4PxFAZmj7HwZAvl7NGAhj3ftLpTcK+u4rEOSa818NPCzv0KmZcU7gTQceidjrEMtAgcnlMO1S8c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704312383; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZQ2ycey7tFSeCUAvislcm5k2GE6FWRBnHRx9NBcQNWs=; b=b/lxHVUmVr2h/1uh9f13l+TZPwm/MJZnaUHmLEYDxzUmo8k2lHKD9XUDG1kFEMW1w7mKYJvWnXF38+uAhpfmum427uQbGRceKHbX1KLb3J/MQbQVxu38YOYpj/yZ/pyAuGgRO9ZLDpVYq4Q+O5Ela0TFBGX3sJNHfvdx9iZ4QME= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704312383453364.35073124784026; Wed, 3 Jan 2024 12:06:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rL7VF-0004jk-I5; Wed, 03 Jan 2024 15:06:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rL7V6-0004gd-6u for qemu-devel@nongnu.org; Wed, 03 Jan 2024 15:06:05 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rL7V4-0002CR-JJ for qemu-devel@nongnu.org; Wed, 03 Jan 2024 15:06:03 -0500 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 403JYW2p028565; Wed, 3 Jan 2024 20:05:57 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3vaatu5qte-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Jan 2024 20:05:56 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 403K22Vc013668; Wed, 3 Jan 2024 20:05:55 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3vddsvtbp5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Jan 2024 20:05:55 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 403K2Ua1020511; Wed, 3 Jan 2024 20:05:55 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3vddsvtba4-13; Wed, 03 Jan 2024 20:05:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=ZQ2ycey7tFSeCUAvislcm5k2GE6FWRBnHRx9NBcQNWs=; b=WrAWpvQER1TAXWwqLSM3TDSMegbUbXLhWfIFhPBZrUZ9bFb34Yu+QTiZ5ArWvOIp9jWf fTHVJUmH91OTDGL13GawoXdgcR8x42QHLA5siojMWgUOqkjCZFt2d6lGJ0ghgZp/AXm3 946c+krST/FhHsabALFSfrtFf+cYjHZepL2vp3MmELEoPE0qG3vRD0aW+x98Ix7KFJkN HEKQeASmDirjC6HxoNi9zM1R30Vt5cbDUW1x9t1AqY+8lpvM3j9oEXRMcSwtWP1WbQ// 6F2Vc7Vg1gghoLjGVpbu44tM+KY86oRMch9HDUOtIa4W5jkZpZhXABxjH0ZuG927F+fg 4g== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Peter Xu , Paolo Bonzini , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Fabiano Rosas , Leonardo Bras , Markus Armbruster , Anthony PERARD , Stefan Berger , Gerd Hoffmann , Stefano Stabellini , Paul Durrant , Eric Blake , Richard Henderson , Steve Sistare Subject: [PATCH V9 12/12] tests/qtest: postcopy migration with suspend Date: Wed, 3 Jan 2024 12:05:41 -0800 Message-Id: <1704312341-66640-13-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1704312341-66640-1-git-send-email-steven.sistare@oracle.com> References: <1704312341-66640-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-03_08,2024-01-03_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 suspectscore=0 mlxscore=0 adultscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401030162 X-Proofpoint-GUID: XtLY27RWd7btVOXpSmQt0bk-DnvUn08i X-Proofpoint-ORIG-GUID: XtLY27RWd7btVOXpSmQt0bk-DnvUn08i Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1704312385079100009 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a test case to verify that the suspended state is handled correctly by live migration postcopy. The test suspends the src, migrates, then wakes the dest. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu --- tests/qtest/migration-test.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index a3bfbf2..136e5df 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -1347,6 +1347,7 @@ static int migrate_postcopy_prepare(QTestState **from= _ptr, =20 /* Wait for the first serial output from the source */ wait_for_serial("src_serial"); + wait_for_suspend(from, &src_state); =20 g_autofree char *uri =3D migrate_get_socket_address(to, "socket-addres= s"); migrate_qmp(from, uri, "{}"); @@ -1364,6 +1365,11 @@ static void migrate_postcopy_complete(QTestState *fr= om, QTestState *to, { wait_for_migration_complete(from); =20 + if (args->start.suspend_me) { + /* wakeup succeeds only if guest is suspended */ + qtest_qmp_assert_success(to, "{'execute': 'system_wakeup'}"); + } + /* Make sure we get at least one "B" on destination */ wait_for_serial("dest_serial"); =20 @@ -1397,6 +1403,15 @@ static void test_postcopy(void) test_postcopy_common(&args); } =20 +static void test_postcopy_suspend(void) +{ + MigrateCommon args =3D { + .start.suspend_me =3D true, + }; + + test_postcopy_common(&args); +} + static void test_postcopy_compress(void) { MigrateCommon args =3D { @@ -3412,7 +3427,10 @@ int main(int argc, char **argv) qtest_add_func("/migration/postcopy/recovery/double-failures", test_postcopy_recovery_double_fail); #endif /* _WIN32 */ - + if (is_x86) { + qtest_add_func("/migration/postcopy/suspend", + test_postcopy_suspend); + } } =20 qtest_add_func("/migration/bad_dest", test_baddest); --=20 1.8.3.1