qemu/softmmu/runstate-action.c
Paolo Bonzini c27025e044 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 <eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-01-21 13:00:41 +01:00

46 lines
1.2 KiB
C

/*
* Copyright (c) 2020 Oracle and/or its affiliates.
*
* This work is licensed under the terms of the GNU GPL, version 2.
* See the COPYING file in the top-level directory.
*
*/
#include "qemu/osdep.h"
#include "sysemu/runstate-action.h"
#include "sysemu/watchdog.h"
#include "qemu/config-file.h"
#include "qapi/error.h"
#include "qemu/option_int.h"
RebootAction reboot_action = REBOOT_ACTION_RESET;
ShutdownAction shutdown_action = SHUTDOWN_ACTION_POWEROFF;
PanicAction panic_action = PANIC_ACTION_SHUTDOWN;
/*
* Receives actions to be applied for specific guest events
* and sets the internal state as requested.
*/
void qmp_set_action(bool has_reboot, RebootAction reboot,
bool has_shutdown, ShutdownAction shutdown,
bool has_panic, PanicAction panic,
bool has_watchdog, WatchdogAction watchdog,
Error **errp)
{
if (has_reboot) {
reboot_action = reboot;
}
if (has_panic) {
panic_action = panic;
}
if (has_watchdog) {
qmp_watchdog_set_action(watchdog, errp);
}
/* Process shutdown last, in case the panic action needs to be altered */
if (has_shutdown) {
shutdown_action = shutdown;
}
}