All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com
Subject: [PATCH 03/12] hmp: replace "O" parser with keyval
Date: Wed, 11 Nov 2020 09:25:28 -0500	[thread overview]
Message-ID: <20201111142537.1213209-4-pbonzini@redhat.com> (raw)
In-Reply-To: <20201111142537.1213209-1-pbonzini@redhat.com>

HMP is using QemuOpts to parse free-form commands device_add,
netdev_add and object_add.  However, none of these need QemuOpts
for validation (these three QemuOptsLists are all of the catch-all
kind), and keyval is already able to parse into QDict.  So use
keyval directly, avoiding the detour from
string to QemuOpts to QDict.

The args_type now stores the implied key.  This arguably makes more
sense than storing the QemuOptsList name; at least, it _is_ a key
that might end up in the arguments QDict.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hmp-commands.hx |  6 +++---
 monitor/hmp.c   | 20 +++++++++-----------
 2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/hmp-commands.hx b/hmp-commands.hx
index ff2d7aa8f3..35ecd0d9ca 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -668,7 +668,7 @@ ERST
 
     {
         .name       = "device_add",
-        .args_type  = "device:O",
+        .args_type  = "driver:O",
         .params     = "driver[,prop=value][,...]",
         .help       = "add device, like -device on the command line",
         .cmd        = hmp_device_add,
@@ -1314,7 +1314,7 @@ ERST
 
     {
         .name       = "netdev_add",
-        .args_type  = "netdev:O",
+        .args_type  = "type:O",
         .params     = "[user|tap|socket|vde|bridge|hubport|netmap|vhost-user],id=str[,prop=value][,...]",
         .help       = "add host network device",
         .cmd        = hmp_netdev_add,
@@ -1342,7 +1342,7 @@ ERST
 
     {
         .name       = "object_add",
-        .args_type  = "object:O",
+        .args_type  = "qom-type:O",
         .params     = "[qom-type=]type,id=str[,prop=value][,...]",
         .help       = "create QOM object",
         .cmd        = hmp_object_add,
diff --git a/monitor/hmp.c b/monitor/hmp.c
index 0027f1465d..e535baafd0 100644
--- a/monitor/hmp.c
+++ b/monitor/hmp.c
@@ -744,13 +744,9 @@ static QDict *monitor_parse_arguments(Monitor *mon,
             break;
         case 'O':
             {
-                QemuOptsList *opts_list;
-                QemuOpts *opts;
+                Error *errp;
+                bool help;
 
-                opts_list = qemu_find_opts(key);
-                if (!opts_list || opts_list->desc->name) {
-                    goto bad_type;
-                }
                 while (qemu_isspace(*p)) {
                     p++;
                 }
@@ -760,12 +756,14 @@ static QDict *monitor_parse_arguments(Monitor *mon,
                 if (get_str(buf, sizeof(buf), &p) < 0) {
                     goto fail;
                 }
-                opts = qemu_opts_parse_noisily(opts_list, buf, true);
-                if (!opts) {
-                    goto fail;
+                keyval_parse_into(qdict, buf, key, &help, &errp);
+                if (help) {
+                    if (qdict_haskey(qdict, key)) {
+                        qdict_put_bool(qdict, "help", true);
+                    } else {
+                        qdict_put_str(qdict, key, "help");
+                    }
                 }
-                qemu_opts_to_qdict(opts, qdict);
-                qemu_opts_del(opts);
             }
             break;
         case '/':
-- 
2.26.2




  parent reply	other threads:[~2020-11-11 14:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-11 14:25 [RFC PATCH 00/12] Remove QemuOpts usage for HMP, -object and -readconfig Paolo Bonzini
2020-11-11 14:25 ` [PATCH 01/12] tests: convert check-qom-proplist to keyval Paolo Bonzini
2020-11-11 14:25 ` [PATCH 02/12] keyval: introduce keyval_parse_into Paolo Bonzini
2020-11-11 14:25 ` Paolo Bonzini [this message]
2020-11-11 14:25 ` [PATCH 04/12] qom: use qemu_printf to print help for user-creatable objects Paolo Bonzini
2020-11-11 14:25 ` [PATCH 05/12] hmp: special case help options for object_add Paolo Bonzini
2020-11-11 14:25 ` [PATCH 06/12] qemu-io: use keyval for -object parsing Paolo Bonzini
2020-11-11 14:25 ` [PATCH 07/12] qemu-nbd: " Paolo Bonzini
2020-11-11 14:25 ` [PATCH 08/12] qemu-img: " Paolo Bonzini
2020-11-11 14:25 ` [PATCH 09/12] qemu-config: add error propagation to qemu_config_parse Paolo Bonzini
2020-11-11 14:25 ` [PATCH 10/12] qemu-option: support accept-any QemuOptsList in qemu_opts_absorb_qdict Paolo Bonzini
2020-11-11 14:25 ` [PATCH 11/12] qemu-config: parse configuration files to a QDict Paolo Bonzini
2020-11-11 14:25 ` [PATCH 12/12] qemu: use keyval for -object parsing Paolo Bonzini
2020-11-13 14:35 ` [RFC PATCH 00/12] Remove QemuOpts usage for HMP, -object and -readconfig Kevin Wolf

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=20201111142537.1213209-4-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kwolf@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.