From patchwork Tue Jan 2 17:06:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 10141079 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 24DDD601A1 for ; Tue, 2 Jan 2018 17:09:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0FAFF2860F for ; Tue, 2 Jan 2018 17:09:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0497228C74; Tue, 2 Jan 2018 17:09:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 67EB12860F for ; Tue, 2 Jan 2018 17:09:18 +0000 (UTC) Received: from localhost ([::1]:48958 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWQ3x-0000UM-GA for patchwork-qemu-devel@patchwork.kernel.org; Tue, 02 Jan 2018 12:09:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59325) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWQ1q-0006u5-Au for qemu-devel@nongnu.org; Tue, 02 Jan 2018 12:07:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eWQ1m-0000cr-8L for qemu-devel@nongnu.org; Tue, 02 Jan 2018 12:07:06 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:33332 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 1eWQ1m-0000c7-2W for qemu-devel@nongnu.org; Tue, 02 Jan 2018 12:07:02 -0500 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w02H3fHN082111 for ; Tue, 2 Jan 2018 12:07:01 -0500 Received: from e13.ny.us.ibm.com (e13.ny.us.ibm.com [129.33.205.203]) by mx0a-001b2d01.pphosted.com with ESMTP id 2f8700rsnp-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 02 Jan 2018 12:07:00 -0500 Received: from localhost by e13.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 2 Jan 2018 12:07:00 -0500 Received: from b01cxnp23032.gho.pok.ibm.com (9.57.198.27) by e13.ny.us.ibm.com (146.89.104.200) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 2 Jan 2018 12:06:58 -0500 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w02H6we142598468; Tue, 2 Jan 2018 17:06:58 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 27B22AE04B; Tue, 2 Jan 2018 12:08:06 -0500 (EST) Received: from localhost.localdomain (unknown [9.80.207.143]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP id E8516AE03B; Tue, 2 Jan 2018 12:08:04 -0500 (EST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Date: Tue, 2 Jan 2018 15:06:45 -0200 X-Mailer: git-send-email 2.13.6 X-TM-AS-GCONF: 00 x-cbid: 18010217-0008-0000-0000-000002B7AF32 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008306; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000244; SDB=6.00969239; UDB=6.00490777; IPR=6.00749214; BA=6.00005764; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00018832; XFM=3.00000015; UTC=2018-01-02 17:06:59 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18010217-0009-0000-0000-000037C2E790 Message-Id: <20180102170645.5877-1-danielhb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-01-02_13:, , 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=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1801020246 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 RESEND 1/1] 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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) void hmp_system_wakeup(Monitor *mon, const QDict *qdict) { - qmp_system_wakeup(NULL); + Error *err = NULL; + qmp_system_wakeup(&err); + hmp_handle_error(mon, &err); } void hmp_nmi(Monitor *mon, const QDict *qdict) diff --git a/qmp.c b/qmp.c index 52cfd2d81c..d0be43fa1a 100644 --- a/qmp.c +++ b/qmp.c @@ -201,6 +201,11 @@ void qmp_cont(Error **errp) 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); }