[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 02/22] QMP: allow JSON dict arguments in qmp-shell
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PULL 02/22] QMP: allow JSON dict arguments in qmp-shell |
Date: |
Thu, 13 Feb 2014 10:30:20 -0500 |
From: Stefan Hajnoczi <address@hidden>
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 <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Benoit Canet <address@hidden>
Signed-off-by: Luiz Capitulino <address@hidden>
---
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.1.4
- [Qemu-devel] [PULL 00/22] QMP queue, Luiz Capitulino, 2014/02/13
- [Qemu-devel] [PULL 01/22] hmp: migrate command (without -d) now blocks correctly, Luiz Capitulino, 2014/02/13
- [Qemu-devel] [PULL 02/22] QMP: allow JSON dict arguments in qmp-shell,
Luiz Capitulino <=
- [Qemu-devel] [PULL 03/22] Use error_is_set() only when necessary, Luiz Capitulino, 2014/02/13
- [Qemu-devel] [PULL 05/22] dump: const-qualify the buf of WriteCoreDumpFunction, Luiz Capitulino, 2014/02/13
- [Qemu-devel] [PULL 06/22] dump: add argument to write_elfxx_notes, Luiz Capitulino, 2014/02/13
- [Qemu-devel] [PULL 04/22] qmp: expose list of supported character device backends, Luiz Capitulino, 2014/02/13
- [Qemu-devel] [PULL 07/22] dump: add API to write header of flatten format, Luiz Capitulino, 2014/02/13
- [Qemu-devel] [PULL 09/22] dump: add API to write elf notes to buffer, Luiz Capitulino, 2014/02/13
- [Qemu-devel] [PULL 08/22] dump: add API to write vmcore, Luiz Capitulino, 2014/02/13
- [Qemu-devel] [PULL 10/22] dump: add support for lzo/snappy, Luiz Capitulino, 2014/02/13
- [Qemu-devel] [PULL 11/22] dump: add members to DumpState and init some of them, Luiz Capitulino, 2014/02/13
- [Qemu-devel] [PULL 12/22] dump: add API to write dump header, Luiz Capitulino, 2014/02/13