qemu-e2k/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 maint: Fix macros with broken 'do/while(0); ' usage 2018-01-16 14:54:52 +01:00
allwinner-a10-pit.c
altera_timer.c altera_timer: fix incorrect memset 2017-06-04 18:42:55 +03:00
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 maint: Fix macros with broken 'do/while(0); ' usage 2018-01-16 14:54:52 +01:00
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 hw/timer/exynos4210_mct: Remove unused defines 2017-06-13 14:56:57 +01:00
exynos4210_pwm.c hw/arm/exynos: Convert fprintf to qemu_log_mask/error_report 2017-04-20 17:39:17 +01:00
exynos4210_rtc.c hw/arm/exynos: Convert fprintf to qemu_log_mask/error_report 2017-04-20 17:39:17 +01:00
grlib_gptimer.c timer/grlib_gptimer: Convert sysbus init function to realize function 2018-12-13 13:48:02 +00:00
hpet.c hpet: recover timer offset correctly 2018-01-12 13:22:02 +01:00
i8254_common.c hw/timer/i8254: rename pit_init() -> i8254_pit_init() 2017-12-18 17:07:02 +03:00
i8254.c qdev: use device_class_set_parent_realize/unrealize/reset() 2018-02-05 13:54:38 +01:00
imx_epit.c
imx_gpt.c i.MX: Add i.MX7 GPT variant 2018-02-09 10:40:30 +00:00
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 shutdown: Add source information to SHUTDOWN and RESET 2017-05-23 13:28:17 +02:00
mips_gictimer.c
mss-timer.c maint: Fix macros with broken 'do/while(0); ' usage 2018-01-16 14:54:52 +01:00
omap_gptimer.c Replace all occurances of __FUNCTION__ with __func__ 2018-01-22 09:46:18 +01:00
omap_synctimer.c hw/timer/omap_synctimer.c: Don't use old_mmio 2017-09-21 16:34:27 +01:00
pl031.c migration: pre_save return int 2017-09-27 11:35:59 +01:00
puv3_ost.c timer/puv3_ost: Convert sysbus init function to realize function 2018-12-13 13:48:02 +00:00
pxa2xx_timer.c hw/timer/pxa2xx_timer: replace hw_error() -> qemu_log_mask() 2018-01-11 13:25:38 +00:00
sh_timer.c fix "Missing break in switch" coverity reports 2018-08-23 13:32:50 +02:00
slavio_timer.c sun4m: remove include/hw/sparc/sun4m.h and all references to it 2018-01-09 21:48:20 +00:00
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 xlnx-zynqmp-rtc: Add basic time support 2018-03-02 10:45:34 +00:00