From patchwork Tue Jan 2 17:09:35 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: 854656 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zB0x31Ptbz9s7g for ; Wed, 3 Jan 2018 04:12:23 +1100 (AEDT) Received: from localhost ([::1]:49023 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWQ6v-0002X1-An for incoming@patchwork.ozlabs.org; Tue, 02 Jan 2018 12:12:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33548) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWQ4e-000159-7s for qemu-devel@nongnu.org; Tue, 02 Jan 2018 12:10:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eWQ4a-0002gI-59 for qemu-devel@nongnu.org; Tue, 02 Jan 2018 12:10:00 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:33902) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eWQ4Z-0002fY-Tk for qemu-devel@nongnu.org; Tue, 02 Jan 2018 12:09:56 -0500 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w02H9dVu086532 for ; Tue, 2 Jan 2018 12:09:54 -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 2f8ddn1ybk-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 02 Jan 2018 12:09:54 -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:09:53 -0500 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) 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:09:50 -0500 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w02H9nAJ41222164; Tue, 2 Jan 2018 17:09:49 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BAB0B112034; Tue, 2 Jan 2018 12:08:02 -0500 (EST) Received: from localhost.localdomain (unknown [9.80.207.143]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id 814EB112047; Tue, 2 Jan 2018 12:08:01 -0500 (EST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Date: Tue, 2 Jan 2018 15:09:35 -0200 X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180102170936.6150-1-danielhb@linux.vnet.ibm.com> References: <20180102170936.6150-1-danielhb@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18010217-0008-0000-0000-000002B7AF5F 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.00969241; UDB=6.00490777; IPR=6.00749215; 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:09:51 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18010217-0009-0000-0000-000037C2E8CB Message-Id: <20180102170936.6150-2-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-1801020247 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v2 1/2] qmp: adding 'wakeup-suspend-support' in query-target 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 , mdroth@linux.vnet.ibm.com, dgilbert@redhat.com, armbru@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 adds a new flag called 'wakeup-suspend-support' in TargetInfo 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 query-target when running a x86 guest: {"execute" : "query-target"} {"return": {"arch": "x86_64", "wakeup-suspend-support": true}} This is the output when running a pseries guest: {"execute" : "query-target"} {"return": {"arch": "ppc64", "wakeup-suspend-support": 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 --- arch_init.c | 1 + include/sysemu/sysemu.h | 1 + qapi-schema.json | 3 ++- vl.c | 5 +++++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/arch_init.c b/arch_init.c index a0b8ed6167..9c5c519d9d 100644 --- a/arch_init.c +++ b/arch_init.c @@ -109,6 +109,7 @@ TargetInfo *qmp_query_target(Error **errp) TargetInfo *info = g_malloc0(sizeof(*info)); info->arch = g_strdup(TARGET_NAME); + info->wakeup_suspend_support = !qemu_wakeup_notifier_is_empty(); return info; } diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 31612caf10..b15374e0b8 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 5c06745c79..6ed741d00b 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -2388,11 +2388,12 @@ # Information describing the QEMU target. # # @arch: the target architecture (eg "x86_64", "i386", etc) +# @wakeup-suspend-support: true if the target supports wake up from suspend # # Since: 1.2.0 ## { 'struct': 'TargetInfo', - 'data': { 'arch': 'str' } } + 'data': { 'arch': 'str', 'wakeup-suspend-support': 'bool' } } ## # @query-target: diff --git a/vl.c b/vl.c index d3a5c5d021..871c1f9bd1 100644 --- a/vl.c +++ b/vl.c @@ -1844,6 +1844,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;