qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: qemu-devel@nongnu.org
Cc: Igor Mammedov <imammedo@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Luiz Capitulino <lcapitulino@redhat.com>
Subject: [Qemu-devel] [PATCH] QMP: allow dot separated dict path arguments in qmp-shell
Date: Tue, 11 Feb 2014 18:45:05 +0800	[thread overview]
Message-ID: <1392115505-21969-1-git-send-email-famz@redhat.com> (raw)
In-Reply-To: <1390994251-21768-1-git-send-email-stefanha@redhat.com>

As another convinience to allow using commands that expect a dict as
argument, this patch adds support for foo.bar=value syntax, similar to
command line argument style:

  (QEMU) blockdev-add options.driver=file options.id=drive1 options.filename=...

Signed-off-by: Fam Zheng <famz@redhat.com>

--
Applies on top of Stefan's patch

    [PATCH] QMP: allow JSON dict arguments in qmp-shell

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 scripts/qmp/qmp-shell | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell
index d374b35..9c84551 100755
--- a/scripts/qmp/qmp-shell
+++ b/scripts/qmp/qmp-shell
@@ -112,7 +112,14 @@ class QMPShell(qmp.QEMUMonitorProtocol):
                     value = json.loads(opt[1])
                 else:
                     value = opt[1]
-            qmpcmd['arguments'][opt[0]] = value
+            optpath = opt[0].split('.')
+            parent = qmpcmd['arguments']
+            for p in optpath[:-1]:
+                if not p in parent:
+                    d = dict()
+                    parent[p] = d
+                parent = d
+            parent[optpath[-1]] = value
         return qmpcmd
 
     def _execute_cmd(self, cmdline):
-- 
1.8.5.4

  parent reply	other threads:[~2014-02-11 10:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-29 11:17 [Qemu-devel] [PATCH] QMP: allow JSON dict arguments in qmp-shell Stefan Hajnoczi
2014-01-29 15:48 ` Eric Blake
2014-01-29 15:50 ` Benoît Canet
2014-02-10 20:43 ` Luiz Capitulino
2014-02-11  1:39 ` Fam Zheng
2014-02-11  8:41   ` Kevin Wolf
2014-02-11  9:35     ` Fam Zheng
2014-02-11  8:43   ` Markus Armbruster
2014-02-11  9:38     ` Fam Zheng
2014-02-11 10:45 ` Fam Zheng [this message]
2014-02-11 13:28   ` [Qemu-devel] [PATCH] QMP: allow dot separated dict path " Stefan Hajnoczi
2014-02-12  0:56     ` Fam Zheng

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=1392115505-21969-1-git-send-email-famz@redhat.com \
    --to=famz@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).