qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
To: qemu-devel@nongnu.org
Cc: david.edmondson@oracle.com, pbonzini@redhat.com,
	mihai.carabas@oracle.com
Subject: [PATCH v3 3/4] qmp: Allow setting -action parameters on the fly
Date: Fri, 11 Dec 2020 11:52:43 -0500	[thread overview]
Message-ID: <1607705564-26264-4-git-send-email-alejandro.j.jimenez@oracle.com> (raw)
In-Reply-To: <1607705564-26264-1-git-send-email-alejandro.j.jimenez@oracle.com>

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(+)

diff --git a/qapi/run-state.json b/qapi/run-state.json
index 03ff78b..4732a89 100644
--- a/qapi/run-state.json
+++ b/qapi/run-state.json
@@ -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
diff --git a/softmmu/runstate-action.c b/softmmu/runstate-action.c
index bc30102..92feebf 100644
--- a/softmmu/runstate-action.c
+++ b/softmmu/runstate-action.c
@@ -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.
  */
-- 
1.8.3.1



  parent reply	other threads:[~2020-12-11 16:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-11 16:52 [PATCH v3 0/4] Add a new -action parameter Alejandro Jimenez
2020-12-11 16:52 ` [PATCH v3 1/4] vl: Add an -action option to respond to guest events Alejandro Jimenez
2020-12-11 16:52 ` [PATCH v3 2/4] vl: Add option to avoid stopping VM upon guest panic Alejandro Jimenez
2020-12-11 16:52 ` Alejandro Jimenez [this message]
2020-12-11 16:52 ` [PATCH v3 4/4] qtest/pvpanic: Test panic option that allows VM to continue Alejandro Jimenez
2020-12-11 22:23 ` [PATCH v3 0/4] Add a new -action parameter Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1607705564-26264-4-git-send-email-alejandro.j.jimenez@oracle.com \
    --to=alejandro.j.jimenez@oracle.com \
    --cc=david.edmondson@oracle.com \
    --cc=mihai.carabas@oracle.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).