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>
This commit is contained in:
parent
2a5ad60b54
commit
c753e8e725
|
@ -14,5 +14,6 @@
|
||||||
/* in softmmu/runstate-action.c */
|
/* in softmmu/runstate-action.c */
|
||||||
extern RebootAction reboot_action;
|
extern RebootAction reboot_action;
|
||||||
extern ShutdownAction shutdown_action;
|
extern ShutdownAction shutdown_action;
|
||||||
|
extern PanicAction panic_action;
|
||||||
|
|
||||||
#endif /* RUNSTATE_ACTION_H */
|
#endif /* RUNSTATE_ACTION_H */
|
||||||
|
|
|
@ -353,6 +353,18 @@
|
||||||
{ 'enum': 'ShutdownAction',
|
{ 'enum': 'ShutdownAction',
|
||||||
'data': [ 'poweroff', 'pause' ] }
|
'data': [ 'poweroff', 'pause' ] }
|
||||||
|
|
||||||
|
##
|
||||||
|
# @PanicAction:
|
||||||
|
#
|
||||||
|
# @none: Continue VM execution
|
||||||
|
#
|
||||||
|
# @pause: Pause the VM
|
||||||
|
#
|
||||||
|
# Since: 6.0
|
||||||
|
##
|
||||||
|
{ 'enum': 'PanicAction',
|
||||||
|
'data': [ 'poweroff', 'pause', 'none' ] }
|
||||||
|
|
||||||
##
|
##
|
||||||
# @watchdog-set-action:
|
# @watchdog-set-action:
|
||||||
#
|
#
|
||||||
|
@ -372,6 +384,8 @@
|
||||||
#
|
#
|
||||||
# @shutdown: @ShutdownAction action taken on guest shutdown.
|
# @shutdown: @ShutdownAction action taken on guest shutdown.
|
||||||
#
|
#
|
||||||
|
# @panic: @PanicAction action taken on guest panic.
|
||||||
|
#
|
||||||
# @watchdog: @WatchdogAction action taken when watchdog timer expires .
|
# @watchdog: @WatchdogAction action taken when watchdog timer expires .
|
||||||
#
|
#
|
||||||
# Returns: Nothing on success.
|
# Returns: Nothing on success.
|
||||||
|
@ -383,12 +397,14 @@
|
||||||
# -> { "execute": "set-action",
|
# -> { "execute": "set-action",
|
||||||
# "arguments": { "reboot": "shutdown",
|
# "arguments": { "reboot": "shutdown",
|
||||||
# "shutdown" : "pause",
|
# "shutdown" : "pause",
|
||||||
|
# "panic": "pause",
|
||||||
# "watchdog": "inject-nmi" } }
|
# "watchdog": "inject-nmi" } }
|
||||||
# <- { "return": {} }
|
# <- { "return": {} }
|
||||||
##
|
##
|
||||||
{ 'command': 'set-action',
|
{ 'command': 'set-action',
|
||||||
'data': { '*reboot': 'RebootAction',
|
'data': { '*reboot': 'RebootAction',
|
||||||
'*shutdown': 'ShutdownAction',
|
'*shutdown': 'ShutdownAction',
|
||||||
|
'*panic': 'PanicAction',
|
||||||
'*watchdog': 'WatchdogAction' },
|
'*watchdog': 'WatchdogAction' },
|
||||||
'allow-preconfig': true }
|
'allow-preconfig': true }
|
||||||
|
|
||||||
|
|
|
@ -3899,6 +3899,8 @@ DEF("action", HAS_ARG, QEMU_OPTION_action,
|
||||||
" action when guest reboots [default=none]\n"
|
" action when guest reboots [default=none]\n"
|
||||||
"-action shutdown=poweroff|pause\n"
|
"-action shutdown=poweroff|pause\n"
|
||||||
" action when guest shuts down [default=poweroff]\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 watchdog=reset|shutdown|poweroff|inject-nmi|pause|debug|none\n"
|
||||||
" action when watchdog fires [default=reset]\n",
|
" action when watchdog fires [default=reset]\n",
|
||||||
QEMU_ARCH_ALL)
|
QEMU_ARCH_ALL)
|
||||||
|
@ -3911,6 +3913,7 @@ SRST
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
|
``-action panic=none``
|
||||||
``-action reboot=shutdown,shutdown=pause``
|
``-action reboot=shutdown,shutdown=pause``
|
||||||
``-watchdog i6300esb -action watchdog=pause``
|
``-watchdog i6300esb -action watchdog=pause``
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
RebootAction reboot_action = REBOOT_ACTION_NONE;
|
RebootAction reboot_action = REBOOT_ACTION_NONE;
|
||||||
ShutdownAction shutdown_action = SHUTDOWN_ACTION_POWEROFF;
|
ShutdownAction shutdown_action = SHUTDOWN_ACTION_POWEROFF;
|
||||||
|
PanicAction panic_action = PANIC_ACTION_POWEROFF;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Receives actions to be applied for specific guest events
|
* 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;
|
reboot_action = reboot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (has_panic) {
|
||||||
|
panic_action = panic;
|
||||||
|
}
|
||||||
|
|
||||||
if (has_watchdog) {
|
if (has_watchdog) {
|
||||||
qmp_watchdog_set_action(watchdog, errp);
|
qmp_watchdog_set_action(watchdog, errp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -469,13 +469,23 @@ void qemu_system_guest_panicked(GuestPanicInformation *info)
|
||||||
if (current_cpu) {
|
if (current_cpu) {
|
||||||
current_cpu->crash_occurred = true;
|
current_cpu->crash_occurred = true;
|
||||||
}
|
}
|
||||||
qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE,
|
/*
|
||||||
!!info, info);
|
* TODO: Currently the available panic actions are: none, pause, and
|
||||||
vm_stop(RUN_STATE_GUEST_PANICKED);
|
* poweroff, but in principle debug and reset could be supported as well.
|
||||||
if (shutdown_action == SHUTDOWN_ACTION_POWEROFF) {
|
* 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,
|
qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_POWEROFF,
|
||||||
!!info, info);
|
!!info, info);
|
||||||
|
vm_stop(RUN_STATE_GUEST_PANICKED);
|
||||||
qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_PANIC);
|
qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_PANIC);
|
||||||
|
} else {
|
||||||
|
qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_RUN,
|
||||||
|
!!info, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info) {
|
if (info) {
|
||||||
|
|
|
@ -489,6 +489,9 @@ static QemuOptsList qemu_action_opts = {
|
||||||
},{
|
},{
|
||||||
.name = "reboot",
|
.name = "reboot",
|
||||||
.type = QEMU_OPT_STRING,
|
.type = QEMU_OPT_STRING,
|
||||||
|
},{
|
||||||
|
.name = "panic",
|
||||||
|
.type = QEMU_OPT_STRING,
|
||||||
},{
|
},{
|
||||||
.name = "watchdog",
|
.name = "watchdog",
|
||||||
.type = QEMU_OPT_STRING,
|
.type = QEMU_OPT_STRING,
|
||||||
|
@ -3212,7 +3215,7 @@ void qemu_init(int argc, char **argv, char **envp)
|
||||||
break;
|
break;
|
||||||
case QEMU_OPTION_no_shutdown:
|
case QEMU_OPTION_no_shutdown:
|
||||||
olist = qemu_find_opts("action");
|
olist = qemu_find_opts("action");
|
||||||
qemu_opts_parse_noisily(olist, "shutdown=pause", false);
|
qemu_opts_parse_noisily(olist, "panic=pause,shutdown=pause", false);
|
||||||
break;
|
break;
|
||||||
case QEMU_OPTION_show_cursor:
|
case QEMU_OPTION_show_cursor:
|
||||||
warn_report("The -show-cursor option is deprecated. Please "
|
warn_report("The -show-cursor option is deprecated. Please "
|
||||||
|
|
Loading…
Reference in New Issue