From nobody Sat Apr 27 07:16:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1512153614182411.39209293968133; Fri, 1 Dec 2017 10:40:14 -0800 (PST) Received: from localhost ([::1]:59568 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eKqEE-00019V-8S for importer@patchew.org; Fri, 01 Dec 2017 13:40:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59864) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eKou8-0005xh-Vk for qemu-devel@nongnu.org; Fri, 01 Dec 2017 12:15:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eKou3-0003lM-7w for qemu-devel@nongnu.org; Fri, 01 Dec 2017 12:15:12 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:44156 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eKou3-0003jy-30 for qemu-devel@nongnu.org; Fri, 01 Dec 2017 12:15:07 -0500 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vB1HEsjq036749 for ; Fri, 1 Dec 2017 12:15:06 -0500 Received: from e16.ny.us.ibm.com (e16.ny.us.ibm.com [129.33.205.206]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ek8wkfmek-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 01 Dec 2017 12:15:05 -0500 Received: from localhost by e16.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 1 Dec 2017 12:15:04 -0500 Received: from b01cxnp22036.gho.pok.ibm.com (9.57.198.26) by e16.ny.us.ibm.com (146.89.104.203) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 1 Dec 2017 12:15:01 -0500 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vB1HF1AC32440440; Fri, 1 Dec 2017 17:15:01 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9C27DAE043; Fri, 1 Dec 2017 12:15:57 -0500 (EST) Received: from localhost.localdomain (unknown [9.85.195.77]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP id 63E0DAE056; Fri, 1 Dec 2017 12:15:56 -0500 (EST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Date: Fri, 1 Dec 2017 15:14:45 -0200 X-Mailer: git-send-email 2.13.6 X-TM-AS-GCONF: 00 x-cbid: 17120117-0024-0000-0000-000002FB2D0D X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008136; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000243; SDB=6.00953947; UDB=6.00482054; IPR=6.00734022; BA=6.00005726; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00018294; XFM=3.00000015; UTC=2017-12-01 17:15:02 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17120117-0025-0000-0000-00004631937A Message-Id: <20171201171445.11679-1-danielhb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-12-01_04:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1712010197 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v1] qmp.c: system_wakeup: adding RUN_STATE_SUSPENDED check before proceeding X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Henrique Barboza , Markus Armbruster , "Dr . David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The qmp/hmp command 'system_wakeup' is simply a direct call to 'qemu_system_wakeup_request' from vl.c. This function verifies if runstate is SUSPENDED and if the wake up reason is valid before proceeding. However, no error or warning is thrown if any of those pre-requirements isn't met. This leads to situations such as the one described in https://github.com/open-power-host-os/qemu/issues/31, where one can induce the OS to be suspended by using pm-suspend (via dompmsuspend, for example) but for some reason the machine failed to go to the SUSPENDED runstate, staying at runstate RUNNING. The user then tries to wake up the guest using system_wakeup (or dompmwakeup), no error is thrown but nothing happened either because the wake up wasn't fired at all. In the end, the user is left with a guest that is dormant and believing that system_wakeup isn't working. This patch changes qmp_system_wakeup to make the runstate verification before proceeding to call qemu_system_wakeup_request, firing up an error message if the user tries to wake up a machine that isn't in SUSPENDED state. The change isn't made inside qemu_system_wakeup_request because it is used in migration, ACPI and others where this usage might be valid. This patch by no means fixes the situation described above, but it can direct the user/management closer to the real problem. Signed-off-by: Daniel Henrique Barboza CC: Markus Armbruster CC: Dr. David Alan Gilbert --- hmp.c | 4 +++- qmp.c | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/hmp.c b/hmp.c index 35a7041824..2c2326a00e 100644 --- a/hmp.c +++ b/hmp.c @@ -1158,7 +1158,9 @@ void hmp_cont(Monitor *mon, const QDict *qdict) =20 void hmp_system_wakeup(Monitor *mon, const QDict *qdict) { - qmp_system_wakeup(NULL); + Error *err =3D NULL; + qmp_system_wakeup(&err); + hmp_handle_error(mon, &err); } =20 void hmp_nmi(Monitor *mon, const QDict *qdict) diff --git a/qmp.c b/qmp.c index e8c303116a..9b8f99f225 100644 --- a/qmp.c +++ b/qmp.c @@ -206,6 +206,11 @@ void qmp_cont(Error **errp) =20 void qmp_system_wakeup(Error **errp) { + if (!runstate_check(RUN_STATE_SUSPENDED)) { + error_setg(errp, + "Unable to wake up: guest is not in suspended state"); + return; + } qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER); } =20 --=20 2.13.6