From nobody Tue May 14 03:54:48 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=1693350485; cv=none; d=zohomail.com; s=zohoarc; b=cIqR6ioNBa7h+n9ZAb6J8E6beljVW0QIDtjqHW8lL2mIqyT2+XbXfJ9MJDWZH2gXi0A4FIDhvKtk6hdMW2lBGhehFlz0fAAaGYyo2+7dUHMgmMz4Ta4IisrW6VELIkC4Kpe7T1x3YBY5BrTxH/Rtt4ZTpgZP+I/ip0myo0azLdk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693350485; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=QldYdQCuSfWnLDpGzc4j13m7wbuFMYdlmEh5gluOY8g=; b=Us4NqoMGomCO7ArlDXW5G2kPdC2ctCsFq8nA9HGnGmzqtvXYDfzep4Ln/GgBsVUp2nqVMGa821jswNYp7YkpyTjyIZYtr5eVYeGe8D/xhXq4D3Y6BLGVdIyy2qHlwHl0fkzzXGzD4j0IKh5ONuXV1/szNUNTUMhuKOg9TL2i46Q= 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 1693350485057755.3843788324059; Tue, 29 Aug 2023 16:08:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qb7mz-0000o2-Ou; Tue, 29 Aug 2023 19:06:25 -0400 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 1qb3IA-0002bH-PW for qemu-devel@nongnu.org; Tue, 29 Aug 2023 14:18:18 -0400 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 1qb3I5-0003UR-Fk for qemu-devel@nongnu.org; Tue, 29 Aug 2023 14:18:18 -0400 Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37THioqa025992; Tue, 29 Aug 2023 18:18:09 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 3sq9j4dqyt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Aug 2023 18:18:08 +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 37THB2cl024804; Tue, 29 Aug 2023 18:18:08 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3sr6dnfwhr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Aug 2023 18:18:08 +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 37TII6lq011911; Tue, 29 Aug 2023 18:18:07 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 3sr6dnfwgx-2; Tue, 29 Aug 2023 18:18:07 +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-03-30; bh=QldYdQCuSfWnLDpGzc4j13m7wbuFMYdlmEh5gluOY8g=; b=Lqu6nnvRGS76uqrdKdLDL0+O3WGUIXE9XlWs7JF9JR/BHctHjLmZN7tgiSLo6ZwXLedc lYwArwblHhXrlUEM2fk1s/MFX4vfNrrvAuMDo317eTWRAnR1HV+IrlD89hd5mEr+xoYM 0XPdiv+ajzh82k6X15ruKh72b8lyiW2CYWEl+h5HxXsPjoUpJ0hXPzXMwqgVOTvVz+yO WBBonkSrTWHMF8YbI/uyLazrjJkxZhwtPY+2J0gKKOmnTkN2xghkSRpm6a6Kg3RJw8r9 7U/djNGtfh3M7h/lhToGSimv99ry3SOMLX+TE0yizOt2aRVj/HJAMUrfT87rwC+MKgma hw== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Juan Quintela , Peter Xu , Paolo Bonzini , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Steve Sistare Subject: [PATCH V4 01/11] cpus: pass runstate to vm_prepare_start Date: Tue, 29 Aug 2023 11:17:56 -0700 Message-Id: <1693333086-392798-2-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1693333086-392798-1-git-send-email-steven.sistare@oracle.com> References: <1693333086-392798-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-29_13,2023-08-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2308290158 X-Proofpoint-GUID: xAgmnt-6HXzXim7SOre9Z-I_LiY3wq-w X-Proofpoint-ORIG-GUID: xAgmnt-6HXzXim7SOre9Z-I_LiY3wq-w 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: 1693350486823100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When a vm in the suspended state is migrated, we must call vm_prepare_start on the destination, so a later system_wakeup properly resumes the guest, when main_loop_should_exit callsresume_all_vcpus. However, the runstate should remain suspended until system_wakeup is called, so allow the caller to pass the new state to vm_prepare_start, rather than assume the new state is RUN_STATE_RUNNING. Modify vm state change handlers that check RUN_STATE_RUNNING to instead use the running parameter. No functional change. Suggested-by: Peter Xu Signed-off-by: Steve Sistare Reviewed-by: Peter Xu --- backends/tpm/tpm_emulator.c | 2 +- gdbstub/softmmu.c | 2 +- hw/usb/hcd-ehci.c | 2 +- hw/usb/redirect.c | 2 +- hw/xen/xen-hvm-common.c | 2 +- include/sysemu/runstate.h | 3 ++- softmmu/cpus.c | 8 ++++---- 7 files changed, 11 insertions(+), 10 deletions(-) diff --git a/backends/tpm/tpm_emulator.c b/backends/tpm/tpm_emulator.c index 402a2d6..a8e559a 100644 --- a/backends/tpm/tpm_emulator.c +++ b/backends/tpm/tpm_emulator.c @@ -907,7 +907,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/gdbstub/softmmu.c b/gdbstub/softmmu.c index f509b72..a43e832 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -565,7 +565,7 @@ int gdb_continue_partial(char *newstates) } } =20 - if (vm_prepare_start(step_requested)) { + if (vm_prepare_start(step_requested, RUN_STATE_RUNNING)) { return 0; } =20 diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index c930c60..e436f5c 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 39fbaaa..1ec5909 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) diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h index 7beb29c..7d889ab 100644 --- a/include/sysemu/runstate.h +++ b/include/sysemu/runstate.h @@ -39,8 +39,9 @@ void vm_start(void); * vm_prepare_start: Prepare for starting/resuming the VM * * @step_pending: whether any of the CPUs is about to be single-stepped by= gdb + * @state: the vm state to setup */ -int vm_prepare_start(bool step_pending); +int vm_prepare_start(bool step_pending, RunState state); int vm_stop(RunState state); int vm_stop_force_state(RunState state); int vm_shutdown(void); diff --git a/softmmu/cpus.c b/softmmu/cpus.c index fed20ff..0a082d3 100644 --- a/softmmu/cpus.c +++ b/softmmu/cpus.c @@ -681,7 +681,7 @@ int vm_stop(RunState state) * 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. */ -int vm_prepare_start(bool step_pending) +int vm_prepare_start(bool step_pending, RunState state) { RunState requested; =20 @@ -713,14 +713,14 @@ 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); + runstate_set(state); + vm_state_notify(1, state); return 0; } =20 void vm_start(void) { - if (!vm_prepare_start(false)) { + if (!vm_prepare_start(false, RUN_STATE_RUNNING)) { resume_all_vcpus(); } } --=20 1.8.3.1 From nobody Tue May 14 03:54:48 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=1693350849; cv=none; d=zohomail.com; s=zohoarc; b=KuH4yJCF47gWYGyL0eJ4s5Ld1GCHvhR1P9ekAzIOxjaFIW3URGitT+hCRuwZ+rpJ8soQFm8WSH/gHfCEDWMvTmzgxPNfvfQRgL9gpqfyY5XEC6TEjvrF97RjJDmEsG99BEjHRaxSWYyjAu4UjZefUt6JVML9TqQBUHlY9hqAQDk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693350849; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=b8svEifVQlkpZwsts2HrwmL6UewsjMUsdbmn7xtesCc=; b=MSKVE+zZBK7UI4xlpVXKCMrsGdLjQ0iRoFXLvU9j+DvrnIUByA7aj7058XgGxH/4rYg9yiFd05JrRWDG53qijw3dGUovAMKGByzQWuMIn++k9BmWocR/XvhwJXMJ+3y4sMFrs5ZOkpvgvNauU21Lm9S6OE85LyAHRRNGS9L6vQU= 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 1693350849519907.006525055293; Tue, 29 Aug 2023 16:14:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qb7ms-0000hL-BW; Tue, 29 Aug 2023 19:06:18 -0400 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 1qb3I8-0002ab-Ez for qemu-devel@nongnu.org; Tue, 29 Aug 2023 14:18:17 -0400 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 1qb3I5-0003UX-Fz for qemu-devel@nongnu.org; Tue, 29 Aug 2023 14:18:16 -0400 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 37THii1e023429; Tue, 29 Aug 2023 18:18:09 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 3sq9gdwmqe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Aug 2023 18:18:09 +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 37THEWLP024792; Tue, 29 Aug 2023 18:18:08 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3sr6dnfwja-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Aug 2023 18:18:08 +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 37TII6ls011911; Tue, 29 Aug 2023 18:18:08 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 3sr6dnfwgx-3; Tue, 29 Aug 2023 18:18:08 +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-03-30; bh=b8svEifVQlkpZwsts2HrwmL6UewsjMUsdbmn7xtesCc=; b=ZBRw5Ovx/WT/Iyih+LxOrZUh9KuxxJ5WotBtLaA8FMjzlRtkNbmufwRmMmBlttEGyMek OCuUM2A7ymTJxzepf7Dbm/bnuXLPg/K/xLfjg4Yh4AWNUetLA1PML04ePPYNgNGAh7+o lkaHFUqER2A01bdwqw6ziRGSNr/mBjODunDgX+czFqe42iYuFz/3yvq/KLlL1R7EROJQ AXFqvIEccLnHBq1V/j0loUqAMOaL7tWGhgcgJyoHDjQCb9QR6bvwTRsQIIQsB0j0SZdy OXB5bv+gkxbtBJENAax+qUdObYsjrPG+0pHK3CDshxzQyneUlSOt62oleufHyyrjQos8 Sg== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Juan Quintela , Peter Xu , Paolo Bonzini , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Steve Sistare Subject: [PATCH V4 02/11] migration: preserve suspended runstate Date: Tue, 29 Aug 2023 11:17:57 -0700 Message-Id: <1693333086-392798-3-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1693333086-392798-1-git-send-email-steven.sistare@oracle.com> References: <1693333086-392798-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-29_13,2023-08-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2308290158 X-Proofpoint-ORIG-GUID: fKidjNp4-QSw-wLcUDEz5e5oDD8fI56D X-Proofpoint-GUID: fKidjNp4-QSw-wLcUDEz5e5oDD8fI56D 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: 1693350851581100019 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, do not call qemu_system_wakeup_request(). On the incoming side for precopy, prepare to start the vm, but do not yet start it. A future system_wakeup will cause the main loop to resume the VCPUs. On the incoming side for postcopy, do not wake the guest, and apply the the same logic as found in precopy: if autostart and the runstate is RUNNING, then vm_start, else prepare to start the vm. Signed-off-by: Steve Sistare Reviewed-by: Fabiano Rosas Reviewed-by: Peter Xu --- migration/migration.c | 4 ++-- migration/savevm.c | 15 ++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 5528acb..5bcc761 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -496,6 +496,8 @@ static void process_incoming_migration_bh(void *opaque) } else if (migration_incoming_colo_enabled()) { migration_incoming_disable_colo(); vm_start(); + } else if (global_state_get_runstate() =3D=3D RUN_STATE_SUSPENDED) { + vm_prepare_start(false, global_state_get_runstate()); } else { runstate_set(global_state_get_runstate()); } @@ -2109,7 +2111,6 @@ static int postcopy_start(MigrationState *ms, Error *= *errp) qemu_mutex_lock_iothread(); trace_postcopy_start_set_run(); =20 - qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL); global_state_store(); ret =3D vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); if (ret < 0) { @@ -2315,7 +2316,6 @@ static void migration_completion(MigrationState *s) if (s->state =3D=3D MIGRATION_STATUS_ACTIVE) { qemu_mutex_lock_iothread(); s->downtime_start =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); - qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL); =20 s->vm_old_state =3D runstate_get(); global_state_store(); diff --git a/migration/savevm.c b/migration/savevm.c index a2cb885..bae0a1a 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2070,12 +2070,17 @@ static void loadvm_postcopy_handle_run_bh(void *opa= que) =20 dirty_bitmap_mig_before_vm_start(); =20 - if (autostart) { - /* Hold onto your hats, starting the CPU */ - vm_start(); + if (!global_state_received() || + global_state_get_runstate() =3D=3D RUN_STATE_RUNNING) { + if (autostart) { + vm_start(); + } else { + runstate_set(RUN_STATE_PAUSED); + } + } else if (global_state_get_runstate() =3D=3D RUN_STATE_SUSPENDED) { + vm_prepare_start(false, RUN_STATE_SUSPENDED); } else { - /* leave it paused and let management decide when to start the CPU= */ - runstate_set(RUN_STATE_PAUSED); + runstate_set(global_state_get_runstate()); } =20 qemu_bh_delete(mis->bh); --=20 1.8.3.1 From nobody Tue May 14 03:54:48 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=1693350887; cv=none; d=zohomail.com; s=zohoarc; b=KP9CIztbYRVYDMha/iPfXZwpGUESfnEBuj7x2B1BDsmegfcT6DsLRIxP02j73oGDe2E+kzMKZbf+sYdPeTCwsxVJ9Ver7/Zi1tvkL4Yxia/qYd9yfdVe8Dsk5mOFEPRLeuZIf9LBU1hG1pNl6/wdEmAUfG9N8HHbJVGAyaVBTv0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693350887; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=P9YuFI3pEGxSQ80k/zVw2ifGJXLSaaHRqk8odCfdN2I=; b=LPO7KiNbWhqlb3ijlZJbRnPSVoiIpaYMpMa27NICySXdfCEq/2gomF4hgInzzJTZ8Ejhh53AJe5w/b1ukGT5w9uCOUzB3qsxdHGuKzesOcj3WIAsLEneBYeE4SOKKnYeuIeRhqtEjfUy2X77CfVGwi30MTev8ezm19fURygbc6k= 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 1693350887391189.22172880318806; Tue, 29 Aug 2023 16:14:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qb7my-0000lW-2i; Tue, 29 Aug 2023 19:06:24 -0400 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 1qb3IA-0002aq-CY for qemu-devel@nongnu.org; Tue, 29 Aug 2023 14:18:18 -0400 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 1qb3I5-0003Ux-Fj for qemu-devel@nongnu.org; Tue, 29 Aug 2023 14:18:18 -0400 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 37THnL1d021261; Tue, 29 Aug 2023 18:18:10 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 3sq9nywk2u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Aug 2023 18:18:10 +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 37THDvpC024829; Tue, 29 Aug 2023 18:18:09 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3sr6dnfwjw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Aug 2023 18:18:09 +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 37TII6lu011911; Tue, 29 Aug 2023 18:18:08 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 3sr6dnfwgx-4; Tue, 29 Aug 2023 18:18:08 +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-03-30; bh=P9YuFI3pEGxSQ80k/zVw2ifGJXLSaaHRqk8odCfdN2I=; b=rJB6CeiRDF8ELSWjix4oYwXaorcqhFBrHK9S4Nld2ZYIt2oEn5D9VirJy4SzWXkjX541 kvef5hFBITBcJ8Wrau1cu8Az0ao1YZhxSDlQi+uWmGow9VC3oqRYpMabpO5iEHGhGWmc llj+25stEx/tz5pxp0MNS3CcnPK/bGSSe457PbAbxUjCp2806ERChiQe6lrXiUyFoo0x jPI5lcF3Eoji+xM0sHcjqir/SVanjXWhBEFTnnjTDNV2SX6XoAlAMdjNZsnz7N2cG9pY XiLb9kDb2t1VYOkQoMCqrHfG86h6+XhQKlazPv3P0C75xEYlyk+qWzCbceBDwfuXINNY 5Q== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Juan Quintela , Peter Xu , Paolo Bonzini , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Steve Sistare Subject: [PATCH V4 03/11] migration: add runstate function Date: Tue, 29 Aug 2023 11:17:58 -0700 Message-Id: <1693333086-392798-4-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1693333086-392798-1-git-send-email-steven.sistare@oracle.com> References: <1693333086-392798-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-29_13,2023-08-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 adultscore=0 suspectscore=0 mlxlogscore=849 bulkscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2308290158 X-Proofpoint-ORIG-GUID: 8-Mu_NXmhG9o2K-ObEeEU7kr16ZygBtv X-Proofpoint-GUID: 8-Mu_NXmhG9o2K-ObEeEU7kr16ZygBtv 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: 1693350887788100002 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Create a subroutine for preserving the runstate after migration, to be used in a subsequent patch. No functional change. Signed-off-by: Steve Sistare Reviewed-by: Fabiano Rosas Reviewed-by: Peter Xu --- migration/migration.c | 37 ++++++++++++++++++++++--------------- migration/migration.h | 1 + migration/savevm.c | 13 +------------ 3 files changed, 24 insertions(+), 27 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 5bcc761..a9ecb66 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -486,21 +486,8 @@ static void process_incoming_migration_bh(void *opaque) =20 dirty_bitmap_mig_before_vm_start(); =20 - if (!global_state_received() || - global_state_get_runstate() =3D=3D RUN_STATE_RUNNING) { - if (autostart) { - vm_start(); - } else { - runstate_set(RUN_STATE_PAUSED); - } - } else if (migration_incoming_colo_enabled()) { - migration_incoming_disable_colo(); - vm_start(); - } else if (global_state_get_runstate() =3D=3D RUN_STATE_SUSPENDED) { - vm_prepare_start(false, global_state_get_runstate()); - } else { - runstate_set(global_state_get_runstate()); - } + migrate_set_runstate(); + /* * This must happen after any state changes since as soon as an extern= al * observer sees this event they might start to prod at the VM assuming @@ -1143,6 +1130,26 @@ void migrate_set_state(int *state, int old_state, in= t new_state) } } =20 +void migrate_set_runstate(void) +{ + RunState state =3D global_state_get_runstate(); + + if (!global_state_received() || state =3D=3D RUN_STATE_RUNNING) { + if (autostart) { + vm_start(); + } else { + runstate_set(RUN_STATE_PAUSED); + } + } else if (migration_incoming_colo_enabled()) { + migration_incoming_disable_colo(); + vm_start(); + } else if (state =3D=3D RUN_STATE_SUSPENDED) { + vm_prepare_start(false, state); + } else { + runstate_set(state); + } +} + static void migrate_fd_cleanup(MigrationState *s) { qemu_bh_delete(s->cleanup_bh); diff --git a/migration/migration.h b/migration/migration.h index 6eea18d..45e9805 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -456,6 +456,7 @@ struct MigrationState { }; =20 void migrate_set_state(int *state, int old_state, int new_state); +void migrate_set_runstate(void); =20 void migration_fd_process_incoming(QEMUFile *f, Error **errp); void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp); diff --git a/migration/savevm.c b/migration/savevm.c index bae0a1a..eba3653 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2070,18 +2070,7 @@ static void loadvm_postcopy_handle_run_bh(void *opaq= ue) =20 dirty_bitmap_mig_before_vm_start(); =20 - if (!global_state_received() || - global_state_get_runstate() =3D=3D RUN_STATE_RUNNING) { - if (autostart) { - vm_start(); - } else { - runstate_set(RUN_STATE_PAUSED); - } - } else if (global_state_get_runstate() =3D=3D RUN_STATE_SUSPENDED) { - vm_prepare_start(false, RUN_STATE_SUSPENDED); - } else { - runstate_set(global_state_get_runstate()); - } + migrate_set_runstate(); =20 qemu_bh_delete(mis->bh); =20 --=20 1.8.3.1 From nobody Tue May 14 03:54:48 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=1693351407; cv=none; d=zohomail.com; s=zohoarc; b=J6OkxnpKGjvqEqmwOh3VHs83dq6lbjWAtqfuxEliJVR+SbdATD0n2pouks8u3E6ZFh5pxP1CMq53h7eTwvyKz2fvai8k6/OOtdEdgrvBGflpwOmZewfc6B99KWWMYO3wzqq/zTUcn1IRK0cNv/fqrKnV0kF8r6G/W+sEpa0X1Ms= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693351407; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=cYmW8P29zhyl4EK49rtGEAnDbafZtqFSOlAcIELaads=; b=BQjBtP13UL2sP19d40uiujnjYr7C/SpCAYtoj/sywt1TYFSsTCar9dUu6K3enMhR2jjzVAsOxVgM5SGXRIXJj0pazm9RkAQ7HVAQrOOPtOItKOuSKwcLZABuoWM42sKGqmdtw8I5js0Xu8TcKHQaU3J5byQ3sBOa8MP7+D6VNrM= 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 1693351407266173.4908467660955; Tue, 29 Aug 2023 16:23:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qb7mx-0000kX-Ca; Tue, 29 Aug 2023 19:06:23 -0400 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 1qb3IA-0002b5-KM for qemu-devel@nongnu.org; Tue, 29 Aug 2023 14:18:18 -0400 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 1qb3I5-0003Vc-Fz for qemu-devel@nongnu.org; Tue, 29 Aug 2023 14:18:18 -0400 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 37THikeU025725; Tue, 29 Aug 2023 18:18:10 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 3sq9xt5qjj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Aug 2023 18:18:10 +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 37TH6Sln024740; Tue, 29 Aug 2023 18:18:09 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3sr6dnfwkc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Aug 2023 18:18:09 +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 37TII6lw011911; Tue, 29 Aug 2023 18:18:09 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 3sr6dnfwgx-5; Tue, 29 Aug 2023 18:18:09 +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-03-30; bh=cYmW8P29zhyl4EK49rtGEAnDbafZtqFSOlAcIELaads=; b=OmsEJ3BZg4/iHTkIoXJWLnCVx2jqr1r9oVdO8gXSLrFIk0J95b7hX422HCNKcFOPJjrk mjQTmShj/jm+i4aMyiw82Lx+g0lNAeizd9d5ufjMG0lZtmgIrHja6lEHorWVgeORUBz/ 68ekfZSm/dYkNpPdiyx6PiVdowj2ClqAZjJu+WKTT67KPafy0Eiq75/cLrNDyXNlE2x3 sdpWtaQMTvaCJdhx7nevwLYHbwY3sxKtDU9lEfSjmrioVs4YBWgoHrO5xkXhGI2+vsNB yGja0e605odi6+aVQsCSX4VfwXUMdi+d9GZA7JQk0Yu2vowop07Mdd1jT40ryxFHtsnK QQ== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Juan Quintela , Peter Xu , Paolo Bonzini , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Steve Sistare Subject: [PATCH V4 04/11] migration: preserve suspended for snapshot Date: Tue, 29 Aug 2023 11:17:59 -0700 Message-Id: <1693333086-392798-5-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1693333086-392798-1-git-send-email-steven.sistare@oracle.com> References: <1693333086-392798-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-29_13,2023-08-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2308290158 X-Proofpoint-ORIG-GUID: WV0LUJZp-nh_e_x0qjz7-FzAUZsM44t3 X-Proofpoint-GUID: WV0LUJZp-nh_e_x0qjz7-FzAUZsM44t3 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: 1693351407968100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Restoring a snapshot can break a suspended guest. If a guest is suspended and saved to a snapshot using savevm, and qemu is terminated and restarted with the -S option, then loadvm does not restore the guest. The runstate is running, but the guest is not, because vm_start was not called. The root cause is that loadvm does not restore the runstate (eg suspended) from global_state loaded from the state file. Restore the runstate, and allow the new state transitions that are possible. Signed-off-by: Steve Sistare --- migration/savevm.c | 1 + softmmu/runstate.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/migration/savevm.c b/migration/savevm.c index eba3653..7b9c477 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -3194,6 +3194,7 @@ bool load_snapshot(const char *name, const char *vmst= ate, } aio_context_acquire(aio_context); ret =3D qemu_loadvm_state(f); + migrate_set_runstate(); migration_incoming_state_destroy(); aio_context_release(aio_context); =20 diff --git a/softmmu/runstate.c b/softmmu/runstate.c index f3bd862..21d7407 100644 --- a/softmmu/runstate.c +++ b/softmmu/runstate.c @@ -77,6 +77,8 @@ typedef struct { =20 static const RunStateTransition runstate_transitions_def[] =3D { { RUN_STATE_PRELAUNCH, RUN_STATE_INMIGRATE }, + { RUN_STATE_PRELAUNCH, RUN_STATE_PAUSED }, + { RUN_STATE_PRELAUNCH, RUN_STATE_SUSPENDED }, =20 { RUN_STATE_DEBUG, RUN_STATE_RUNNING }, { RUN_STATE_DEBUG, RUN_STATE_FINISH_MIGRATE }, --=20 1.8.3.1 From nobody Tue May 14 03:54:48 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=1693350846; cv=none; d=zohomail.com; s=zohoarc; b=dJvmALSNhTuOnfE+T9Sm+tISa+n7TORkZEk4w2T+gz9Mm85v/cMiuIkFvn9+dq8m9Yhd77bL17ALsIdXWCQtWP4v1Nz2G/bMMdOVPKdY8gHFatnZXcP+6FHL+d0Ds7eC8OAXoModNDewSakAu80KK+2dXqs18GAhW/9KFYNqIdE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693350846; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=h94VtR53L6uwr4r9YxfrOz3ZrAAYuou30fpWw5QoZDE=; b=ffJVu8CsYsxeFySZMuG47ZWftzR06Zs0pBp4rIm3OoypazWBPGn6ntVlLhQONTVWoRcv7dX3htEAl0IFh85gJng2cjybJ5GNnkxOE+8K2E7uIBC8GFZhsicxuR/rmEGRYRXrVgyzcq3/qehNXZOeyg+Fl+701d+/L0VJoGodH/M= 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 1693350846932252.49738602349305; Tue, 29 Aug 2023 16:14:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qb7mw-0000jg-Pi; Tue, 29 Aug 2023 19:06:22 -0400 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 1qb3IA-0002b3-KJ for qemu-devel@nongnu.org; Tue, 29 Aug 2023 14:18:18 -0400 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 1qb3I5-0003Vl-G0 for qemu-devel@nongnu.org; Tue, 29 Aug 2023 14:18:18 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37THjHhv025414; Tue, 29 Aug 2023 18:18:11 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 3sq9k65qp9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Aug 2023 18:18:11 +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 37THBb1A024746; Tue, 29 Aug 2023 18:18:10 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3sr6dnfwks-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Aug 2023 18:18:10 +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 37TII6m0011911; Tue, 29 Aug 2023 18:18:09 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 3sr6dnfwgx-6; Tue, 29 Aug 2023 18:18:09 +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-03-30; bh=h94VtR53L6uwr4r9YxfrOz3ZrAAYuou30fpWw5QoZDE=; b=1DhG/LjIf6l3NDc2AFIZbI9X2zkM+2bUa9+Uob9sYsvhhkM9qUa0NX0qdhhMMOGl/ZS3 3CY6ZVw+WWnj0Zb1Wapv1C/AnHk1ssBajWMnFBHAxQO0DS9oWISzS1MVj25MUxxlDycw CKQ7s8PVYB2bhod9aRIoby8RQr7B8muIoVgDVPqSY2KcJMY9AOc7K42NctSZVQAfsuBu L0wM/8lZdG+v61ogNVUtSQgJa90oHOw5vPSMMmqgXnVth697413rEfKlrFGebccduA+X IwHMC+2Ir0m8BHL75tNPFW/aumMnll02FKWY+5A3xClxbw6YMHMMMRfUoswEH0c4WsyY cw== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Juan Quintela , Peter Xu , Paolo Bonzini , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Steve Sistare Subject: [PATCH V4 05/11] migration: preserve suspended for bg_migration Date: Tue, 29 Aug 2023 11:18:00 -0700 Message-Id: <1693333086-392798-6-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1693333086-392798-1-git-send-email-steven.sistare@oracle.com> References: <1693333086-392798-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-29_13,2023-08-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2308290158 X-Proofpoint-GUID: Xu5yAh_Yhh7PvcQUH-VhsKaQ_AGgPfil X-Proofpoint-ORIG-GUID: Xu5yAh_Yhh7PvcQUH-VhsKaQ_AGgPfil 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: 1693350848291100015 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. Signed-off-by: Steve Sistare --- migration/migration.c | 12 +++++------- softmmu/runstate.c | 1 + 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index a9ecb66..303d5a6 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3064,7 +3064,9 @@ 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(); + if (!runstate_check(RUN_STATE_SUSPENDED)) { + vm_start(); + } s->downtime =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME) - s->downtime_s= tart; } =20 @@ -3134,16 +3136,12 @@ 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(); /* Forcibly stop VM before saving state of vCPUs and devices */ - if (vm_stop_force_state(RUN_STATE_PAUSED)) { + if (!runstate_check(RUN_STATE_SUSPENDED) && + vm_stop_force_state(RUN_STATE_PAUSED)) { goto fail; } /* diff --git a/softmmu/runstate.c b/softmmu/runstate.c index 21d7407..4417527 100644 --- a/softmmu/runstate.c +++ b/softmmu/runstate.c @@ -163,6 +163,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 }, --=20 1.8.3.1 From nobody Tue May 14 03:54:48 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=1693350843; cv=none; d=zohomail.com; s=zohoarc; b=fRpoCvjckHygyGNrVn2wgwg75SE3ssgNW+qipPJjwmtzhioRH/3iM+PN3ewnk+lpfM1BPKBxOmrxQXdl0/yTITzANHJBSnhdSuUek2FtXEqH383dcL5gOq9MN6FkiorddxfOjfb7fp6WH/7MFlBUTjL1iyvtrVmkA9DeQoBA6IM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693350843; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=5zEChsrDoYLFxW2jtgLbAXkBvJiujNDhlgKylYUaDbs=; b=cjCUfUn2kavqd+EhstckOx8id8/TjahBxf6S0ZeTvlEQw3LOYQ8dDi/H9qkRayPSY3dps1oimq3njR9CnPa35Jj9s/keC9NMZQzXMrt/jkjJ/8rBC8AJP9+hgvEaVhrcdJD2MUCw3LOEzNQk6ACTJ1C0/jB+KWrMh3IdI0irt4g= 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 1693350843529460.9749949813589; Tue, 29 Aug 2023 16:14:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qb7mv-0000jO-R6; Tue, 29 Aug 2023 19:06:21 -0400 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 1qb3I8-0002aa-8x for qemu-devel@nongnu.org; Tue, 29 Aug 2023 14:18:17 -0400 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 1qb3I5-0003XS-G0 for qemu-devel@nongnu.org; Tue, 29 Aug 2023 14:18:16 -0400 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 37THii1f023429; Tue, 29 Aug 2023 18:18:12 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 3sq9gdwmqj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Aug 2023 18:18:11 +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 37THBApm024778; Tue, 29 Aug 2023 18:18:11 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3sr6dnfwm1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Aug 2023 18:18:10 +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 37TII6m2011911; Tue, 29 Aug 2023 18:18:10 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 3sr6dnfwgx-7; Tue, 29 Aug 2023 18:18:10 +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-03-30; bh=5zEChsrDoYLFxW2jtgLbAXkBvJiujNDhlgKylYUaDbs=; b=WTxyjawOkUHUT73UMiUL+HlJx/OHQOcswmBDofo8zfUUT2oIotvXA2Gt68Qvwx2n7RHX omtUZvQ9zTCuZikCOPh/2whPeIg19HgJPNYc4IqD3BH+62jmKg/Gvkhxr1W5a08Q3ShQ ghBhkldkKEfX+R69dWI10er4f3KDHOUlhYQAri4GjRMfeAN3Hpu8/do5Lgu85LmHXoEC MJxyrn0e0Ft+eah/g5SWLPva1Fsio8sjD9oJnxfv3FxKwsE2l1zN+ZGDOwXBkIntjed2 IWe0g/Ig8BKupme/CwWponoc/9rKUlRc//vBENM6UbcWXm5LCSqztIsx8/cHOrnEvlEx gA== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Juan Quintela , Peter Xu , Paolo Bonzini , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Steve Sistare Subject: [PATCH V4 06/11] migration: preserve cpu ticks if suspended Date: Tue, 29 Aug 2023 11:18:01 -0700 Message-Id: <1693333086-392798-7-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1693333086-392798-1-git-send-email-steven.sistare@oracle.com> References: <1693333086-392798-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-29_13,2023-08-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2308290158 X-Proofpoint-ORIG-GUID: knGy5YIXjvuqUVnJwdn-AB89aMPQW3Kn X-Proofpoint-GUID: knGy5YIXjvuqUVnJwdn-AB89aMPQW3Kn 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: 1693350845133100007 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" During RUN_STATE_SUSPENDED, the cpu clock remains enabled, so the timers_state saved to the migration stream is stale, causing time errors in the guest when it wakes from suspend. To fix, maintain a shadow copy of timers_state, and update the shadow in a pre_save handler that uses the same logic found in cpu_disable_ticks. Copy the shadow to timers_state in post_load. Signed-off-by: Steve Sistare --- softmmu/cpu-timers.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/softmmu/cpu-timers.c b/softmmu/cpu-timers.c index 117408c..d5af317 100644 --- a/softmmu/cpu-timers.c +++ b/softmmu/cpu-timers.c @@ -157,6 +157,36 @@ static bool icount_shift_state_needed(void *opaque) return icount_enabled() =3D=3D 2; } =20 +static int cpu_pre_save_ticks(void *opaque) +{ + TimersState *t =3D &timers_state; + TimersState *snap =3D opaque; + + seqlock_write_lock(&t->vm_clock_seqlock, &t->vm_clock_lock); + + if (t->cpu_ticks_enabled) { + snap->cpu_ticks_offset =3D t->cpu_ticks_offset + cpu_get_host_tick= s(); + snap->cpu_clock_offset =3D cpu_get_clock_locked(); + } else { + snap->cpu_ticks_offset =3D t->cpu_ticks_offset; + snap->cpu_clock_offset =3D t->cpu_clock_offset; + } + seqlock_write_unlock(&t->vm_clock_seqlock, &t->vm_clock_lock); + return 0; +} + +static int cpu_post_load_ticks(void *opaque, int version_id) +{ + TimersState *t =3D &timers_state; + TimersState *snap =3D opaque; + + seqlock_write_lock(&t->vm_clock_seqlock, &t->vm_clock_lock); + t->cpu_ticks_offset =3D snap->cpu_ticks_offset; + t->cpu_clock_offset =3D snap->cpu_clock_offset; + seqlock_write_unlock(&t->vm_clock_seqlock, &t->vm_clock_lock); + return 0; +} + /* * Subsection for warp timer migration is optional, because may not be cre= ated */ @@ -221,6 +251,8 @@ static const VMStateDescription vmstate_timers =3D { .name =3D "timer", .version_id =3D 2, .minimum_version_id =3D 1, + .pre_save =3D cpu_pre_save_ticks, + .post_load =3D cpu_post_load_ticks, .fields =3D (VMStateField[]) { VMSTATE_INT64(cpu_ticks_offset, TimersState), VMSTATE_UNUSED(8), @@ -269,9 +301,11 @@ TimersState timers_state; /* initialize timers state and the cpu throttle for convenience */ void cpu_timers_init(void) { + static TimersState timers_snapshot; + seqlock_init(&timers_state.vm_clock_seqlock); qemu_spin_init(&timers_state.vm_clock_lock); - vmstate_register(NULL, 0, &vmstate_timers, &timers_state); + vmstate_register(NULL, 0, &vmstate_timers, &timers_snapshot); =20 cpu_throttle_init(); } --=20 1.8.3.1 From nobody Tue May 14 03:54:48 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=1693351506; cv=none; d=zohomail.com; s=zohoarc; b=JxwluhfiPyQ5jZZTcN2x/gZn2AdjwNlJwShUtKRNgOJxmaOtWv4ryGkVsFNblqtTXm4OyRX9sNFLr0brO+6ab5wfBHEJf12JvLoDZRSJPvqnnI0i4OtoaUpiVpRd42wtKQZZLKIi592zNUcRV9Dfne0Phpl2B1zYYRcPvPXQqDs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693351506; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=1vdErBTqswJKCGBgKcN3iU5n5MlIwhPZ2NAoPmPdHEE=; b=Qx2XHJ1+uI/mp3gzPuS4fY67tpYodcVF0Lin0dHVbXbB9is6PlUuAphYknRGq0tKSXGrrBryPfW9DH8OJ9i5G6jvsHJA2A0d+JclePM1FuFAmxA8es39hPOsKvQBDoW4V6fPLeN3faqjY2cCHF8NK6p3bbScxOnas2vnk0RSg9I= 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 1693351506432944.6975733650444; Tue, 29 Aug 2023 16:25:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qb7mt-0000hY-HK; Tue, 29 Aug 2023 19:06:19 -0400 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 1qb3IC-0002bj-Lp for qemu-devel@nongnu.org; Tue, 29 Aug 2023 14:18:20 -0400 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 1qb3I6-0003Xv-50 for qemu-devel@nongnu.org; Tue, 29 Aug 2023 14:18:20 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37THio7C022974; Tue, 29 Aug 2023 18:18:12 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 3sq9k65qpb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Aug 2023 18:18:12 +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 37THC5h4024776; Tue, 29 Aug 2023 18:18:11 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3sr6dnfwmd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Aug 2023 18:18:11 +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 37TII6m4011911; Tue, 29 Aug 2023 18:18:11 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 3sr6dnfwgx-8; Tue, 29 Aug 2023 18:18:10 +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-03-30; bh=1vdErBTqswJKCGBgKcN3iU5n5MlIwhPZ2NAoPmPdHEE=; b=ivjfSvvM2hfa8vl9OIqw37nerFf/VFF+0PR16KFV3eq3k2NumVp7IKgaBQc7CF2Kj6WO WRBiEGUJffglywhMlNQY1rJFEb8KCWDT/qAZ2VBtq9d3VG4yrow38W3Jjr7RTq7MFIKA RnjlUlXw1WmAAWQsXvSNUNBJChq7ur0lceu3T1dhWmtbiED8N/F6x0n7k3+LQgUSoG5p UB/aO4JOBGXI7F328tU2dM/khOmFByPujvIXczl+TYiRGFbYUj68ZNYWbb4UvMbzTGm9 JY7hCPb5yDzleFY0B22Sc7v7+URLyeO3t7ySoAmaHqSG9WdFK770oxDcbxgqjAij7VUX 3A== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Juan Quintela , Peter Xu , Paolo Bonzini , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Steve Sistare Subject: [PATCH V4 07/11] tests/qtest: migration events Date: Tue, 29 Aug 2023 11:18:02 -0700 Message-Id: <1693333086-392798-8-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1693333086-392798-1-git-send-email-steven.sistare@oracle.com> References: <1693333086-392798-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-29_13,2023-08-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2308290158 X-Proofpoint-GUID: IJsnKrVwbBg8FLFwevjpVw9mAnjUWGWA X-Proofpoint-ORIG-GUID: IJsnKrVwbBg8FLFwevjpVw9mAnjUWGWA 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: 1693351506876100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- tests/qtest/migration-helpers.c | 24 +++++---------- tests/qtest/migration-helpers.h | 8 +++-- tests/qtest/migration-test.c | 68 +++++++++++++++++++------------------= ---- 3 files changed, 44 insertions(+), 56 deletions(-) diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helper= s.c index be00c52..b541108 100644 --- a/tests/qtest/migration-helpers.c +++ b/tests/qtest/migration-helpers.c @@ -23,26 +23,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 009e250..59fbb83 100644 --- a/tests/qtest/migration-helpers.h +++ b/tests/qtest/migration-helpers.h @@ -15,9 +15,11 @@ =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, 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 62d3f37..526a1b7 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 @@ -188,6 +188,13 @@ 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"); + } +} + /* * It's tricky to use qemu's migration event capability with qtest, * events suddenly appearing confuse the qmp()/hmp() responses. @@ -235,21 +242,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) @@ -586,10 +591,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 @@ -720,8 +722,9 @@ 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) { }; + bootpath =3D g_strdup_printf("%s/bootsect", tmpfs); 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 */ @@ -801,8 +804,8 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, if (!args->only_target) { *from =3D qtest_init(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 " @@ -821,8 +824,8 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, ignore_stderr); *to =3D qtest_init(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. @@ -1516,9 +1519,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); } } @@ -1560,9 +1561,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); /* @@ -1575,7 +1575,7 @@ static void test_precopy_common(MigrateCommon *args) qtest_qmp_assert_success(to, "{ 'execute' : 'cont'}"); } =20 - if (!got_dst_resume) { + if (!dst_state.resume_seen) { qtest_qmp_eventwait(to, "RESUME"); } =20 @@ -1696,9 +1696,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 @@ -2139,7 +2137,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); @@ -2481,9 +2479,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"); --=20 1.8.3.1 From nobody Tue May 14 03:54:48 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=1693351254; cv=none; d=zohomail.com; s=zohoarc; b=mPEhi5CTRRGBapv9PtQ7rDdv5Ya9DEEhU7JFinbaia1jMcvka9v88uhejokJ5h3Ilp11B4EJEABYIewVRrG5frM7RChE22zDC1eDT5M66FgzFD8uTUawwK2kCUHmHsrjnH/B70q6F6GuM3Jtu0yevhY467Wb+rwfoQ6qZHElNOQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693351254; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=UNxLun2DOapVva8NGN0SFSfM2/dSJ1uh5JMJ64QcNFo=; b=fR0nTo4wlKXRQKLBMWe/sKLMbB1jSmGBnmsyE/q/lz+x7nHxtZ+tGwYZHgr3Asnyax6oxZQA4CPxDrIR4ZLxP45xjZH3HrHeocZsqbXFQuNTIfblJxu9zC9IPkpTLRx+B3nqyT/X0TdlHysMYauzOizXTeVKGbZiBqw4SxDreE0= 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 SMTP id 1693351254948350.46825044994125; Tue, 29 Aug 2023 16:20:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qb7mx-0000kB-1l; Tue, 29 Aug 2023 19:06:23 -0400 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 1qb3IC-0002by-RY for qemu-devel@nongnu.org; Tue, 29 Aug 2023 14:18:20 -0400 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 1qb3I6-0003YY-57 for qemu-devel@nongnu.org; Tue, 29 Aug 2023 14:18:20 -0400 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37THinQ5007100; Tue, 29 Aug 2023 18:18:13 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 3sq9mcnprw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Aug 2023 18:18:12 +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 37THEWLS024792; Tue, 29 Aug 2023 18:18:12 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3sr6dnfwmw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Aug 2023 18:18:12 +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 37TII6m6011911; Tue, 29 Aug 2023 18:18:11 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 3sr6dnfwgx-9; Tue, 29 Aug 2023 18:18:11 +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-03-30; bh=UNxLun2DOapVva8NGN0SFSfM2/dSJ1uh5JMJ64QcNFo=; b=BwrdQbQmyUu1W9hDE19XvfLdKsIiQ+EbdxWcqJJzWL7VzxlvOl6nwIde4+C21uxIj7F+ UXua/mFXVEprmK6NcpkGfD9d2LxtUiwDpWhf/c6Gg1CB7TIkaXq1SpxLvNCEgV0lFyJK aqZHoCfNo8zidyuBrhB4P4eJTFbed+HAGgUhXvGck/3Yn4Zhw8bboYHSCcdtDVnWdPFK +rq3a1ZKL9xhTK2P5Z7K2f33KoqTX0rpzIPSHfltg2EVD7BrY6ddEtpIfJpS/OIryzHP oCEWYAL+Lr+XXkyJV8geEXuxe+04yomzT5hwOQmb5NFsu8lYLv6PYrKc6YxmQddUtXB4 YA== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Juan Quintela , Peter Xu , Paolo Bonzini , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Steve Sistare Subject: [PATCH V4 08/11] tests/qtest: option to suspend during migration Date: Tue, 29 Aug 2023 11:18:03 -0700 Message-Id: <1693333086-392798-9-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1693333086-392798-1-git-send-email-steven.sistare@oracle.com> References: <1693333086-392798-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-29_13,2023-08-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2308290158 X-Proofpoint-ORIG-GUID: yK492flz7xITd9QxQ-yN63LNzp9oPGfT X-Proofpoint-GUID: yK492flz7xITd9QxQ-yN63LNzp9oPGfT 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: 1693351256957100001 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. Signed-off-by: Steve Sistare Acked-by: Peter Xu --- tests/migration/i386/Makefile | 5 ++-- tests/migration/i386/a-b-bootblock.S | 51 ++++++++++++++++++++++++++++++++= +--- tests/migration/i386/a-b-bootblock.h | 22 ++++++++++------ tests/qtest/migration-test.c | 4 +++ 4 files changed, 68 insertions(+), 14 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 3d464c7..62d79b2 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 @@ -41,12 +58,11 @@ start: # at 0x7c00 ? # bl keeps a counter so we limit the output speed mov $0, %bl mainloop: - # Start from 1MB - mov $(1024*1024),%eax + mov $LOW_ADDR,%eax innerloop: incb (%eax) add $4096,%eax - cmp $(100*1024*1024),%eax + cmp $HIGH_ADDR,%eax jl innerloop =20 inc %bl @@ -57,7 +73,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 */ @@ -83,6 +122,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 b7b0fce..4d46873 100644 --- a/tests/migration/i386/a-b-bootblock.h +++ b/tests/migration/i386/a-b-bootblock.h @@ -4,20 +4,20 @@ * the header and the assembler differences in your patch submission. */ unsigned char x86_bootsect[] =3D { - 0xfa, 0x0f, 0x01, 0x16, 0x78, 0x7c, 0x66, 0xb8, 0x01, 0x00, 0x00, 0x00, + 0xfa, 0x0f, 0x01, 0x16, 0xa4, 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, 0x00, 0x66, 0xba, 0xf8, 0x03, 0xee, 0xb3, 0x00, 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, 0x60, 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, + 0x42, 0x00, 0x66, 0xba, 0xf8, 0x03, 0xee, 0xa1, 0xaa, 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, 0x8c, 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, @@ -49,3 +49,9 @@ unsigned char x86_bootsect[] =3D { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa }; =20 +#define SYM_gdt 0x00007c8c +#define SYM_gdtdesc 0x00007ca4 +#define SYM_innerloop 0x00007c3d +#define SYM_mainloop 0x00007c38 +#define SYM_start 0x00007c00 +#define SYM_suspend_me 0x00007caa diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 526a1b7..32fea73 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -608,6 +608,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 /* @@ -725,6 +727,8 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, dst_state =3D (QTestMigrationState) { }; src_state =3D (QTestMigrationState) { }; =20 + x86_bootsect[SYM_suspend_me - SYM_start] =3D args->suspend_me; + bootpath =3D g_strdup_printf("%s/bootsect", tmpfs); 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 */ --=20 1.8.3.1 From nobody Tue May 14 03:54:48 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=1693350926; cv=none; d=zohomail.com; s=zohoarc; b=BdFwJu7rsl2y9J+/OID58WIqS1BVSBu27dohTfP6tHV+WpDdakrn+o10igvilb/8Sjxm26mhKe2+e+PaFnFUSzF+MP8+fAZ+UKTlLMfJ2jMiz59C7kOHXhF5AQ99K6LuSY8WRIB64yXZsAqWuwDfNOk9HBsNMNs4T8YsZG8a6MM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693350926; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=Fhb57Vsnw9yolR+L7YBCREWXSS5UQDBkOEELlen67TU=; b=BV+xJiJgN0iwWwphVERQVeVsVfg0SusMmmK6QpfPMGIG8E8P/trbOh9rRVlk17I4SRvdsiUQQvIZ4wBTpoRNd1HEP/pMZnHZfLnZdDBqpalZDq5gZd0TS4xVuu6BfgxnPQpoFlr7WbrH6IG0FpG6n0Kxwyqawe2l91jNJ4YrjEw= 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 1693350926323485.91224947157764; Tue, 29 Aug 2023 16:15:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qb7mw-0000jY-E2; Tue, 29 Aug 2023 19:06:22 -0400 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 1qb3IC-0002bt-Qb for qemu-devel@nongnu.org; Tue, 29 Aug 2023 14:18:20 -0400 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 1qb3I6-0003ZS-Pq for qemu-devel@nongnu.org; Tue, 29 Aug 2023 14:18:20 -0400 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 37THnLOL021253; Tue, 29 Aug 2023 18:18:14 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 3sq9nywk30-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Aug 2023 18:18:13 +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 37THCEqY024859; Tue, 29 Aug 2023 18:18:12 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3sr6dnfwnf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Aug 2023 18:18:12 +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 37TII6m8011911; Tue, 29 Aug 2023 18:18:12 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 3sr6dnfwgx-10; Tue, 29 Aug 2023 18:18:12 +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-03-30; bh=Fhb57Vsnw9yolR+L7YBCREWXSS5UQDBkOEELlen67TU=; b=RYoSqDo+q5pjvQtzWW6MFrxpf5qT34jHbnFsYtU2AN7P6kDAoTFTIz0lxVjipImSVbji eMpqWseR82S5Dn5j5OxhQUzMPVxXRLL8Ph5mbnt93FCJlKD8ePzEngzv1eemdrGMM1KJ usBfot3k3FuXAnOIMhbjr25SxOS/D9ClUOyg2zMwS4LAcSY4YZ8WSE2+Zz2Z+u1jOOTr ugfLS2cNP+05Wj91j8OrYYh4NBd0kt4VHfepamMZeeVBu2XCl4AaGLyI6sEC13luj95t 2hlWBzVxqIiDtKkzDJlI4NNUqvNzFijsW9MqMK9yIGcUWXpv2b/fqeyCSUzqYp8Ei6zC Aw== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Juan Quintela , Peter Xu , Paolo Bonzini , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Steve Sistare Subject: [PATCH V4 09/11] tests/qtest: precopy migration with suspend Date: Tue, 29 Aug 2023 11:18:04 -0700 Message-Id: <1693333086-392798-10-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1693333086-392798-1-git-send-email-steven.sistare@oracle.com> References: <1693333086-392798-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-29_13,2023-08-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2308290158 X-Proofpoint-ORIG-GUID: gfg4ptBhSLM9QqjYoeXGOIh2JOLY7RS4 X-Proofpoint-GUID: gfg4ptBhSLM9QqjYoeXGOIh2JOLY7RS4 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: 1693350928031100011 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 --- tests/qtest/migration-helpers.c | 3 ++ tests/qtest/migration-helpers.h | 3 +- tests/qtest/migration-test.c | 73 +++++++++++++++++++++++++++++++++++++= ---- 3 files changed, 71 insertions(+), 8 deletions(-) diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helper= s.c index b541108..d1fec49 100644 --- a/tests/qtest/migration-helpers.c +++ b/tests/qtest/migration-helpers.c @@ -31,6 +31,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 59fbb83..bac8699 100644 --- a/tests/qtest/migration-helpers.h +++ b/tests/qtest/migration-helpers.h @@ -16,7 +16,8 @@ #include "libqtest.h" =20 typedef struct QTestMigrationState { - bool stop_seen, resume_seen; + bool suspend_me; + bool stop_seen, suspend_seen, resume_seen; } 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 32fea73..cc508ef 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -135,7 +135,7 @@ static void init_bootfile(const char *bootpath, void *c= ontent, size_t len) /* * 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) { @@ -195,6 +195,13 @@ static void wait_for_stop(QTestState *who, QTestMigrat= ionState *state) } } =20 +static void wait_for_suspend(QTestState *who, QTestMigrationState *state) +{ + if (!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. @@ -249,7 +256,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); @@ -545,7 +552,8 @@ static void migrate_wait_for_dirty_mem(QTestState *from, watch_byte =3D qtest_readb(from, watch_address); do { usleep(1000 * 10); - } while (qtest_readb(from, watch_address) =3D=3D watch_byte); + } while (qtest_readb(from, watch_address) =3D=3D watch_byte && + !src_state.suspend_seen); } =20 =20 @@ -727,6 +735,7 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, dst_state =3D (QTestMigrationState) { }; src_state =3D (QTestMigrationState) { }; =20 + src_state.suspend_me =3D args->suspend_me; x86_bootsect[SYM_suspend_me - SYM_start] =3D args->suspend_me; =20 bootpath =3D g_strdup_printf("%s/bootsect", tmpfs); @@ -1522,8 +1531,12 @@ static void test_precopy_common(MigrateCommon *args) * change anything. */ if (args->result =3D=3D MIG_TEST_SUCCEED) { - qtest_qmp_assert_success(from, "{ 'execute' : 'stop'}"); - wait_for_stop(from, &src_state); + if (src_state.suspend_me) { + wait_for_suspend(from, &src_state); + } else { + qtest_qmp_assert_success(from, "{ 'execute' : 'stop'}"); + wait_for_stop(from, &src_state); + } migrate_ensure_converge(from); } } @@ -1565,7 +1578,11 @@ static void test_precopy_common(MigrateCommon *args) */ wait_for_migration_complete(from); =20 - wait_for_stop(from, &src_state); + if (src_state.suspend_me) { + wait_for_suspend(from, &src_state); + } else { + wait_for_stop(from, &src_state); + } =20 } else { wait_for_migration_complete(from); @@ -1579,10 +1596,16 @@ static void test_precopy_common(MigrateCommon *args) qtest_qmp_assert_success(to, "{ 'execute' : 'cont'}"); } =20 + /* Always get RESUME first after switchover */ if (!dst_state.resume_seen) { qtest_qmp_eventwait(to, "RESUME"); } =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 @@ -1609,6 +1632,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) { @@ -2765,7 +2816,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; int ret; @@ -2782,6 +2833,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 @@ -2812,6 +2864,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 03:54:48 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=1693351704; cv=none; d=zohomail.com; s=zohoarc; b=S/B8gTLa1RJ+B/NRXueTWDFaPT2XQWD1afX7dA/HULyqCGX3+F/C+HPlXLLQRrSqHE4SrQ3FBE37YpauXQayE4SmJhQGsQ3DYPbA316bYtUjiDtBMpJ1zAKN8MvXDTD4B4Tm2uWsti0xbKi2MNrVCDfMMoZvbRYu4mFjEdk3F/0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693351704; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=fRwushpw6567sXwJ1uISKOi4xWb1Zs0MflTc5kt0f9E=; b=Qt2Fkha0cTUiTzQQY1UouaC4paK0ktFCxsnvSLs5Tv0EDbhS6h1gDOVYYEw10aNqjDajmuPP48fFvfFwkl0ySA8IKO6kUHUrFHcxLvP2qEsfPQUrSpSeK0jveximEXF8k09hAyp0CFHJHKjQUimAMVGu0B/kriqukUfgAl193gQ= 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 1693351704638884.8616144008323; Tue, 29 Aug 2023 16:28:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qb7n0-0000o9-CI; Tue, 29 Aug 2023 19:06:26 -0400 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 1qb3IC-0002bi-J1 for qemu-devel@nongnu.org; Tue, 29 Aug 2023 14:18:20 -0400 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 1qb3I7-0003ZP-59 for qemu-devel@nongnu.org; Tue, 29 Aug 2023 14:18:20 -0400 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37THimmE007078; Tue, 29 Aug 2023 18:18:14 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 3sq9mcnprx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Aug 2023 18:18:13 +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 37THApTY024805; Tue, 29 Aug 2023 18:18:13 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3sr6dnfwp3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Aug 2023 18:18:13 +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 37TII6mA011911; Tue, 29 Aug 2023 18:18:12 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 3sr6dnfwgx-11; Tue, 29 Aug 2023 18:18:12 +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-03-30; bh=fRwushpw6567sXwJ1uISKOi4xWb1Zs0MflTc5kt0f9E=; b=pypeRrTdUN/fu5F4796/j4Ug+AuiXjX4oCFPgQg2ZqzDcS26R7y8CTMMd1/MeRBAPD4W ItnTHHUSC76xyQVgnBLV+EGz8IAW3pKKiOcH593zg3bWePYHbGYKualJMulSh7OATBK9 iTcy2snuB9jczj0EcjJFaErqS49npsxMQH1reNFu1fXMbeHdpv+e8JAchs/APwc3TaoD 54GG1OHcmyD/tHXEtoAz/h6r7Q7wvn2x6GvqXAD8JtUl6OmIN69vhKYSe9jQqmjS2yJh iJkU8avO7jnx7ej5vFj2CbfHVqB3zFT8VRctIn3efrL2Ho8ooAYgCAvNAbN5NyJMfkYC Vw== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Juan Quintela , Peter Xu , Paolo Bonzini , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Steve Sistare Subject: [PATCH V4 10/11] tests/qtest: postcopy migration with suspend Date: Tue, 29 Aug 2023 11:18:05 -0700 Message-Id: <1693333086-392798-11-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1693333086-392798-1-git-send-email-steven.sistare@oracle.com> References: <1693333086-392798-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-29_13,2023-08-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2308290158 X-Proofpoint-ORIG-GUID: KcbZGdBa8hl6wYO5xAmRVhVbSiC9DyWa X-Proofpoint-GUID: KcbZGdBa8hl6wYO5xAmRVhVbSiC9DyWa 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: 1693351705020100001 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 --- tests/qtest/migration-test.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index cc508ef..6306fb0 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -599,8 +599,12 @@ static void migrate_postcopy_start(QTestState *from, Q= TestState *to) { qtest_qmp_assert_success(from, "{ 'execute': 'migrate-start-postcopy' = }"); =20 - wait_for_stop(from, &src_state); - qtest_qmp_eventwait(to, "RESUME"); + if (src_state.suspend_me) { + wait_for_suspend(from, &src_state); + } else { + wait_for_stop(from, &src_state); + qtest_qmp_eventwait(to, "RESUME"); + } } =20 typedef struct { @@ -1299,6 +1303,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 @@ -1332,6 +1341,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 { @@ -2884,6 +2902,10 @@ int main(int argc, char **argv) qtest_add_func("/migration/postcopy/recovery/compress/plain", test_postcopy_recovery_compress); } + 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 From nobody Tue May 14 03:54:48 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=1693351452; cv=none; d=zohomail.com; s=zohoarc; b=SPJKq+pK3sqA35kA4KX75D3HyWfSELlfmJ0x7okqTnO65JZ64GqHEjJ8oF4GwZCMWJvfmDzgf6TCfo/T/L5O2Nb4vlcpi4ZF82vIXuov6/zw791WXx8gP/n7+M3+d7DzUSs9CwWbz5MVbSwD3pWal13Or8pp1EP4E/aWH55zLIM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693351452; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=IWWVBha9gd8bwnKmWDKDDFgbWBMDNoq5y26TbIpzpVU=; b=Qbkc8QX4M22sVqG07VHn3PliJ8SLOvVIiJ/KVRUXIZ73Pg/PbfdOr3cSwtrBhWZrYy94TJ5o0TIIevSqI+H+z4uKeojAVFb1QnRGxWmywuzLE+8kyz6hnyGmYIaHndcvCkFNnLo1UyDTpz2XVx594d/IN2qnU7M3zX48RS+MIXk= 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 1693351452416920.407166985286; Tue, 29 Aug 2023 16:24:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qb7n1-0000oL-1f; Tue, 29 Aug 2023 19:06:27 -0400 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 1qb3IC-0002bk-Lc for qemu-devel@nongnu.org; Tue, 29 Aug 2023 14:18:20 -0400 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 1qb3I7-0003Zs-Hh for qemu-devel@nongnu.org; Tue, 29 Aug 2023 14:18:20 -0400 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 37THihp9023421; Tue, 29 Aug 2023 18:18:14 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 3sq9gdwmqp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Aug 2023 18:18:14 +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 37THBb1D024746; Tue, 29 Aug 2023 18:18:13 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3sr6dnfwph-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Aug 2023 18:18:13 +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 37TII6mC011911; Tue, 29 Aug 2023 18:18:13 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 3sr6dnfwgx-12; Tue, 29 Aug 2023 18:18:13 +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-03-30; bh=IWWVBha9gd8bwnKmWDKDDFgbWBMDNoq5y26TbIpzpVU=; b=doHedP8JKKusKUGGZR/p64f2nWrcSnDRXxY5mXCEJ3uCuDgcG4KiuqU90QjpDd8QxVUr SYpLP8UTaxJbv6jSLqPALMIRzoZeJilzsR8vAEVQD8WnE9EocbVzlHtpA7CU8qTXgEBW V9KKIEbWX0EOlou7h0IKb3XfwXE0U35Jj51R53yeTnDLTpFC7fqY74OJeD/KpLonG+HR zrLDkllihKFPawRSFOB93RwOYCZNkNruC7vSiFOlLN21pIN+dNG+P5u+AiePJjvvzbOC WPCDySxjpGDChojmnHYfA6oS42J0zAlI5quf0a2NExAIbB47pGRH/4khcLhSc4SFv4Jo hA== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Juan Quintela , Peter Xu , Paolo Bonzini , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Steve Sistare Subject: [PATCH V4 11/11] tests/qtest: background migration with suspend Date: Tue, 29 Aug 2023 11:18:06 -0700 Message-Id: <1693333086-392798-12-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1693333086-392798-1-git-send-email-steven.sistare@oracle.com> References: <1693333086-392798-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-29_13,2023-08-29_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2308290158 X-Proofpoint-ORIG-GUID: lQSiuTJlKU5HPFx0rj-DuDZckEqbVtWI X-Proofpoint-GUID: lQSiuTJlKU5HPFx0rj-DuDZckEqbVtWI 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: 1693351453189100003 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 a background migration. The test suspends the src, migrates, then wakes the dest. Signed-off-by: Steve Sistare --- tests/qtest/migration-test.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 6306fb0..5cc8b91 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -1679,6 +1679,26 @@ static void test_precopy_unix_suspend_notlive(void) test_precopy_common(&args); } =20 +static void *test_bg_suspend_start(QTestState *from, QTestState *to) +{ + migrate_set_capability(from, "background-snapshot", true); + return NULL; +} + +static void test_bg_suspend(void) +{ + g_autofree char *uri =3D g_strdup_printf("unix:%s/migsocket", tmpfs); + MigrateCommon args =3D { + .listen_uri =3D uri, + .connect_uri =3D uri, + .live =3D true, /* runs fast, the src suspends immediately. = */ + .start.suspend_me =3D true, + .start_hook =3D test_bg_suspend_start + }; + + test_precopy_common(&args); +} + static void test_precopy_unix_dirty_ring(void) { g_autofree char *uri =3D g_strdup_printf("unix:%s/migsocket", tmpfs); @@ -2905,6 +2925,7 @@ int main(int argc, char **argv) if (is_x86) { qtest_add_func("/migration/postcopy/suspend", test_postcopy_suspend); + qtest_add_func("/migration/bg/suspend", test_bg_suspend); } } =20 --=20 1.8.3.1