[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 01/32] QMP: Allow dot separated dict path arguments i
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PULL 01/32] QMP: Allow dot separated dict path arguments in qmp-shell |
Date: |
Mon, 3 Mar 2014 12:11:52 -0500 |
From: Fam Zheng <address@hidden>
As another convenience 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 <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Luiz Capitulino <address@hidden>
---
scripts/qmp/qmp-shell | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell
index d374b35..e0e848b 100755
--- a/scripts/qmp/qmp-shell
+++ b/scripts/qmp/qmp-shell
@@ -112,13 +112,29 @@ 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']
+ curpath = []
+ for p in optpath[:-1]:
+ curpath.append(p)
+ d = parent.get(p, {})
+ if type(d) is not dict:
+ raise QMPShellError('Cannot use "%s" as both leaf and
non-leaf key' % '.'.join(curpath))
+ parent[p] = d
+ parent = d
+ if optpath[-1] in parent:
+ if type(parent[optpath[-1]]) is dict:
+ raise QMPShellError('Cannot use "%s" as both leaf and
non-leaf key' % '.'.join(curpath))
+ else:
+ raise QMPShellError('Cannot set "%s" multiple times' %
opt[0])
+ parent[optpath[-1]] = value
return qmpcmd
def _execute_cmd(self, cmdline):
try:
qmpcmd = self.__build_cmd(cmdline)
- except:
+ except Exception, e:
+ print 'Error while parsing command line: %s' % e
print 'command format: <command-name> ',
print '[arg-name1=arg1] ... [arg-nameN=argN]'
return True
--
1.8.1.4
- [Qemu-devel] [PULL 00/32] QMP queue, Luiz Capitulino, 2014/03/03
- [Qemu-devel] [PULL 02/32] MAINTAINERS: update status for HMP, QAPI and QMP trees, Luiz Capitulino, 2014/03/03
- [Qemu-devel] [PULL 01/32] QMP: Allow dot separated dict path arguments in qmp-shell,
Luiz Capitulino <=
- [Qemu-devel] [PULL 04/32] dump: add argument to write_elfxx_notes, Luiz Capitulino, 2014/03/03
- [Qemu-devel] [PULL 07/32] dump: add API to write elf notes to buffer, Luiz Capitulino, 2014/03/03
- [Qemu-devel] [PULL 08/32] dump: add support for lzo/snappy, Luiz Capitulino, 2014/03/03
- [Qemu-devel] [PULL 09/32] dump: add members to DumpState and init some of them, Luiz Capitulino, 2014/03/03
- [Qemu-devel] [PULL 05/32] dump: add API to write header of flatten format, Luiz Capitulino, 2014/03/03
- [Qemu-devel] [PULL 11/32] dump: add API to write dump_bitmap, Luiz Capitulino, 2014/03/03
- [Qemu-devel] [PULL 06/32] dump: add API to write vmcore, Luiz Capitulino, 2014/03/03
- [Qemu-devel] [PULL 12/32] dump: add APIs to operate DataCache, Luiz Capitulino, 2014/03/03
- [Qemu-devel] [PULL 10/32] dump: add API to write dump header, Luiz Capitulino, 2014/03/03
- [Qemu-devel] [PULL 03/32] dump: const-qualify the buf of WriteCoreDumpFunction, Luiz Capitulino, 2014/03/03