Message ID | 20180326150916.9602-3-marcandre.lureau@redhat.com |
---|---|
State | New |
Headers | show |
Series | RFC: monitor: add asynchronous command type | expand |
On Mon, Mar 26, 2018 at 05:08:40PM +0200, Marc-André Lureau wrote: > 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: Marc-André Lureau <marcandre.lureau@redhat.com> Wonderful. Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index be449de621..af7033c765 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -73,6 +73,7 @@ import sys import os import errno import atexit +import shlex class QMPCompleter(list): def complete(self, text, state): @@ -218,7 +219,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(':
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: Marc-André Lureau <marcandre.lureau@redhat.com> --- scripts/qmp/qmp-shell | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)