From patchwork Wed Dec 6 12:02:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 10095727 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 1C3DE60210 for ; Wed, 6 Dec 2017 12:03:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CC1E29CDB for ; Wed, 6 Dec 2017 12:03:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0083F29CE0; Wed, 6 Dec 2017 12:03:46 +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 6246129CDB for ; Wed, 6 Dec 2017 12:03:46 +0000 (UTC) Received: from localhost ([::1]:55114 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eMYQT-0006Qr-NE for patchwork-qemu-devel@patchwork.kernel.org; Wed, 06 Dec 2017 07:03:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55745) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eMYPV-0005qM-3v for qemu-devel@nongnu.org; Wed, 06 Dec 2017 07:02:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eMYPQ-000525-3W for qemu-devel@nongnu.org; Wed, 06 Dec 2017 07:02:45 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:39466 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 1eMYPP-000512-Te for qemu-devel@nongnu.org; Wed, 06 Dec 2017 07:02:40 -0500 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vB6BxJou120829 for ; Wed, 6 Dec 2017 07:02:37 -0500 Received: from e19.ny.us.ibm.com (e19.ny.us.ibm.com [129.33.205.209]) by mx0b-001b2d01.pphosted.com with ESMTP id 2epcha2y3v-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 06 Dec 2017 07:02:35 -0500 Received: from localhost by e19.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 6 Dec 2017 07:02:35 -0500 Received: from b01cxnp22035.gho.pok.ibm.com (9.57.198.25) by e19.ny.us.ibm.com (146.89.104.206) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 6 Dec 2017 07:02:32 -0500 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vB6C2WYJ48824532; Wed, 6 Dec 2017 12:02:32 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B192FAC03A; Wed, 6 Dec 2017 07:03:31 -0500 (EST) Received: from localhost.localdomain (unknown [9.80.229.1]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP id 450FFAC040; Wed, 6 Dec 2017 07:03:30 -0500 (EST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Date: Wed, 6 Dec 2017 10:02:15 -0200 X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171206120217.11392-1-danielhb@linux.vnet.ibm.com> References: <20171206120217.11392-1-danielhb@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17120612-0056-0000-0000-000003F48BFA X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008159; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000244; SDB=6.00956234; UDB=6.00483355; IPR=6.00736271; BA=6.00005729; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00018380; XFM=3.00000015; UTC=2017-12-06 12:02:34 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17120612-0057-0000-0000-0000082BC1F2 Message-Id: <20171206120217.11392-2-danielhb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-12-06_05:, , 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-1712060175 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 1/3] qmp: introduce query-wakeup-from-suspend-support command 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: mdroth@linux.vnet.ibm.com, Daniel Henrique Barboza , armbru@redhat.com, dgilbert@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP When issuing the qmp/hmp 'system_wakeup' command, what happens in a nutshell is: - qmp_system_wakeup_request set runstate to RUNNING, sets a wakeup_reason and notify the event - in the main_loop, all vcpus are paused, a system reset is issued, all subscribers of wakeup_notifiers receives a notification, vcpus are then resumed and the wake up QAPI event is fired Note that this procedure alone doesn't ensure that the guest will awake from SUSPENDED state - the subscribers of the wake up event must take action to resume the guest, otherwise the guest will simply reboot. At this moment there are only two subscribers of the wake up event: one in hw/acpi/core.c and another one in hw/i386/xen/xen-hvm.c. This means that system_wakeup does not work as intended with other architectures. However, only the presence of 'system_wakeup' is required for QGA to support 'guest-suspend-ram' and 'guest-suspend-hybrid' at this moment. This means that the user/management will expect to suspend the guest using one of those suspend commands and then resume execution using system_wakeup, regardless of the support offered in system_wakeup in the first place. This patch implements a new QMP command called 'query-wakeup-from-suspend-support' that allows the caller to query if the guest supports wake up from suspend via system_wakeup. It goes over the subscribers of the wake up event and, if it's empty, it assumes that the guest does not support wake up from suspend (and thus, pm-suspend itself). This is the expected output of the command when running a x86 guest: {"execute" : "query-wakeup-from-suspend-support"} {"return": {"enabled": true}} This is the output when running a pseries guest: {"execute" : "query-wakeup-from-suspend-support"} {"return": {"enabled": false}} With this extra tool, management can avoid situations where a guest that does not have proper suspend/wake capabilities ends up in inconsistent state (e.g. https://github.com/open-power-host-os/qemu/issues/31). Signed-off-by: Daniel Henrique Barboza --- include/sysemu/sysemu.h | 1 + qapi-schema.json | 23 +++++++++++++++++++++++ qmp.c | 9 +++++++++ vl.c | 5 +++++ 4 files changed, 38 insertions(+) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index c083869fcf..70b94dcda5 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -69,6 +69,7 @@ typedef enum WakeupReason { void qemu_system_reset_request(ShutdownCause reason); void qemu_system_suspend_request(void); void qemu_register_suspend_notifier(Notifier *notifier); +bool qemu_wakeup_notifier_is_empty(void); void qemu_system_wakeup_request(WakeupReason reason); void qemu_system_wakeup_enable(WakeupReason reason, bool enabled); void qemu_register_wakeup_notifier(Notifier *notifier); diff --git a/qapi-schema.json b/qapi-schema.json index 18457954a8..cf5bf327bd 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3200,3 +3200,26 @@ # Since: 2.11 ## { 'command': 'watchdog-set-action', 'data' : {'action': 'WatchdogAction'} } + +## +# @WakeupSuspendSupportInfo: +# +# Information about the wake up from suspend support of the VM. +# +# @enabled: true if the target supports wake up from suspend +# +# Since: 2.12 +## +{ 'struct': 'WakeupSuspendSupportInfo', + 'data': { 'enabled': 'bool' } } + +## +# @query-wakeup-from-suspend-support: +# +# Return information about the wake up from suspend support of the VM. +# +# Returns: WakeupSuspendSupportInfo +# +# Since: 2.12 +## +{ 'command': 'query-wakeup-from-suspend-support', 'returns': 'WakeupSuspendSupportInfo' } diff --git a/qmp.c b/qmp.c index e8c303116a..26fefbbe88 100644 --- a/qmp.c +++ b/qmp.c @@ -722,3 +722,12 @@ MemoryInfo *qmp_query_memory_size_summary(Error **errp) return mem_info; } + +WakeupSuspendSupportInfo *qmp_query_wakeup_from_suspend_support(Error **errp) +{ + WakeupSuspendSupportInfo *info = g_malloc0(sizeof(*info)); + + info->enabled = !qemu_wakeup_notifier_is_empty(); + + return info; +} diff --git a/vl.c b/vl.c index 1ad1c04637..b07aa6f098 100644 --- a/vl.c +++ b/vl.c @@ -1889,6 +1889,11 @@ void qemu_register_wakeup_notifier(Notifier *notifier) notifier_list_add(&wakeup_notifiers, notifier); } +bool qemu_wakeup_notifier_is_empty(void) +{ + return QLIST_EMPTY(&wakeup_notifiers.notifiers); +} + void qemu_system_killed(int signal, pid_t pid) { shutdown_signal = signal;