qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] QMP: allow JSON dict arguments in qmp-shell
@ 2014-01-29 11:17 Stefan Hajnoczi
  2014-01-29 15:48 ` Eric Blake
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Stefan Hajnoczi @ 2014-01-29 11:17 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Luiz Capitulino

qmp-shell hides the QMP wire protocol JSON encoding from the user.  Most
of the time this is helpful and makes the command-line human-friendly.

Some QMP commands take a dict as an argument.  In order to express this
we need to revert back to JSON notation.

This patch allows JSON dict arguments in qmp-shell so commands like
blockdev-add and nbd-server-start can be invoked:

  (QEMU) blockdev-add options={"driver":"file","id":"drive1",...}

Note that spaces are not allowed since str.split() is used to break up
the command-line arguments first.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 scripts/qmp/qmp-shell | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell
index d6b420f..d374b35 100755
--- a/scripts/qmp/qmp-shell
+++ b/scripts/qmp/qmp-shell
@@ -31,6 +31,7 @@
 # (QEMU)
 
 import qmp
+import json
 import readline
 import sys
 import pprint
@@ -107,6 +108,8 @@ class QMPShell(qmp.QEMUMonitorProtocol):
                     value = True
                 elif opt[1] == 'false':
                     value = False
+                elif opt[1].startswith('{'):
+                    value = json.loads(opt[1])
                 else:
                     value = opt[1]
             qmpcmd['arguments'][opt[0]] = value
-- 
1.8.5.3

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-02-12  0:56 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [Qemu-devel] [PATCH] QMP: allow dot separated dict path " Fam Zheng
2014-02-11 13:28   ` Stefan Hajnoczi
2014-02-12  0:56     ` Fam Zheng

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).