qmp-shell: learn to send commands with quoted arguments
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Mon, 26 Mar 2018 15:08:40 +0000 (17:08 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Wed, 15 Aug 2018 05:24:22 +0000 (07:24 +0200)
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>
Message-Id: <20180326150916.9602-3-marcandre.lureau@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
scripts/qmp/qmp-shell

index a42306dd8919f90564ca4f5f23ae1f6006a6d940..770140772d07b90d8a03d54a6d570d269002cb07 100755 (executable)
@@ -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(':