qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [PULL 16/27] watchdog: remove select_watchdog_action
Date: Wed,  3 Nov 2021 16:04:31 +0100	[thread overview]
Message-ID: <20211103150442.387121-17-pbonzini@redhat.com> (raw)
In-Reply-To: <20211103150442.387121-1-pbonzini@redhat.com>

Instead of invoking select_watchdog_action from both HMP and command line,
go directly from HMP to QMP and use QemuOpts as the intermediary for the
command line.

This makes -watchdog-action explicitly a shortcut for "-action watchdog",
so that "-watchdog-action" and "-action watchdog" override each other
based on the position on the command line; previously, "-action watchdog"
always won.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/watchdog/watchdog.c    | 14 --------------
 include/sysemu/watchdog.h |  1 -
 monitor/misc.c            | 15 ++++++++++++---
 softmmu/vl.c              | 10 +++++-----
 4 files changed, 17 insertions(+), 23 deletions(-)

diff --git a/hw/watchdog/watchdog.c b/hw/watchdog/watchdog.c
index 0e98ffb73f..1437e6c5b6 100644
--- a/hw/watchdog/watchdog.c
+++ b/hw/watchdog/watchdog.c
@@ -76,20 +76,6 @@ int select_watchdog(const char *p)
     return 1;
 }
 
-int select_watchdog_action(const char *p)
-{
-    int action;
-    char *qapi_value;
-
-    qapi_value = g_ascii_strdown(p, -1);
-    action = qapi_enum_parse(&WatchdogAction_lookup, qapi_value, -1, NULL);
-    g_free(qapi_value);
-    if (action < 0)
-        return -1;
-    qmp_watchdog_set_action(action, &error_abort);
-    return 0;
-}
-
 WatchdogAction get_watchdog_action(void)
 {
     return watchdog_action;
diff --git a/include/sysemu/watchdog.h b/include/sysemu/watchdog.h
index a08d16380d..d2d4901dbb 100644
--- a/include/sysemu/watchdog.h
+++ b/include/sysemu/watchdog.h
@@ -37,7 +37,6 @@ typedef struct WatchdogTimerModel WatchdogTimerModel;
 
 /* in hw/watchdog.c */
 int select_watchdog(const char *p);
-int select_watchdog_action(const char *action);
 WatchdogAction get_watchdog_action(void);
 void watchdog_add_model(WatchdogTimerModel *model);
 void watchdog_perform_action(void);
diff --git a/monitor/misc.c b/monitor/misc.c
index c2d227a07c..1759d1e7f1 100644
--- a/monitor/misc.c
+++ b/monitor/misc.c
@@ -70,6 +70,7 @@
 #include "qapi/qapi-commands-migration.h"
 #include "qapi/qapi-commands-misc.h"
 #include "qapi/qapi-commands-qom.h"
+#include "qapi/qapi-commands-run-state.h"
 #include "qapi/qapi-commands-trace.h"
 #include "qapi/qapi-init-commands.h"
 #include "qapi/error.h"
@@ -471,10 +472,18 @@ static void hmp_gdbserver(Monitor *mon, const QDict *qdict)
 
 static void hmp_watchdog_action(Monitor *mon, const QDict *qdict)
 {
-    const char *action = qdict_get_str(qdict, "action");
-    if (select_watchdog_action(action) == -1) {
-        monitor_printf(mon, "Unknown watchdog action '%s'\n", action);
+    Error *err = NULL;
+    WatchdogAction action;
+    char *qapi_value;
+
+    qapi_value = g_ascii_strdown(qdict_get_str(qdict, "action"), -1);
+    action = qapi_enum_parse(&WatchdogAction_lookup, qapi_value, -1, &err);
+    g_free(qapi_value);
+    if (err) {
+        hmp_handle_error(mon, err);
+        return;
     }
+    qmp_watchdog_set_action(action, &error_abort);
 }
 
 static void monitor_printc(Monitor *mon, int c)
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 570120f5c4..1159a64bce 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -3265,12 +3265,12 @@ void qemu_init(int argc, char **argv, char **envp)
                      exit(1);
                 }
                 break;
-            case QEMU_OPTION_watchdog_action:
-                if (select_watchdog_action(optarg) == -1) {
-                    error_report("unknown -watchdog-action parameter");
-                    exit(1);
-                }
+            case QEMU_OPTION_watchdog_action: {
+                QemuOpts *opts;
+                opts = qemu_opts_create(qemu_find_opts("action"), NULL, 0, &error_abort);
+                qemu_opt_set(opts, "watchdog", optarg, &error_abort);
                 break;
+            }
             case QEMU_OPTION_parallel:
                 add_device_config(DEV_PARALLEL, optarg);
                 default_parallel = 0;
-- 
2.31.1




  parent reply	other threads:[~2021-11-03 15:19 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-03 15:04 [PULL 00/27] Misc patches for QEMU 6.2 soft freeze Paolo Bonzini
2021-11-03 15:04 ` [PULL 01/27] Makefile: Fix gtags generation Paolo Bonzini
2021-11-03 15:04 ` [PULL 02/27] Makefile: Fix cscope issues on MacOS and soft links Paolo Bonzini
2021-11-03 15:04 ` [PULL 03/27] Partially revert "build: -no-pie is no functional linker flag" Paolo Bonzini
2021-11-03 15:04 ` [PULL 04/27] configure/optionrom: Fix MSYS2 multiboot.bin issue Paolo Bonzini
2021-11-03 15:04 ` [PULL 05/27] util: Make some iova_tree parameters const Paolo Bonzini
2021-11-03 15:04 ` [PULL 06/27] MAINTAINERS: update location of microvm docs Paolo Bonzini
2021-11-03 15:04 ` [PULL 07/27] target/i386: move linuxboot_dma_enabled to X86MachineState Paolo Bonzini
2021-11-03 15:04 ` [PULL 08/27] optionrom: add a DMA-enabled multiboot ROM Paolo Bonzini
2021-11-03 15:04 ` [PULL 09/27] target/i386: use DMA-enabled multiboot ROM for new-enough QEMU machine types Paolo Bonzini
2021-11-03 15:04 ` [PULL 10/27] configure: remove useless NPTL probe Paolo Bonzini
2021-11-03 15:04 ` [PULL 11/27] configure: do not duplicate CPU_CFLAGS into QEMU_LDFLAGS Paolo Bonzini
2021-11-03 15:04 ` [PULL 12/27] hvf: Avoid mapping regions < PAGE_SIZE as ram Paolo Bonzini
2021-11-03 15:04 ` [PULL 13/27] hw/i386: Rename default_bus_bypass_iommu Paolo Bonzini
2021-11-03 15:04 ` [PULL 14/27] watchdog: add information from -watchdog help to -device help Paolo Bonzini
2021-11-03 15:04 ` [PULL 15/27] vl: deprecate -watchdog Paolo Bonzini
2021-11-03 15:04 ` Paolo Bonzini [this message]
2021-11-03 15:04 ` [PULL 17/27] hw/i386: fix vmmouse registration Paolo Bonzini
2021-11-03 15:04 ` [PULL 18/27] KVM: SVM: add migration support for nested TSC scaling Paolo Bonzini
2021-11-03 15:04 ` [PULL 19/27] esp: ensure in-flight SCSI requests are always cancelled Paolo Bonzini
2021-11-03 15:04 ` [PULL 20/27] qtest/am53c974-test: add test for cancelling in-flight requests Paolo Bonzini
2021-11-03 15:04 ` [PULL 21/27] meson: bump submodule to 0.59.3 Paolo Bonzini
2021-11-03 15:04 ` [PULL 22/27] meson.build: Allow to disable OSS again Paolo Bonzini
2021-11-03 15:04 ` [PULL 23/27] meson: remove pointless warnings Paolo Bonzini
2021-11-03 15:04 ` [PULL 24/27] meson: remove unnecessary coreaudio test program Paolo Bonzini
2021-11-03 15:04 ` [PULL 25/27] Move the l2tpv3 test from configure to meson.build Paolo Bonzini
2021-11-03 15:04 ` [PULL 26/27] configure: Remove the check for the __thread keyword Paolo Bonzini
2021-11-03 15:04 ` [PULL 27/27] configure: fix --audio-drv-list help message Paolo Bonzini
2021-11-04  4:42 ` [PULL 00/27] Misc patches for QEMU 6.2 soft freeze Richard Henderson

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=20211103150442.387121-17-pbonzini@redhat.com \
    --to=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).