xemu/hw/input
Daniel Henrique Barboza fb06411210 qmp hmp: Make system_wakeup check wake-up support and run state
The qmp/hmp command 'system_wakeup' is simply a direct call to
'qemu_system_wakeup_request' from vl.c. This function verifies if
runstate is SUSPENDED and if the wake up reason is valid before
proceeding. However, no error or warning is thrown if any of those
pre-requirements isn't met. There is no way for the caller to
differentiate between a successful wakeup or an error state caused
when trying to wake up a guest that wasn't suspended.

This means that system_wakeup is silently failing, which can be
considered a bug. Adding error handling isn't an API break in this
case - applications that didn't check the result will remain broken,
the ones that check it will have a chance to deal with it.

Adding to that, the commit before previous created a new QMP API called
query-current-machine, with a new flag called wakeup-suspend-support,
that indicates if the guest has the capability of waking up from suspended
state. Although such guest will never reach SUSPENDED state and erroring
it out in this scenario would suffice, it is more informative for the user
to differentiate between a failure because the guest isn't suspended versus
a failure because the guest does not have support for wake up at all.

All this considered, this patch changes qmp_system_wakeup to check if
the guest is capable of waking up from suspend, and if it is suspended.
After this patch, this is the output of system_wakeup in a guest that
does not have wake-up from suspend support (ppc64):

(qemu) system_wakeup
wake-up from suspend is not supported by this guest
(qemu)

And this is the output of system_wakeup in a x86 guest that has the
support but isn't suspended:

(qemu) system_wakeup
Unable to wake up: guest is not in suspended state
(qemu)

Reported-by: Balamuruhan S <bala24@linux.vnet.ibm.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20181205194701.17836-4-danielhb413@gmail.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2018-12-18 07:55:47 +01:00
..
adb-internal.h Split adb.c into adb.c, adb-mouse.c and adb-kbd.c 2017-12-21 20:11:28 +01:00
adb-kbd.c adb: add property to disable direct reg 3 writes 2018-06-16 16:32:33 +10:00
adb-mouse.c adb: add property to disable direct reg 3 writes 2018-06-16 16:32:33 +10:00
adb.c adb: add property to disable direct reg 3 writes 2018-06-16 16:32:33 +10:00
hid.c hw/input/hid: Add support for several keys. 2017-12-18 17:07:02 +03:00
lm832x.c hw/i2c: Use DeviceClass::realize instead of I2CSlaveClass::init 2018-06-01 15:14:31 +02:00
Makefile.objs hw: make virtio devices configurable via default-configs/ 2018-06-01 15:14:31 +02:00
milkymist-softusb.c milkymist-softusb: Convert sysbus init function to realize function 2018-12-13 13:47:58 +00:00
pckbd.c hw/input/pckbd: Use qemu_log_mask(GUEST_ERROR) instead of fprintf 2018-06-26 17:50:40 +01:00
pl050.c input/pl050: Convert sysbus init function to realize function 2018-12-13 13:47:59 +00:00
ps2.c qmp hmp: Make system_wakeup check wake-up support and run state 2018-12-18 07:55:47 +01:00
pxa2xx_keypad.c Replace all occurances of __FUNCTION__ with __func__ 2018-01-22 09:46:18 +01:00
stellaris_input.c arm: Clean up includes 2016-01-29 15:07:23 +00:00
trace-events hw/input/tsc2005: Convert a fprintf() call to trace events 2018-06-29 15:04:18 +01:00
tsc210x.c Replace all occurances of __FUNCTION__ with __func__ 2018-01-22 09:46:18 +01:00
tsc2005.c hw/input/tsc2005: Convert a fprintf() call to trace events 2018-06-29 15:04:18 +01:00
virtio-input-hid.c hw: convert virtio-input-hid device to keycodemapdb 2018-01-29 09:35:44 +01:00
virtio-input-host.c virtio-input: support absolute axis config in pass-through 2016-04-13 17:26:12 +02:00
virtio-input.c virtio-input: fix eventq batching 2017-03-27 12:14:45 +02:00