[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 07/10] scripts: qmp-shell: refactor helpers
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PULL 07/10] scripts: qmp-shell: refactor helpers |
Date: |
Fri, 8 May 2015 09:34:08 -0400 |
From: John Snow <address@hidden>
Refactor the qmp-shell command line processing function
into two components. This will be used to allow sub-expressions,
which will assist us in adding transactional support to qmp-shell.
Signed-off-by: John Snow <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Tested-by: Kashyap Chamarthy <address@hidden>
Signed-off-by: Luiz Capitulino <address@hidden>
---
scripts/qmp/qmp-shell | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell
index e0e848b..a9632ec 100755
--- a/scripts/qmp/qmp-shell
+++ b/scripts/qmp/qmp-shell
@@ -88,16 +88,8 @@ class QMPShell(qmp.QEMUMonitorProtocol):
# clearing everything as it doesn't seem to matter
readline.set_completer_delims('')
- def __build_cmd(self, cmdline):
- """
- Build a QMP input object from a user provided command-line in the
- following format:
-
- < command-name > [ arg-name1=arg1 ] ... [ arg-nameN=argN ]
- """
- cmdargs = cmdline.split()
- qmpcmd = { 'execute': cmdargs[0], 'arguments': {} }
- for arg in cmdargs[1:]:
+ def __cli_expr(self, tokens, parent):
+ for arg in tokens:
opt = arg.split('=')
try:
if(len(opt) > 2):
@@ -113,7 +105,6 @@ class QMPShell(qmp.QEMUMonitorProtocol):
else:
value = opt[1]
optpath = opt[0].split('.')
- parent = qmpcmd['arguments']
curpath = []
for p in optpath[:-1]:
curpath.append(p)
@@ -128,6 +119,17 @@ class QMPShell(qmp.QEMUMonitorProtocol):
else:
raise QMPShellError('Cannot set "%s" multiple times' %
opt[0])
parent[optpath[-1]] = value
+
+ def __build_cmd(self, cmdline):
+ """
+ Build a QMP input object from a user provided command-line in the
+ following format:
+
+ < command-name > [ arg-name1=arg1 ] ... [ arg-nameN=argN ]
+ """
+ cmdargs = cmdline.split()
+ qmpcmd = { 'execute': cmdargs[0], 'arguments': {} }
+ self.__cli_expr(cmdargs[1:], qmpcmd['arguments'])
return qmpcmd
def _execute_cmd(self, cmdline):
--
1.9.3
- [Qemu-devel] [PULL 00/10] QMP queue, Luiz Capitulino, 2015/05/08
- [Qemu-devel] [PULL 03/10] qobject: Clean up around qtype_code, Luiz Capitulino, 2015/05/08
- [Qemu-devel] [PULL 02/10] QJSON: Use OBJECT_CHECK, Luiz Capitulino, 2015/05/08
- [Qemu-devel] [PULL 05/10] json-parser: Accept 'null' in QMP, Luiz Capitulino, 2015/05/08
- [Qemu-devel] [PULL 04/10] qobject: Add a special null QObject, Luiz Capitulino, 2015/05/08
- [Qemu-devel] [PULL 07/10] scripts: qmp-shell: refactor helpers,
Luiz Capitulino <=
- [Qemu-devel] [PULL 06/10] MAINTAINERS: New maintainer for QMP and QAPI, Luiz Capitulino, 2015/05/08
- [Qemu-devel] [PULL 01/10] monitor: add memory search commands s, sp, Luiz Capitulino, 2015/05/08
- [Qemu-devel] [PULL 08/10] scripts: qmp-shell: Expand support for QMP expressions, Luiz Capitulino, 2015/05/08
- [Qemu-devel] [PULL 09/10] scripts: qmp-shell: add transaction subshell, Luiz Capitulino, 2015/05/08
- [Qemu-devel] [PULL 10/10] scripts: qmp-shell: Add verbose flag, Luiz Capitulino, 2015/05/08
- Re: [Qemu-devel] [PULL 00/10] QMP queue, Peter Maydell, 2015/05/11