Skip to content

Commit c27025e

Browse files
committed
runstate: cleanup reboot and panic actions
The possible choices for panic, reset and watchdog actions are inconsistent. "-action panic=poweroff" should be renamed to "-action panic=shutdown" on the command line. This is because "-action panic=poweroff" and "-action watchdog=poweroff" have slightly different semantics, the first does an unorderly exit while the second goes through qemu_cleanup(). With this change, -no-shutdown would not have to change "-action panic=pause" "pause", just like it does not have to change the reset action. "-action reboot=none" should be renamed to "-action reboot=reset". This should be self explanatory, since for example "-action panic=none" lets the guest proceed without taking any action. Reviewed-by: Eric Blake <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent fef80ea commit c27025e

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

qapi/run-state.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,14 +330,14 @@
330330
#
331331
# Possible QEMU actions upon guest reboot
332332
#
333-
# @none: Reset the VM
333+
# @reset: Reset the VM
334334
#
335-
# @shutdown: Shutdown the VM and exit
335+
# @shutdown: Shutdown the VM and exit, according to the shutdown action
336336
#
337337
# Since: 6.0
338338
##
339339
{ 'enum': 'RebootAction',
340-
'data': [ 'none', 'shutdown' ] }
340+
'data': [ 'reset', 'shutdown' ] }
341341

342342
##
343343
# @ShutdownAction:
@@ -360,10 +360,12 @@
360360
#
361361
# @pause: Pause the VM
362362
#
363+
# @shutdown: Shutdown the VM and exit, according to the shutdown action
364+
#
363365
# Since: 6.0
364366
##
365367
{ 'enum': 'PanicAction',
366-
'data': [ 'poweroff', 'pause', 'none' ] }
368+
'data': [ 'pause', 'shutdown', 'none' ] }
367369

368370
##
369371
# @watchdog-set-action:

qemu-options.hx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3900,12 +3900,12 @@ SRST
39003900
ERST
39013901

39023902
DEF("action", HAS_ARG, QEMU_OPTION_action,
3903-
"-action reboot=none|shutdown\n"
3904-
" action when guest reboots [default=none]\n"
3903+
"-action reboot=reset|shutdown\n"
3904+
" action when guest reboots [default=reset]\n"
39053905
"-action shutdown=poweroff|pause\n"
39063906
" action when guest shuts down [default=poweroff]\n"
3907-
"-action panic=poweroff|pause|none\n"
3908-
" action when guest panics [default=poweroff]\n"
3907+
"-action panic=pause|shutdown|none\n"
3908+
" action when guest panics [default=shutdown]\n"
39093909
"-action watchdog=reset|shutdown|poweroff|inject-nmi|pause|debug|none\n"
39103910
" action when watchdog fires [default=reset]\n",
39113911
QEMU_ARCH_ALL)

softmmu/runstate-action.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
#include "qapi/error.h"
1414
#include "qemu/option_int.h"
1515

16-
RebootAction reboot_action = REBOOT_ACTION_NONE;
16+
RebootAction reboot_action = REBOOT_ACTION_RESET;
1717
ShutdownAction shutdown_action = SHUTDOWN_ACTION_POWEROFF;
18-
PanicAction panic_action = PANIC_ACTION_POWEROFF;
18+
PanicAction panic_action = PANIC_ACTION_SHUTDOWN;
1919

2020
/*
2121
* Receives actions to be applied for specific guest events

softmmu/runstate.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -471,14 +471,15 @@ void qemu_system_guest_panicked(GuestPanicInformation *info)
471471
}
472472
/*
473473
* TODO: Currently the available panic actions are: none, pause, and
474-
* poweroff, but in principle debug and reset could be supported as well.
474+
* shutdown, but in principle debug and reset could be supported as well.
475475
* Investigate any potential use cases for the unimplemented actions.
476476
*/
477-
if (panic_action == PANIC_ACTION_PAUSE) {
477+
if (panic_action == PANIC_ACTION_PAUSE
478+
|| (panic_action == PANIC_ACTION_SHUTDOWN && shutdown_action == SHUTDOWN_ACTION_PAUSE)) {
478479
qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE,
479480
!!info, info);
480481
vm_stop(RUN_STATE_GUEST_PANICKED);
481-
} else if (panic_action == PANIC_ACTION_POWEROFF) {
482+
} else if (panic_action == PANIC_ACTION_SHUTDOWN) {
482483
qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_POWEROFF,
483484
!!info, info);
484485
vm_stop(RUN_STATE_GUEST_PANICKED);

softmmu/vl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3202,7 +3202,7 @@ void qemu_init(int argc, char **argv, char **envp)
32023202
break;
32033203
case QEMU_OPTION_no_shutdown:
32043204
olist = qemu_find_opts("action");
3205-
qemu_opts_parse_noisily(olist, "panic=pause,shutdown=pause", false);
3205+
qemu_opts_parse_noisily(olist, "shutdown=pause", false);
32063206
break;
32073207
case QEMU_OPTION_uuid:
32083208
if (qemu_uuid_parse(optarg, &qemu_uuid) < 0) {

0 commit comments

Comments
 (0)