From nobody Wed Nov 27 02:36:50 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=1701882815; cv=none; d=zohomail.com; s=zohoarc; b=Ggfw43qgyH2Eq7ameEgBWVVQzGmw71gUpsUzKwEatPvDgmm3UvovM0Ou/oAJFZNZo+DCNqvz0tAoVDI7ZL1B32uOKHoU4ON9IRuBdOGQHw1UicSpxs/JiENQUFTh15w2OwpFXKT15dEbw7WUaSq4Ii7vLtMR0Lru7N//BkCwMKs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701882815; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=aLOz2yAMmdAjdRV81QWUIcK3jFpFi6Me6Vk5sz1tc2I=; b=a9GvGa+FObcBBROmD0aL5bN6uskjf2AEGIAjUGEjA9UIF2Jd1szt3VNPxRUU9CeGIzuQsOY+O4jHFBCl5k6ws1VvdmVfDOtMXRsTrq/d3vJIBITjuXoSoXKHMSaYMAZEQhQJZJL1itTzogmxfmWb8shEzjWMNae0Hd5gLPTP6ys= 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 1701882815166768.310627790119; Wed, 6 Dec 2023 09:13:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rAvSZ-00072d-UF; Wed, 06 Dec 2023 12:13:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rAvSY-00071h-J4 for qemu-devel@nongnu.org; Wed, 06 Dec 2023 12:13:18 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rAvSW-0001Xf-SS for qemu-devel@nongnu.org; Wed, 06 Dec 2023 12:13:18 -0500 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B6EY6Um006578; Wed, 6 Dec 2023 17:13:16 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3utdabt0cq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 06 Dec 2023 17:13:15 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3B6H1H7P032300; Wed, 6 Dec 2023 17:13:15 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3utan9exh1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 06 Dec 2023 17:13:15 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3B6HCrVN024168; Wed, 6 Dec 2023 17:13:14 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3utan9ewxa-17; Wed, 06 Dec 2023 17:13:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=aLOz2yAMmdAjdRV81QWUIcK3jFpFi6Me6Vk5sz1tc2I=; b=Qu3AP2kT393QcZiqh/E4qaGDtK9cnTU5BxseCMiegU3RyemlXbSSYXveGpkJmRBbx6Xy ObJ3ZRHoKuvv7f1NPgGxmvKu3yFpvUrgJ6JAecskVrggo9TRvqTJrnTYxko0l5Su9xKo h45ha7mMYfBVXqqR9kUiPuJKyV1+1VwSXRZuaxciswb++Gyn0e2kHcIo65aYadX/8TzA GwR8wYvoh6K+nH4FDKkw9tKQUj7J3LbFfSx0c0IzBD2eTd8zAPlL+v//LHoJy8Zs9TS3 cULwU4dysxqceXz3LR4A75xTO4QB10O8Lvk07tPtSNGi94jMVjsq9/otgsqBgdu4c1Fq 5g== 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?= , Fabiano Rosas , Leonardo Bras , Steve Sistare Subject: [PATCH 08/14] migration: preserve suspended runstate Date: Wed, 6 Dec 2023 09:12:42 -0800 Message-Id: <1701882772-356078-17-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1701882772-356078-1-git-send-email-steven.sistare@oracle.com> References: <1701882772-356078-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-06_15,2023-12-06_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 suspectscore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312060140 X-Proofpoint-ORIG-GUID: 8HQTM7Y3PZGITvJwGgu3ESidGk6_SfOC X-Proofpoint-GUID: 8HQTM7Y3PZGITvJwGgu3ESidGk6_SfOC 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1701882815525100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" A guest that is migrated in the suspended state automaticaly wakes and continues execution. This is wrong; the guest should end migration in the same state it started. The root cause is that the outgoing migration code automatically wakes the guest, then saves the RUNNING runstate in global_state_store(), hence the incoming migration code thinks the guest is running and continues the guest if autostart is true. On the outgoing side, delete the call to qemu_system_wakeup_request(). Now that vm_stop completely stops a vm in the suspended state (from the preceding patches), the existing call to vm_stop_force_state is sufficient to correctly migrate all vmstate. On the incoming side, call vm_start if the pre-migration state was running or suspended. For the latter, vm_start correctly restores the suspended state, and a future system_wakeup monitor request will cause the vm to resume running. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu --- migration/migration.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 28a34c9..52ba0bc 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -603,7 +603,7 @@ static void process_incoming_migration_bh(void *opaque) */ if (!migrate_late_block_activate() || (autostart && (!global_state_received() || - global_state_get_runstate() =3D=3D RUN_STATE_RUNNING))) { + runstate_is_live(global_state_get_runstate())))) { /* Make sure all file formats throw away their mutable metadata. * If we get an error here, just don't restart the VM yet. */ bdrv_activate_all(&local_err); @@ -627,7 +627,7 @@ static void process_incoming_migration_bh(void *opaque) dirty_bitmap_mig_before_vm_start(); =20 if (!global_state_received() || - global_state_get_runstate() =3D=3D RUN_STATE_RUNNING) { + runstate_is_live(global_state_get_runstate())) { if (autostart) { vm_start(); } else { @@ -2415,7 +2415,6 @@ static int postcopy_start(MigrationState *ms, Error *= *errp) =20 migration_downtime_start(ms); =20 - qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL); global_state_store(); ret =3D migration_stop_vm(RUN_STATE_FINISH_MIGRATE); if (ret < 0) { @@ -2614,7 +2613,6 @@ static int migration_completion_precopy(MigrationStat= e *s, =20 qemu_mutex_lock_iothread(); migration_downtime_start(s); - qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL); =20 s->vm_old_state =3D runstate_get(); global_state_store(); @@ -3135,7 +3133,7 @@ static void migration_iteration_finish(MigrationState= *s) case MIGRATION_STATUS_FAILED: case MIGRATION_STATUS_CANCELLED: case MIGRATION_STATUS_CANCELLING: - if (s->vm_old_state =3D=3D RUN_STATE_RUNNING) { + if (runstate_is_live(s->vm_old_state)) { if (!runstate_check(RUN_STATE_SHUTDOWN)) { vm_start(); } --=20 1.8.3.1