qemu-e2k/hw/i386
Daniel Henrique Barboza 46ea94ca9c qmp: query-current-machine with wakeup-suspend-support
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, only the ACPI machines via acpi_pm1_cnt_init and xen_hvm_init
have wake-up from suspend support.

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 creates a new API called query-current-machine [1], that holds
a new flag called 'wakeup-suspend-support' that indicates if the guest
supports wake up from suspend via system_wakeup. The machine is considered
to implement wake-up support if a call to a new 'qemu_register_wakeup_support'
is made during its init, as it is now being done inside acpi_pm1_cnt_init
and xen_hvm_init. This allows for any other machine type to declare wake-up
support regardless of ACPI state or wakeup_notifiers subscription, making easier
for newer implementations that might have their own mechanisms in the future.

This is the expected output of query-current-machine when running a x86
guest:

{"execute" : "query-current-machine"}
{"return": {"wakeup-suspend-support": true}}

Running the same x86 guest, but with the --no-acpi option:

{"execute" : "query-current-machine"}
{"return": {"wakeup-suspend-support": false}}

This is the output when running a pseries guest:

{"execute" : "query-current-machine"}
{"return": {"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).

[1] the decision of creating the query-current-machine API is based
on discussions in the QEMU mailing list where it was decided that
query-target wasn't a proper place to store the wake-up flag, neither
was query-machines because this isn't a static property of the
machine object. This new API can then be used to store other
dynamic machine properties that are scattered around the code
ATM. More info at:
https://lists.gnu.org/archive/html/qemu-devel/2018-05/msg04235.html

Reported-by: Balamuruhan S <bala24@linux.vnet.ibm.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20181205194701.17836-2-danielhb413@gmail.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2018-12-18 07:55:47 +01:00
..
kvm kvmclock: run KVM_KVMCLOCK_CTRL ioctl in vcpu thread 2018-10-02 19:09:13 +02:00
xen qmp: query-current-machine with wakeup-suspend-support 2018-12-18 07:55:47 +01:00
Makefile.objs hw/i386: make IOMMUs configurable via default-configs/ 2018-03-12 16:12:46 +01:00
acpi-build.c x86_iommu/amd: Enable Guest virtual APIC support 2018-11-05 13:24:02 -05:00
acpi-build.h Use scripts/clean-includes to drop redundant qemu/typedefs.h 2016-03-22 22:20:16 +01:00
amd_iommu.c x86_iommu/amd: Add interrupt remap support when VAPIC is enabled 2018-11-05 13:24:02 -05:00
amd_iommu.h x86_iommu/amd: Enable Guest virtual APIC support 2018-11-05 13:24:02 -05:00
intel_iommu.c x86_iommu: move vtd_generate_msi_message in common file 2018-11-05 13:24:02 -05:00
intel_iommu_internal.h intel-iommu: Extend address width to 48 bits 2018-01-18 21:52:38 +02:00
kvmvapic.c target: Do not include "exec/exec-all.h" if it is not necessary 2018-06-01 14:15:10 +02:00
multiboot.c hw/i386/multiboot.c: Don't use load_image() 2018-12-14 13:30:51 +00:00
multiboot.h refer to FWCfgState explicitly 2013-06-02 18:14:02 +03:00
pc.c hw/i386/pc.c: Don't use load_image() 2018-12-14 13:30:51 +00:00
pc_piix.c pc: Use default_machine_opts to set suppress_vmdesc 2018-12-11 15:45:22 -02:00
pc_q35.c q35/440fx/arm/spapr: Add QEMU 4.0 machine type 2018-12-11 15:45:22 -02:00
pc_sysfw.c hw/i386: Use the IEC binary prefix definitions 2018-07-02 15:41:16 +02:00
trace-events x86_iommu/amd: Add interrupt remap support when VAPIC is enabled 2018-11-05 13:24:02 -05:00
vmmouse.c hw/input/i8042: Extract declarations from i386/pc.h into input/i8042.h 2018-03-12 16:12:48 +01:00
vmport.c hw/input/i8042: Extract declarations from i386/pc.h into input/i8042.h 2018-03-12 16:12:48 +01:00
x86-iommu.c x86_iommu: move vtd_generate_msi_message in common file 2018-11-05 13:24:02 -05:00