From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
Cc: armbru@redhat.com
Subject: [Qemu-devel] [PATCH for-2.11 2/5] qmp-shell: Pass split cmdargs to __build_cmd()
Date: Fri, 4 Aug 2017 18:36:22 -0300 [thread overview]
Message-ID: <20170804213625.3756-3-ehabkost@redhat.com> (raw)
In-Reply-To: <20170804213625.3756-1-ehabkost@redhat.com>
This will allow us to implement a method to run a command that is
already split in a list.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
scripts/qmp/qmp-shell | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell
index c276b90..5fe6162 100755
--- a/scripts/qmp/qmp-shell
+++ b/scripts/qmp/qmp-shell
@@ -212,15 +212,13 @@ class QMPShell(qmp.QEMUMonitorProtocol):
raise QMPShellError('Cannot set "%s" multiple times' % key)
parent[optpath[-1]] = value
- def __build_cmd(self, cmdline):
+ def __build_cmd(self, cmdargs):
"""
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()
-
# Transactional CLI entry/exit:
if cmdargs[0] == 'transaction(':
self._transmode = True
@@ -247,7 +245,7 @@ class QMPShell(qmp.QEMUMonitorProtocol):
finalize = True
self.__cli_expr(cmdargs[1:], action['data'])
self._actions.append(action)
- return self.__build_cmd(')') if finalize else None
+ return self.__build_cmd([')']) if finalize else None
# Standard command: parse and return it to be executed.
qmpcmd = { 'execute': cmdargs[0], 'arguments': {} }
@@ -262,8 +260,9 @@ class QMPShell(qmp.QEMUMonitorProtocol):
print str(jsobj)
def _execute_cmd(self, cmdline):
+ cmdargs = cmdline.split()
try:
- qmpcmd = self.__build_cmd(cmdline)
+ qmpcmd = self.__build_cmd(cmdargs)
except Exception as e:
print 'Error while parsing command line: %s' % e
print 'command format: <command-name> ',
--
2.9.4
next prev parent reply other threads:[~2017-08-04 21:43 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-04 21:36 [Qemu-devel] [PATCH for-2.11 0/5] qmp-shell non-interactive mode, delete scripts/qmp/qmp Eduardo Habkost
2017-08-04 21:36 ` [Qemu-devel] [PATCH for-2.11 1/5] qmp-shell: Use argparse module Eduardo Habkost
2017-08-08 10:07 ` Stefan Hajnoczi
2017-08-08 10:11 ` Daniel P. Berrange
2017-08-08 12:57 ` Eduardo Habkost
2017-08-04 21:36 ` Eduardo Habkost [this message]
2017-08-08 10:09 ` [Qemu-devel] [PATCH for-2.11 2/5] qmp-shell: Pass split cmdargs to __build_cmd() Stefan Hajnoczi
2017-08-04 21:36 ` [Qemu-devel] [PATCH for-2.11 3/5] qmp-shell: execute_cmdargs() method Eduardo Habkost
2017-08-08 10:09 ` Stefan Hajnoczi
2017-08-04 21:36 ` [Qemu-devel] [PATCH for-2.11 4/5] qmp-shell: Accept QMP command as argument Eduardo Habkost
2017-08-08 10:11 ` Stefan Hajnoczi
2017-08-04 21:36 ` [Qemu-devel] [PATCH for-2.11 5/5] Remove scripts/qmp/qmp Eduardo Habkost
2017-08-08 10:11 ` Stefan Hajnoczi
2017-08-05 14:56 ` [Qemu-devel] [PATCH for-2.11 0/5] qmp-shell non-interactive mode, delete scripts/qmp/qmp Fam Zheng
2017-08-05 19:11 ` Eduardo Habkost
2017-08-07 2:26 ` Fam Zheng
2017-08-07 22:20 ` John Snow
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170804213625.3756-3-ehabkost@redhat.com \
--to=ehabkost@redhat.com \
--cc=armbru@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.