qmp-shell: learn to connect to qemu-ga
cover qmp-shell: learn to connect to qemu-ga
Hi,
This series adds a -N option to skip negotiate phase that qemu-ga doesn't implement. This allows to use qmp-shell with qemu-ga for testing.
Marc-André Lureau (4):
qmp-shell: add -N option to skip negotiate
qmp-shell: ignore query-commands error
qmp-shell: don't show version greeting if unavailable
qmp-shell: improve help
scripts/qmp/qmp-shell | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
Signature · 1 line
2.12.0.191.gc5d8de91d
PATCH 1/4 qmp-shell: add -N option to skip negotiate
qemu-ga doesn't have negotiate phase.
--- scripts/qmp/qmp-shell | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
scripts/qmp/qmp-shell +7 -4
@@ -256,8 +256,8 @@ class QMPShell(qmp.QEMUMonitorProtocol): self._print(resp) return True - def connect(self): - self._greeting = qmp.QEMUMonitorProtocol.connect(self) + def connect(self, negotiate): + self._greeting = qmp.QEMUMonitorProtocol.connect(self, negotiate) self.__completer_setup() def show_banner(self, msg='Welcome to the QMP low-level shell!'):
@@ -369,7 +369,7 @@ def die(msg): def fail_cmdline(option=None): if option: sys.stderr.write('ERROR: bad command-line option \'%s\'\n' % option) - sys.stderr.write('qemu-shell [ -v ] [ -p ] [ -H ] < UNIX socket path> | < TCP address:port >\n') + sys.stderr.write('qemu-shell [ -v ] [ -p ] [ -H ] [ -N ] < UNIX socket path> | < TCP address:port >\n') sys.exit(1) def main():
@@ -378,6 +378,7 @@ def main(): hmp = False pretty = False verbose = False + negotiate = True try: for arg in sys.argv[1:]:
@@ -387,6 +388,8 @@ def main(): hmp = True elif arg == "-p": pretty = True + elif arg == "-N": + negotiate = False elif arg == "-v": verbose = True else:
@@ -404,7 +407,7 @@ def main(): die('bad port number in command-line') try: - qemu.connect() + qemu.connect(negotiate) except qmp.QMPConnectError: die('Didn\'t get QMP greeting message') except qmp.QMPCapabilitiesError:
Signature · 1 line
2.12.0.191.gc5d8de91d
Re: [Qemu-devel] [PATCH 1/4] qmp-shell: add -N option to skip negotiate
Quoted 6 lines · Marc-André Lureau
qemu-ga doesn't have negotiate phase.
Signed-off-by Marc-André Lureau <[email protected]>--- scripts/qmp/qmp-shell | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH 2/4 qmp-shell: ignore query-commands error
In reply to Marc-André Lureauqemu-ga doesn't implement it.
--- scripts/qmp/qmp-shell | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
scripts/qmp/qmp-shell +4 -1
@@ -126,7 +126,10 @@ class QMPShell(qmp.QEMUMonitorProtocol): return arg def _fill_completion(self): - for cmd in self.cmd('query-commands')['return']: + cmds = self.cmd('query-commands') + if cmds.has_key('error'): + return + for cmd in cmds['return']: self._completer.append(cmd['name']) def __completer_setup(self):
Signature · 1 line
2.12.0.191.gc5d8de91d
Re: [Qemu-devel] [PATCH 2/4] qmp-shell: ignore query-commands error
Quoted 7 lines · Marc-André Lureau
qemu-ga doesn't implement it.
Signed-off-by Marc-André Lureau <[email protected]>--- scripts/qmp/qmp-shell | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Quoted 17 lines
scripts/qmp/qmp-shell +4
-1@@ -126,7 +126,10 @@ class QMPShell(qmp.QEMUMonitorProtocol): return arg def _fill_completion(self): - for cmd in self.cmd('query-commands')['return']: + cmds = self.cmd('query-commands') + if cmds.has_key('error'): + return + for cmd in cmds['return']: self._completer.append(cmd['name']) def __completer_setup(self):
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [Qemu-devel] [PATCH 2/4] qmp-shell: ignore query-commands error
In reply to Marc-André LureauI'd like to rephrase "ignore query-commands error" to "Cope with query-commands error" on commit, if you don't mind.
Quoted 23 lines · Marc-André Lureau
qemu-ga doesn't implement it.
Signed-off-by Marc-André Lureau <[email protected]>--- scripts/qmp/qmp-shell | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)scripts/qmp/qmp-shell +4
-1@@ -126,7 +126,10 @@ class QMPShell(qmp.QEMUMonitorProtocol): return arg def _fill_completion(self): - for cmd in self.cmd('query-commands')['return']: + cmds = self.cmd('query-commands') + if cmds.has_key('error'): + return + for cmd in cmds['return']: self._completer.append(cmd['name']) def __completer_setup(self):
Re: [Qemu-devel] [PATCH 2/4] qmp-shell: ignore query-commands error
Hi
----- Original Message -----
Quoted 3 lines
I'd like to rephrase "ignore query-commands error" to "Cope with query-commands error" on commit, if you don't mind.
No, please do :)
thanks
Quoted 26 lines
Quoted 23 lines · Marc-André Lureau
qemu-ga doesn't implement it.
Signed-off-by Marc-André Lureau <[email protected]>--- scripts/qmp/qmp-shell | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)scripts/qmp/qmp-shell +4
-1@@ -126,7 +126,10 @@ class QMPShell(qmp.QEMUMonitorProtocol): return arg def _fill_completion(self): - for cmd in self.cmd('query-commands')['return']: + cmds = self.cmd('query-commands') + if cmds.has_key('error'): + return + for cmd in cmds['return']: self._completer.append(cmd['name']) def __completer_setup(self):
PATCH 3/4 qmp-shell: don't show version greeting if unavailable
In reply to Marc-André Lureauqemu-ga doesn't have greeting.
--- scripts/qmp/qmp-shell | 3 +++ 1 file changed, 3 insertions(+)
scripts/qmp/qmp-shell +3 -0
@@ -265,6 +265,9 @@ class QMPShell(qmp.QEMUMonitorProtocol): def show_banner(self, msg='Welcome to the QMP low-level shell!'): print msg + if not self._greeting: + print 'Connected' + return version = self._greeting['QMP']['version']['qemu'] print 'Connected to QEMU %d.%d.%d\n' % (version['major'],version['minor'],version['micro'])
Signature · 1 line
2.12.0.191.gc5d8de91d
Re: [Qemu-devel] [PATCH 3/4] qmp-shell: don't show version greeting if unavailable
Quoted 7 lines · Marc-André Lureau
qemu-ga doesn't have greeting.
Signed-off-by Marc-André Lureau <[email protected]>--- scripts/qmp/qmp-shell | 3 +++ 1 file changed, 3 insertions(+)
Quoted 15 lines
scripts/qmp/qmp-shell +3
-0@@ -265,6 +265,9 @@ class QMPShell(qmp.QEMUMonitorProtocol): def show_banner(self, msg='Welcome to the QMP low-level shell!'): print msg + if not self._greeting: + print 'Connected' + return version = self._greeting['QMP']['version']['qemu'] print 'Connected to QEMU %d.%d.%d\n' % (version['major'],version['minor'],version['micro'])
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH 4/4 qmp-shell: improve help
In reply to Marc-André LureauDescribe the arguments & fix the tool name.
--- scripts/qmp/qmp-shell | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
scripts/qmp/qmp-shell +5 -1
@@ -375,7 +375,11 @@ def die(msg): def fail_cmdline(option=None): if option: sys.stderr.write('ERROR: bad command-line option \'%s\'\n' % option) - sys.stderr.write('qemu-shell [ -v ] [ -p ] [ -H ] [ -N ] < UNIX socket path> | < TCP address:port >\n') + sys.stderr.write('qmp-shell [ -v ] [ -p ] [ -H ] [ -N ] < UNIX socket path> | < TCP address:port >\n') + sys.stderr.write(' -v Verbose (echo command sent and received)\n') + sys.stderr.write(' -p Pretty-print JSON\n') + sys.stderr.write(' -H Use HMP interface\n') + sys.stderr.write(' -N Skip negotiate (for qemu-ga)\n') sys.exit(1) def main():
Signature · 1 line
2.12.0.191.gc5d8de91d
Re: [Qemu-devel] [PATCH 4/4] qmp-shell: improve help
Quoted 6 lines · Marc-André Lureau
Describe the arguments & fix the tool name.
Signed-off-by Marc-André Lureau <[email protected]>--- scripts/qmp/qmp-shell | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Quoted 19 lines
scripts/qmp/qmp-shell +5
-1@@ -375,7 +375,11 @@ def die(msg): def fail_cmdline(option=None): if option: sys.stderr.write('ERROR: bad command-line option \'%s\'\n' % option) - sys.stderr.write('qemu-shell [ -v ] [ -p ] [ -H ] [ -N ] < UNIX socket path> | < TCP address:port >\n') + sys.stderr.write('qmp-shell [ -v ] [ -p ] [ -H ] [ -N ] < UNIX socket path> | < TCP address:port >\n') + sys.stderr.write(' -v Verbose (echo command sent and received)\n') + sys.stderr.write(' -p Pretty-print JSON\n') + sys.stderr.write(' -H Use HMP interface\n') + sys.stderr.write(' -N Skip negotiate (for qemu-ga)\n') sys.exit(1) def main():
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [Qemu-devel] [PATCH 4/4] qmp-shell: improve help
In reply to Marc-André LureauQuoted 14 lines · Marc-André Lureau
Describe the arguments & fix the tool name.
Signed-off-by Marc-André Lureau <[email protected]>--- scripts/qmp/qmp-shell | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)scripts/qmp/qmp-shell +0
-0@@ -375,7 +375,11 @@ def die(msg): def fail_cmdline(option=None): if option:
scripts/qmp/qmp-shell def die(msg): · line 385
Quoted 10 lines
scripts/qmp/qmp-shell +5
-1sys.stderr.write('ERROR: bad command-line option \'%s\'\n' % option) - sys.stderr.write('qemu-shell [ -v ] [ -p ] [ -H ] [ -N ] < UNIX socket path> | < TCP address:port >\n') + sys.stderr.write('qmp-shell [ -v ] [ -p ] [ -H ] [ -N ] < UNIX socket path> | < TCP address:port >\n') + sys.stderr.write(' -v Verbose (echo command sent and received)\n') + sys.stderr.write(' -p Pretty-print JSON\n') + sys.stderr.write(' -H Use HMP interface\n') + sys.stderr.write(' -N Skip negotiate (for qemu-ga)\n') sys.exit(1) def main():
Given Python modules like argparse, doing option parsing by hand is basically stupid. I'll take this patch anyway, because it improves help without making the program appreciably stupider.
Markus Armbruster
AppliedQuoted 5 lines · Marc-André Lureau
Hi,
This series adds a -N option to skip negotiate phase that qemu-ga doesn't implement. This allows to use qmp-shell with qemu-ga for testing.
Applied to qapi-next, thanks!