提交 fcfab754 编写于 作者: M Marc-André Lureau 提交者: Markus Armbruster

qmp-shell: learn to send commands with quoted arguments

Use shlex to split the CLI command, respecting quoted arguments, and
also comments. This allows to call for ex:

(QEMU) human-monitor-command command-line="screendump /dev/null"
{"execute": "human-monitor-command", "arguments": {"command-line": "screendump /dev/null"}}
Signed-off-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20180326150916.9602-3-marcandre.lureau@redhat.com>
Reviewed-by: NEduardo Habkost <ehabkost@redhat.com>
Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
上级 38441756
......@@ -74,6 +74,7 @@ import sys
import os
import errno
import atexit
import shlex
class QMPCompleter(list):
def complete(self, text, state):
......@@ -219,7 +220,7 @@ class QMPShell(qmp.QEMUMonitorProtocol):
< command-name > [ arg-name1=arg1 ] ... [ arg-nameN=argN ]
"""
cmdargs = cmdline.split()
cmdargs = shlex.split(cmdline)
# Transactional CLI entry/exit:
if cmdargs[0] == 'transaction(':
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册