aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sysemu/runstate-action.h1
-rw-r--r--qapi/run-state.json16
-rw-r--r--qemu-options.hx3
-rw-r--r--softmmu/runstate-action.c5
-rw-r--r--softmmu/runstate.c18
-rw-r--r--softmmu/vl.c5
6 files changed, 43 insertions, 5 deletions
diff --git a/include/sysemu/runstate-action.h b/include/sysemu/runstate-action.h
index 51a461c..cff45a0 100644
--- a/include/sysemu/runstate-action.h
+++ b/include/sysemu/runstate-action.h
@@ -14,5 +14,6 @@
/* in softmmu/runstate-action.c */
extern RebootAction reboot_action;
extern ShutdownAction shutdown_action;
+extern PanicAction panic_action;
#endif /* RUNSTATE_ACTION_H */
diff --git a/qapi/run-state.json b/qapi/run-state.json
index 25e82d1..1f3b329 100644
--- a/qapi/run-state.json
+++ b/qapi/run-state.json
@@ -354,6 +354,18 @@
'data': [ 'poweroff', 'pause' ] }
##
+# @PanicAction:
+#
+# @none: Continue VM execution
+#
+# @pause: Pause the VM
+#
+# Since: 6.0
+##
+{ 'enum': 'PanicAction',
+ 'data': [ 'poweroff', 'pause', 'none' ] }
+
+##
# @watchdog-set-action:
#
# Set watchdog action
@@ -372,6 +384,8 @@
#
# @shutdown: @ShutdownAction action taken on guest shutdown.
#
+# @panic: @PanicAction action taken on guest panic.
+#
# @watchdog: @WatchdogAction action taken when watchdog timer expires .
#
# Returns: Nothing on success.
@@ -383,12 +397,14 @@
# -> { "execute": "set-action",
# "arguments": { "reboot": "shutdown",
# "shutdown" : "pause",
+# "panic": "pause",
# "watchdog": "inject-nmi" } }
# <- { "return": {} }
##
{ 'command': 'set-action',
'data': { '*reboot': 'RebootAction',
'*shutdown': 'ShutdownAction',
+ '*panic': 'PanicAction',
'*watchdog': 'WatchdogAction' },
'allow-preconfig': true }
diff --git a/qemu-options.hx b/qemu-options.hx
index eb55cd0..94cdfcf 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -3899,6 +3899,8 @@ DEF("action", HAS_ARG, QEMU_OPTION_action,
" action when guest reboots [default=none]\n"
"-action shutdown=poweroff|pause\n"
" action when guest shuts down [default=poweroff]\n"
+ "-action panic=poweroff|pause|none\n"
+ " action when guest panics [default=poweroff]\n"
"-action watchdog=reset|shutdown|poweroff|inject-nmi|pause|debug|none\n"
" action when watchdog fires [default=reset]\n",
QEMU_ARCH_ALL)
@@ -3911,6 +3913,7 @@ SRST
Examples:
+ ``-action panic=none``
``-action reboot=shutdown,shutdown=pause``
``-watchdog i6300esb -action watchdog=pause``
diff --git a/softmmu/runstate-action.c b/softmmu/runstate-action.c
index 44de01a..99ce880 100644
--- a/softmmu/runstate-action.c
+++ b/softmmu/runstate-action.c
@@ -15,6 +15,7 @@
RebootAction reboot_action = REBOOT_ACTION_NONE;
ShutdownAction shutdown_action = SHUTDOWN_ACTION_POWEROFF;
+PanicAction panic_action = PANIC_ACTION_POWEROFF;
/*
* Receives actions to be applied for specific guest events
@@ -30,6 +31,10 @@ void qmp_set_action(bool has_reboot, RebootAction reboot,
reboot_action = reboot;
}
+ if (has_panic) {
+ panic_action = panic;
+ }
+
if (has_watchdog) {
qmp_watchdog_set_action(watchdog, errp);
}
diff --git a/softmmu/runstate.c b/softmmu/runstate.c
index bd0522e..636aab0 100644
--- a/softmmu/runstate.c
+++ b/softmmu/runstate.c
@@ -469,13 +469,23 @@ void qemu_system_guest_panicked(GuestPanicInformation *info)
if (current_cpu) {
current_cpu->crash_occurred = true;
}
- qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE,
- !!info, info);
- vm_stop(RUN_STATE_GUEST_PANICKED);
- if (shutdown_action == SHUTDOWN_ACTION_POWEROFF) {
+ /*
+ * TODO: Currently the available panic actions are: none, pause, and
+ * poweroff, but in principle debug and reset could be supported as well.
+ * Investigate any potential use cases for the unimplemented actions.
+ */
+ if (panic_action == PANIC_ACTION_PAUSE) {
+ qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE,
+ !!info, info);
+ vm_stop(RUN_STATE_GUEST_PANICKED);
+ } else if (panic_action == PANIC_ACTION_POWEROFF) {
qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_POWEROFF,
!!info, info);
+ vm_stop(RUN_STATE_GUEST_PANICKED);
qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_PANIC);
+ } else {
+ qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_RUN,
+ !!info, info);
}
if (info) {
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 6d1a7eb..3921a04 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -490,6 +490,9 @@ static QemuOptsList qemu_action_opts = {
.name = "reboot",
.type = QEMU_OPT_STRING,
},{
+ .name = "panic",
+ .type = QEMU_OPT_STRING,
+ },{
.name = "watchdog",
.type = QEMU_OPT_STRING,
},
@@ -3212,7 +3215,7 @@ void qemu_init(int argc, char **argv, char **envp)
break;
case QEMU_OPTION_no_shutdown:
olist = qemu_find_opts("action");
- qemu_opts_parse_noisily(olist, "shutdown=pause", false);
+ qemu_opts_parse_noisily(olist, "panic=pause,shutdown=pause", false);
break;
case QEMU_OPTION_show_cursor:
warn_report("The -show-cursor option is deprecated. Please "