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 <f...@redhat.com>

--
Applies on top of Stefan's patch

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

Signed-off-by: Fam Zheng <f...@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


Reply via email to