qemu/hw/timer
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
..
a9gtimer.c
allwinner-a10-pit.c
altera_timer.c
arm_mptimer.c
arm_timer.c
armv7m_systick.c
aspeed_timer.c error: Fix use of error_prepend() with &error_fatal, &error_abort 2018-10-19 14:51:34 +02:00
cadence_ttc.c
cmsdk-apb-dualtimer.c hw/timer/cmsdk-apb-dualtimer: Add missing 'break' statements 2018-09-25 15:13:24 +01:00
cmsdk-apb-timer.c hw/timer/cmsdk-apb-timer: run or stop timer on writes to RELOAD and VALUE 2018-07-09 14:51:34 +01:00
digic-timer.c hw/digic: Add trailing '\n' to qemu_log() calls 2018-06-08 13:15:33 +01:00
ds1338.c
etraxfs_timer.c timer/etraxfs_timer: Convert sysbus init function to realize function 2018-12-13 13:48:00 +00:00
exynos4210_mct.c
exynos4210_pwm.c
exynos4210_rtc.c
grlib_gptimer.c timer/grlib_gptimer: Convert sysbus init function to realize function 2018-12-13 13:48:02 +00:00
hpet.c
i8254_common.c
i8254.c
imx_epit.c
imx_gpt.c
lm32_timer.c
m41t80.c hw/timer: Add basic M41T80 emulation 2018-07-03 09:56:52 +10:00
m48t59-internal.h hw/timer/mt48t59: Fix bit-rotten NVRAM_PRINTF format strings 2018-05-20 08:50:16 +03:00
m48t59-isa.c
m48t59.c hw/timer/m48t59: Move away from old_mmio accessors 2018-08-20 11:24:33 +01:00
Makefile.objs hw/timer/cmsdk-apb-dualtimer: Implement CMSDK dual timer module 2018-08-24 13:17:41 +01:00
mc146818rtc.c qmp hmp: Make system_wakeup check wake-up support and run state 2018-12-18 07:55:47 +01:00
milkymist-sysctl.c
mips_gictimer.c
mss-timer.c
omap_gptimer.c
omap_synctimer.c
pl031.c
puv3_ost.c timer/puv3_ost: Convert sysbus init function to realize function 2018-12-13 13:48:02 +00:00
pxa2xx_timer.c
sh_timer.c fix "Missing break in switch" coverity reports 2018-08-23 13:32:50 +02:00
slavio_timer.c
stm32f2xx_timer.c hw/arm/stm32f205: Fix the UART and Timer region size 2018-11-19 15:29:08 +00:00
sun4v-rtc.c hw/timer/sun4v-rtc: Fix tracing at sun4v_rtc_write() 2018-12-11 15:45:22 -02:00
trace-events hw/timer/sun4v-rtc: Convert from DPRINTF() macro to trace events 2018-10-24 06:44:59 -03:00
twl92230.c vmstate: constify VMStateField 2018-11-27 15:35:15 +01:00
xilinx_timer.c
xlnx-zynqmp-rtc.c