aboutsummaryrefslogtreecommitdiff
path: root/softmmu
diff options
context:
space:
mode:
authorAlejandro Jimenez <alejandro.j.jimenez@oracle.com>2020-12-11 17:31:52 -0500
committerPaolo Bonzini <pbonzini@redhat.com>2020-12-15 12:51:58 -0500
commitc753e8e72548493d2a110c0482c4a987a733b033 (patch)
treec8830e44baac83400639be1e8ea4bfbd39d91f7b /softmmu
parent2a5ad60b5406daca3658f2a6735318615ee6a116 (diff)
vl: Add option to avoid stopping VM upon guest panic
The current default action of pausing a guest after a panic event is received leaves the responsibility to resume guest execution to the management layer. The reasons for this behavior are discussed here: https://lore.kernel.org/qemu-devel/52148F88.5000509@redhat.com/ However, in instances like the case of older guests (Linux and Windows) using a pvpanic device but missing support for the PVPANIC_CRASHLOADED event, and Windows guests using the hv-crash enlightenment, it is desirable to allow the guests to continue running after sending a PVPANIC_PANICKED event. This allows such guests to proceed to capture a crash dump and automatically reboot without intervention of a management layer. Add an option to avoid stopping a VM after a panic event is received, by passing: -action panic=none in the command line arguments, or during runtime by using an upcoming QMP command. Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com> Message-Id: <1607705564-26264-3-git-send-email-alejandro.j.jimenez@oracle.com> [Do not fix panic action in the variable, instead modify -no-shutdown. - Paolo] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'softmmu')
-rw-r--r--softmmu/runstate-action.c5
-rw-r--r--softmmu/runstate.c18
-rw-r--r--softmmu/vl.c5
3 files changed, 23 insertions, 5 deletions
diff --git a/softmmu/runstate-action.c b/softmmu/runstate-action.c
index 44de01adaf..99ce880886 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 bd0522ed9e..636aab0add 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 6d1a7ebb08..3921a04f77 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 "