1*8d7f2e76SPhilippe Mathieu-Daudé /*
2*8d7f2e76SPhilippe Mathieu-Daudé * Copyright (c) 2020 Oracle and/or its affiliates.
3*8d7f2e76SPhilippe Mathieu-Daudé *
4*8d7f2e76SPhilippe Mathieu-Daudé * This work is licensed under the terms of the GNU GPL, version 2.
5*8d7f2e76SPhilippe Mathieu-Daudé * See the COPYING file in the top-level directory.
6*8d7f2e76SPhilippe Mathieu-Daudé *
7*8d7f2e76SPhilippe Mathieu-Daudé */
8*8d7f2e76SPhilippe Mathieu-Daudé
9*8d7f2e76SPhilippe Mathieu-Daudé #include "qemu/osdep.h"
10*8d7f2e76SPhilippe Mathieu-Daudé #include "sysemu/runstate-action.h"
11*8d7f2e76SPhilippe Mathieu-Daudé #include "sysemu/watchdog.h"
12*8d7f2e76SPhilippe Mathieu-Daudé #include "qemu/config-file.h"
13*8d7f2e76SPhilippe Mathieu-Daudé #include "qapi/error.h"
14*8d7f2e76SPhilippe Mathieu-Daudé #include "qemu/option_int.h"
15*8d7f2e76SPhilippe Mathieu-Daudé
16*8d7f2e76SPhilippe Mathieu-Daudé RebootAction reboot_action = REBOOT_ACTION_RESET;
17*8d7f2e76SPhilippe Mathieu-Daudé ShutdownAction shutdown_action = SHUTDOWN_ACTION_POWEROFF;
18*8d7f2e76SPhilippe Mathieu-Daudé PanicAction panic_action = PANIC_ACTION_SHUTDOWN;
19*8d7f2e76SPhilippe Mathieu-Daudé
20*8d7f2e76SPhilippe Mathieu-Daudé /*
21*8d7f2e76SPhilippe Mathieu-Daudé * Receives actions to be applied for specific guest events
22*8d7f2e76SPhilippe Mathieu-Daudé * and sets the internal state as requested.
23*8d7f2e76SPhilippe Mathieu-Daudé */
qmp_set_action(bool has_reboot,RebootAction reboot,bool has_shutdown,ShutdownAction shutdown,bool has_panic,PanicAction panic,bool has_watchdog,WatchdogAction watchdog,Error ** errp)24*8d7f2e76SPhilippe Mathieu-Daudé void qmp_set_action(bool has_reboot, RebootAction reboot,
25*8d7f2e76SPhilippe Mathieu-Daudé bool has_shutdown, ShutdownAction shutdown,
26*8d7f2e76SPhilippe Mathieu-Daudé bool has_panic, PanicAction panic,
27*8d7f2e76SPhilippe Mathieu-Daudé bool has_watchdog, WatchdogAction watchdog,
28*8d7f2e76SPhilippe Mathieu-Daudé Error **errp)
29*8d7f2e76SPhilippe Mathieu-Daudé {
30*8d7f2e76SPhilippe Mathieu-Daudé if (has_reboot) {
31*8d7f2e76SPhilippe Mathieu-Daudé reboot_action = reboot;
32*8d7f2e76SPhilippe Mathieu-Daudé }
33*8d7f2e76SPhilippe Mathieu-Daudé
34*8d7f2e76SPhilippe Mathieu-Daudé if (has_panic) {
35*8d7f2e76SPhilippe Mathieu-Daudé panic_action = panic;
36*8d7f2e76SPhilippe Mathieu-Daudé }
37*8d7f2e76SPhilippe Mathieu-Daudé
38*8d7f2e76SPhilippe Mathieu-Daudé if (has_watchdog) {
39*8d7f2e76SPhilippe Mathieu-Daudé qmp_watchdog_set_action(watchdog, errp);
40*8d7f2e76SPhilippe Mathieu-Daudé }
41*8d7f2e76SPhilippe Mathieu-Daudé
42*8d7f2e76SPhilippe Mathieu-Daudé /* Process shutdown last, in case the panic action needs to be altered */
43*8d7f2e76SPhilippe Mathieu-Daudé if (has_shutdown) {
44*8d7f2e76SPhilippe Mathieu-Daudé shutdown_action = shutdown;
45*8d7f2e76SPhilippe Mathieu-Daudé }
46*8d7f2e76SPhilippe Mathieu-Daudé }
47