From nobody Thu Apr 18 07:37:24 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; dmarc=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526394500053306.9453716050966; Tue, 15 May 2018 07:28:20 -0700 (PDT) Received: from localhost ([::1]:40587 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIaw7-0004Pt-3E for importer@patchew.org; Tue, 15 May 2018 10:28:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40563) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIaeV-0006Dm-4c for qemu-devel@nongnu.org; Tue, 15 May 2018 10:10:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIaeQ-0005fY-28 for qemu-devel@nongnu.org; Tue, 15 May 2018 10:10:07 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:56188) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fIaeP-0005el-NQ for qemu-devel@nongnu.org; Tue, 15 May 2018 10:10:01 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4FE0gvH000598 for ; Tue, 15 May 2018 10:10:00 -0400 Received: from e16.ny.us.ibm.com (e16.ny.us.ibm.com [129.33.205.206]) by mx0a-001b2d01.pphosted.com with ESMTP id 2j00hght1g-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 15 May 2018 10:09:59 -0400 Received: from localhost by e16.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 15 May 2018 10:09:57 -0400 Received: from b01cxnp23032.gho.pok.ibm.com (9.57.198.27) by e16.ny.us.ibm.com (146.89.104.203) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 15 May 2018 10:09:54 -0400 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4FE9sIF48038048; Tue, 15 May 2018 14:09:54 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D0EB6112051; Tue, 15 May 2018 10:09:56 -0400 (EDT) Received: from heisenbug.br.ibm.com (unknown [9.18.235.77]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id D5AC311204B; Tue, 15 May 2018 10:09:55 -0400 (EDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Date: Tue, 15 May 2018 11:09:43 -0300 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180515140944.15979-1-danielhb@linux.ibm.com> References: <20180515140944.15979-1-danielhb@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18051514-0024-0000-0000-000003593F60 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009029; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000260; SDB=6.01032676; UDB=6.00527960; IPR=6.00811807; MB=3.00021126; MTD=3.00000008; XFM=3.00000015; UTC=2018-05-15 14:09:56 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18051514-0025-0000-0000-000048057662 Message-Id: <20180515140944.15979-2-danielhb@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-05-15_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=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1805150143 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 v6 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+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" 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}} Given that the TargetInfo structure is read-only, adding a new flag to it is backwards compatible. There is no need to deprecate the old TargetInfo format. 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). Reported-by: Balamuruhan S Signed-off-by: Daniel Henrique Barboza --- arch_init.c | 1 + include/sysemu/sysemu.h | 1 + qapi/misc.json | 4 +++- vl.c | 21 +++++++++++++++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/arch_init.c b/arch_init.c index 9597218ced..67bdf27528 100644 --- a/arch_init.c +++ b/arch_init.c @@ -115,6 +115,7 @@ TargetInfo *qmp_query_target(Error **errp) =20 info->arch =3D qapi_enum_parse(&SysEmuTarget_lookup, TARGET_NAME, -1, &error_abort); + info->wakeup_suspend_support =3D !qemu_wakeup_notifier_is_empty(); =20 return info; } diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 544ab77a2b..fbe2a3373e 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/misc.json b/qapi/misc.json index f5988cc0b5..a385d897ae 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -2484,11 +2484,13 @@ # Information describing the QEMU target. # # @arch: the target architecture +# @wakeup-suspend-support: true if the target supports wake up from +# suspend (since 2.13) # # Since: 1.2.0 ## { 'struct': 'TargetInfo', - 'data': { 'arch': 'SysEmuTarget' } } + 'data': { 'arch': 'SysEmuTarget', 'wakeup-suspend-support': 'bool' } } =20 ## # @query-target: diff --git a/vl.c b/vl.c index 3b39bbd7a8..ab6bd7e090 100644 --- a/vl.c +++ b/vl.c @@ -1832,11 +1832,32 @@ void qemu_system_wakeup_enable(WakeupReason reason,= bool enabled) } } =20 +/* The existence of a wake-up notifier is being checked in the function + * qemu_wakeup_notifier_is_empty and it's used in the logic of the + * wakeup-suspend-support flag of QMP 'query-target' command. The idea + * of this flag is to indicate whether the guest supports wake-up from + * suspend (via system_wakeup QMP/HMP call for example), warning the user + * that the guest can't handle both wake-up from suspend and the suspend + * itself via QGA guest-suspend-ram and guest-suspend-hybrid (if it + * can't wake up, it can't be suspended safely). + * + * An assumption is made by the wakeup-suspend-support flag that only the + * guests that can go to RUN_STATE_SUSPENDED and wake up properly would + * be interested in this wakeup_notifier. Adding a wakeup_notifier for + * any other reason will break the logic of the wakeup-suspend-support + * flag and can lead to user/management confusion about the suspend/wake-up + * support of the guest. + */ void qemu_register_wakeup_notifier(Notifier *notifier) { notifier_list_add(&wakeup_notifiers, notifier); } =20 +bool qemu_wakeup_notifier_is_empty(void) +{ + return QLIST_EMPTY(&wakeup_notifiers.notifiers); +} + void qemu_system_killed(int signal, pid_t pid) { shutdown_signal =3D signal; --=20 2.14.3 From nobody Thu Apr 18 07:37:24 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; dmarc=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526394358223248.58179681917886; Tue, 15 May 2018 07:25:58 -0700 (PDT) Received: from localhost ([::1]:40421 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIatp-0002UB-Cx for importer@patchew.org; Tue, 15 May 2018 10:25:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40567) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIaeW-0006EJ-2h for qemu-devel@nongnu.org; Tue, 15 May 2018 10:10:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIaeQ-0005fm-4Z for qemu-devel@nongnu.org; Tue, 15 May 2018 10:10:08 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:59818 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 1fIaeP-0005fH-VE for qemu-devel@nongnu.org; Tue, 15 May 2018 10:10:02 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4FE01aK123810 for ; Tue, 15 May 2018 10:10:01 -0400 Received: from e19.ny.us.ibm.com (e19.ny.us.ibm.com [129.33.205.209]) by mx0b-001b2d01.pphosted.com with ESMTP id 2hyxh5qkwy-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 15 May 2018 10:10:00 -0400 Received: from localhost by e19.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 15 May 2018 10:09:59 -0400 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e19.ny.us.ibm.com (146.89.104.206) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 15 May 2018 10:09:57 -0400 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4FE9uPZ51708002 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 15 May 2018 14:09:56 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 03C50112056; Tue, 15 May 2018 10:09:59 -0400 (EDT) Received: from heisenbug.br.ibm.com (unknown [9.18.235.77]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id 13900112034; Tue, 15 May 2018 10:09:57 -0400 (EDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Date: Tue, 15 May 2018 11:09:44 -0300 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180515140944.15979-1-danielhb@linux.ibm.com> References: <20180515140944.15979-1-danielhb@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18051514-0056-0000-0000-0000044EAAD3 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009029; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000260; SDB=6.01032676; UDB=6.00527959; IPR=6.00811807; MB=3.00021126; MTD=3.00000008; XFM=3.00000015; UTC=2018-05-15 14:09:59 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18051514-0057-0000-0000-00000892BF14 Message-Id: <20180515140944.15979-3-danielhb@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-05-15_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=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1805150143 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 v6 2/2] qga: update guest-suspend-ram and guest-suspend-hybrid descriptions 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+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" This patch updates the descriptions of 'guest-suspend-ram' and 'guest-suspend-hybrid' to mention that both commands relies now on the existence of 'system_wakeup' and also on the proper support for wake up from suspend, retrieved by the 'wakeup-suspend-support' attribute of the 'query-target' QMP command. Reported-by: Balamuruhan S Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michael Roth --- qga/qapi-schema.json | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index 17884c7c70..e3fb8adfce 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -566,8 +566,11 @@ # package installed in the guest. # # IMPORTANT: guest-suspend-ram requires QEMU to support the 'system_wakeup' -# command. Thus, it's *required* to query QEMU for the presence of the -# 'system_wakeup' command before issuing guest-suspend-ram. +# command and the guest to support wake up from suspend. Thus, it's +# *required* to query QEMU for the presence of the 'system_wakeup' command +# and to verify that wake up from suspend is enabled by checking the +# 'wakeup-suspend-support' flag of 'query-target' QMP command, before issu= ing +# guest-suspend-ram. # # This command does NOT return a response on success. There are two options # to check for success: @@ -593,8 +596,11 @@ # This command requires the pm-utils package to be installed in the guest. # # IMPORTANT: guest-suspend-hybrid requires QEMU to support the 'system_wak= eup' -# command. Thus, it's *required* to query QEMU for the presence of the -# 'system_wakeup' command before issuing guest-suspend-hybrid. +# command and the guest to support wake up from suspend. Thus, it's +# *required* to query QEMU for the presence of the 'system_wakeup' command +# and to verify that wake up from suspend is enabled by checking the +# 'wakeup-suspend-support' flag of 'query-target' QMP command, before issu= ing +# guest-suspend-hybrid. # # This command does NOT return a response on success. There are two options # to check for success: --=20 2.14.3