Browse Source
Add a QMP command to allow for the behaviors specified by the
-no-reboot and -no-shutdown command line option to be set at runtime.
The new command is named set-action and takes optional arguments, named
after an event, that provide a corresponding action to take.
Example:
-> { "execute": "set-action",
"arguments": {
"reboot": "none",
"shutdown": "poweroff",
"watchdog": "debug" } }
<- { "return": {} }
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
Message-Id: <1607705564-26264-4-git-send-email-alejandro.j.jimenez@oracle.com>
[Split the series differently, with -action based on the QMP command. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
pull/104/head
committed by
Paolo Bonzini
11 changed files with 134 additions and 13 deletions
@ -0,0 +1,18 @@ |
|||
/*
|
|||
* 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. |
|||
* |
|||
*/ |
|||
|
|||
#ifndef RUNSTATE_ACTION_H |
|||
#define RUNSTATE_ACTION_H |
|||
|
|||
#include "qapi/qapi-commands-run-state.h" |
|||
|
|||
/* in softmmu/runstate-action.c */ |
|||
extern RebootAction reboot_action; |
|||
extern ShutdownAction shutdown_action; |
|||
|
|||
#endif /* RUNSTATE_ACTION_H */ |
|||
@ -0,0 +1,41 @@ |
|||
/*
|
|||
* 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_NONE; |
|||
ShutdownAction shutdown_action = SHUTDOWN_ACTION_POWEROFF; |
|||
|
|||
/*
|
|||
* 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_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; |
|||
} |
|||
} |
|||
Loading…
Reference in new issue