@@ -453,6 +453,40 @@
{ 'command': 'watchdog-set-action', 'data' : {'action': 'WatchdogAction'} }
##
+# @set-action:
+#
+# Set the actions that will be taken by the emulator in response to guest
+# events.
+#
+# @reboot: @RebootAction action taken on guest reboot.
+#
+# @shutdown: @ShutdownAction action taken on guest shutdown.
+#
+# @panic: @PanicAction action taken on guest panic.
+#
+# @watchdog: @WatchdogAction action taken when watchdog timer expires .
+#
+# Returns: Nothing on success.
+#
+# Since: 6.0
+#
+# Example:
+#
+# -> { "execute": "set-action",
+# "arguments": { "reboot": "shutdown",
+# "shutdown" : "pause",
+# "panic": "pause",
+# "watchdog": "inject-nmi" } }
+# <- { "return": {} }
+##
+{ 'command': 'set-action',
+ 'data': { '*reboot': 'RebootAction',
+ '*shutdown': 'ShutdownAction',
+ '*panic': 'PanicAction',
+ '*watchdog': 'WatchdogAction' },
+ 'allow-preconfig': true }
+
+##
# @GUEST_PANICKED:
#
# Emitted when guest OS panic is detected
@@ -40,6 +40,35 @@ static void fix_panic_action(void)
}
/*
+ * 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;
+ fix_panic_action();
+ }
+}
+
+/*
* Process an event|action pair and set the appropriate internal
* state if event and action are valid.
*/
Add a QMP command to allow for the behaviors specified by the -action event=action command line option to be set at runtime. The new command is named set-action and takes optional arguments with an event and a corresponding action to take. Example: -> { "execute": "set-action", "arguments": { "reboot": "none", "shutdown": "poweroff", "panic": "none", "watchdog": "debug" } } <- { "return": {} } Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com> --- qapi/run-state.json | 34 ++++++++++++++++++++++++++++++++++ softmmu/runstate-action.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+)