From patchwork Mon Aug 14 18:54:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 13353188 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 17837C001DB for ; Mon, 14 Aug 2023 18:55:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qVciR-0005dj-Ui; Mon, 14 Aug 2023 14:54:59 -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 1qVciG-0005WV-Uf for qemu-devel@nongnu.org; Mon, 14 Aug 2023 14:54:48 -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 1qVciE-0007rg-58 for qemu-devel@nongnu.org; Mon, 14 Aug 2023 14:54:48 -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 37EGTRL0003567; Mon, 14 Aug 2023 18:54:40 GMT 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=DjJ5aBqqQaSL4LB58R4w8C9VlhvTDYJtFRn9bopg6Vg=; b=OG2998aFKFPVRMIj89YDyOngOxTC2WMuDr/o9I5i2NdNyZwm3FUgRvWbV7iYu73t5fZM jmfSd8wDKli3MSLZ8pFMO3hmr0rJffWbDz5JgeICkRuVbrU75hjoFCG9FjY/ojkUdVnd RA43VbxBZFCrXYu5GS6lLkS5BOWUsxS/pL11HNWOI8wC4md3cXmb2JEctWay/veOkhTj 8KpLPfFG5JXavbJkUzTN1TDrHg3tPt1+D0RFFx2EZ14TuVFK53pl90iveExAVkR4s2zN RMiWOqD120/72OaZPQfqg3HmIx6gzBAMWMOE/vc+siGpnl6qzM5g06sdId7AMzBsxN6M qA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3se2yfkbjt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 14 Aug 2023 18:54:39 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 37EIfJOA006606; Mon, 14 Aug 2023 18:54:39 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3sey2c8x4k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 14 Aug 2023 18:54:39 +0000 Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 37EIsb3n008127; Mon, 14 Aug 2023 18:54:38 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3sey2c8x3f-2; Mon, 14 Aug 2023 18:54:38 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Cc: Juan Quintela , Peter Xu , Paolo Bonzini , Thomas Huth , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Steve Sistare Subject: [PATCH V3 01/10] vl: start on wakeup request Date: Mon, 14 Aug 2023 11:54:27 -0700 Message-Id: <1692039276-148610-2-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1692039276-148610-1-git-send-email-steven.sistare@oracle.com> References: <1692039276-148610-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.591,FMLib:17.11.176.26 definitions=2023-08-14_15,2023-08-10_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 adultscore=0 spamscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308140175 X-Proofpoint-ORIG-GUID: 2XTzaRvbzBEW8MGYXZ2joyb1R6RaMf_m X-Proofpoint-GUID: 2XTzaRvbzBEW8MGYXZ2joyb1R6RaMf_m 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org If qemu starts and loads a VM in the suspended state, then a later wakeup request directly sets the state to running. This skips vm_start() and its initialization steps, which is fatal for the guest. See qemu_system_wakeup_request(), and qemu_system_wakeup() in main_loop_should_exit(). Remember if vm_start has been called. If not, then call vm_start from qemu_system_wakeup_request. Signed-off-by: Steve Sistare Reviewed-by: Fabiano Rosas --- include/sysemu/runstate.h | 1 + softmmu/cpus.c | 12 ++++++++++++ softmmu/runstate.c | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h index 7beb29c..42ddf83 100644 --- a/include/sysemu/runstate.h +++ b/include/sysemu/runstate.h @@ -34,6 +34,7 @@ static inline bool shutdown_caused_by_guest(ShutdownCause cause) } void vm_start(void); +void vm_wakeup(void); /** * vm_prepare_start: Prepare for starting/resuming the VM diff --git a/softmmu/cpus.c b/softmmu/cpus.c index fed20ff..fa9e5ba 100644 --- a/softmmu/cpus.c +++ b/softmmu/cpus.c @@ -66,6 +66,7 @@ #endif /* CONFIG_LINUX */ static QemuMutex qemu_global_mutex; +static bool vm_started; /* * The chosen accelerator is supposed to register this. @@ -264,6 +265,7 @@ static int do_vm_stop(RunState state, bool send_stop) if (send_stop) { qapi_event_send_stop(); } + vm_started = false; } bdrv_drain_all(); @@ -722,6 +724,16 @@ void vm_start(void) { if (!vm_prepare_start(false)) { resume_all_vcpus(); + vm_started = true; + } +} + +void vm_wakeup(void) +{ + if (!vm_started) { + vm_start(); + } else { + runstate_set(RUN_STATE_RUNNING); } } diff --git a/softmmu/runstate.c b/softmmu/runstate.c index f3bd862..95c6ae7 100644 --- a/softmmu/runstate.c +++ b/softmmu/runstate.c @@ -580,7 +580,7 @@ void qemu_system_wakeup_request(WakeupReason reason, Error **errp) if (!(wakeup_reason_mask & (1 << reason))) { return; } - runstate_set(RUN_STATE_RUNNING); + vm_wakeup(); wakeup_reason = reason; qemu_notify_event(); }