qmp: 'wakeup-suspend-support' in query-target
v2 cover qmp: 'wakeup-suspend-support' in query-target
v2:
- changed the approach based on v1 discussions: instead of a new API, add the required flag in QMP query-target
- dropped patch 2 since query-target does not have an HMP counterpart
- previous version link:
https://lists.gnu.org/archive/html/qemu-devel/2017-12/msg00889.html
Daniel Henrique Barboza (2):
qmp: adding 'wakeup-suspend-support' in query-target
qga: update guest-suspend-ram and guest-suspend-hybrid descriptions
arch_init.c | 1 + include/sysemu/sysemu.h | 1 + qapi-schema.json | 3 ++- qga/qapi-schema.json | 14 ++++++++++---- vl.c | 5 +++++ 5 files changed, 19 insertions(+), 5 deletions(-)
Signature · 1 line
2.13.6
PATCH v2 1/2 qmp: adding 'wakeup-suspend-support' in query-target
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).
--- arch_init.c | 1 + include/sysemu/sysemu.h | 1 + qapi-schema.json | 3 ++- vl.c | 5 +++++ 4 files changed, 9 insertions(+), 1 deletion(-)
arch_init.c +1 -0
@@ -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; }
include/sysemu/sysemu.h +1 -0
@@ -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);
qapi-schema.json +2 -1
@@ -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:
vl.c +5 -0
@@ -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;
Signature · 1 line
2.13.6
Re: [Qemu-devel] [PATCH v2 1/2] qmp: adding 'wakeup-suspend-support' in query-target
Quoted 9 lines · Daniel Henrique Barboza
When issuing the qmp/hmp '
system_wakeup' command, what happens in a nutshell is:-
qmp_system_wakeup_requestset runstate to RUNNING, sets awakeup_reasonand notify the event
- in themain_loop, all vcpus are paused, a system reset is issued, all subscribers ofwakeup_notifiersreceives a notification, vcpus are then resumed and the wake up QAPI event is fired
...
Quoted 8 lines
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 <[email protected]>---
Only an interface review:
qapi-schema.json line 2391
Quoted 13 lines
arch_init.c | 1 + include/sysemu/sysemu.h | 1 + qapi-schema.json | 3 ++- vl.c | 5 +++++ 4 files changed, 9 insertions(+), 1 deletion(-)+++
b/qapi-schema.jsonqapi-schema.json +1
-0@@ -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
Missing a '(since 2.12)' notation.
qapi-schema.json line 2396
Quoted 6 lines
qapi-schema.json +1
-1# # Since: 1.2.0 ## { 'struct': 'TargetInfo', - 'data': { 'arch': 'str' } } + 'data': { 'arch': 'str', 'wakeup-suspend-support': 'bool' } }
The struct is output-only, so adding the new field unconditionally is backwards-compatible.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [Qemu-devel] [PATCH v2 1/2] qmp: adding 'wakeup-suspend-support' in query-target
Quoted 26 lines · Eric Blake
Quoted 9 lines · Daniel Henrique Barboza
When issuing the qmp/hmp '
system_wakeup' command, what happens in a nutshell is:-
qmp_system_wakeup_requestset runstate to RUNNING, sets awakeup_reasonand notify the event
- in themain_loop, all vcpus are paused, a system reset is issued, all subscribers ofwakeup_notifiersreceives a notification, vcpus are then resumed and the wake up QAPI event is fired...
Quoted 7 lines
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 <[email protected]>---
Only an interface review:
Quoted 6 lines
arch_init.c | 1 + include/sysemu/sysemu.h | 1 + qapi-schema.json | 3 ++- vl.c | 5 +++++ 4 files changed, 9 insertions(+), 1 deletion(-)
Quoted 7 lines
qapi-schema.json line 2391
Quoted 6 lines
+++
b/qapi-schema.jsonqapi-schema.json +1
-0@@ -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 suspendMissing a '(since 2.12)' notation.
TargetInfo is marked as "Since 1.2.0". Should I add the 2.12.0 notation to the new parameter or change the 1.2.0 notation of TargetInfo?
Quoted 10 lines
qapi-schema.json line 2396
Quoted 7 lines
qapi-schema.json +1
-1# # Since: 1.2.0 ## { 'struct': 'TargetInfo', - 'data': { 'arch': 'str' } } + 'data': { 'arch': 'str', 'wakeup-suspend-support': 'bool' } }The struct is output-only, so adding the new field unconditionally is backwards-compatible.
I believe it's worth adding this info in the commit message.
Thanks,
Daniel
Re: [Qemu-devel] [PATCH v2 1/2] qmp: adding 'wakeup-suspend-support' in query-target
Quoted 18 lines · Daniel Henrique Barboza
Quoted 10 lines
Quoted 7 lines
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 <[email protected]>---
Only an interface review:
Quoted 7 lines
Quoted 6 lines
qapi-schema.json +1
-0@@ -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 fromsuspend
Missing a '(since 2.12)' notation.
Quoted 3 lines
TargetInfo is marked as "Since 1.2.0". Should I add the 2.12.0 notation to the
new parameter or change the 1.2.0 notation of TargetInfo?
Just on the new field, as in:
##
# @TargetInfo:
#
# 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 2.12)
#
# Since: 1.2.0
##
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH v2 2/2 qga: update guest-suspend-ram and guest-suspend-hybrid descriptions
In reply to Daniel Henrique BarbozaThis 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.
--- qga/qapi-schema.json | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
qga/qapi-schema.json +10 -4
@@ -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 issuing +# 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_wakeup' -# 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 issuing +# guest-suspend-hybrid. # # This command does NOT return a response on success. There are two options # to check for success:
Signature · 1 line
2.13.6