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