From a1f93198020b8c043edab5292db39b52ac77f78b Mon Sep 17 00:00:00 2001
Signed-off-by: Zhang Chen <tgfbeta@me.com>
---
scripts/qmp/qmp | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/scripts/qmp/qmp b/scripts/qmp/qmp
index 6cb46fd..0e8ed19 100755
--- a/scripts/qmp/qmp
+++ b/scripts/qmp/qmp
@@ -63,6 +63,16 @@ def main(args):
if not path:
print("QMP path isn't set, use --path=qmp-monitor-address or set QMP_PATH")
return 1
+ tcp_addr = path.split(':')
+ if len(tcp_addr) == 2:
+ try:
+ port = int(tcp_addr[1])
+ except ValueError:
+ print("QMP path contains a non-numeric TCP port")
+ return 1
+ addr = ( tcp_addr[0], port )
+ else:
+ addr = path
if len(args):
command, args = args[0], args[1:]
@@ -74,7 +84,7 @@ def main(args):
if command in ['help']:
os.execlp('man', 'man', 'qmp')
- srv = QEMUMonitorProtocol(path)
+ srv = QEMUMonitorProtocol(addr)
srv.connect()
def do_command(srv, cmd, **kwds):
@@ -99,7 +109,7 @@ def main(args):
raise
return 0
- srv = QEMUMonitorProtocol(path)
+ srv = QEMUMonitorProtocol(addr)
srv.connect()
arguments = {}
--
2.7.4
On Tue, Aug 28, 2018 at 09:32:18PM +0800, Chen Zhang wrote:
> From a1f93198020b8c043edab5292db39b52ac77f78b Mon Sep 17 00:00:00 2001
>
> Signed-off-by: Zhang Chen <tgfbeta@me.com>
> ---
> scripts/qmp/qmp | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/qmp/qmp b/scripts/qmp/qmp
> index 6cb46fd..0e8ed19 100755
> --- a/scripts/qmp/qmp
> +++ b/scripts/qmp/qmp
> @@ -63,6 +63,16 @@ def main(args):
> if not path:
> print("QMP path isn't set, use --path=qmp-monitor-address or set QMP_PATH")
> return 1
> + tcp_addr = path.split(':')
> + if len(tcp_addr) == 2:
> + try:
> + port = int(tcp_addr[1])
> + except ValueError:
> + print("QMP path contains a non-numeric TCP port")
> + return 1
> + addr = ( tcp_addr[0], port )
> + else:
> + addr = path
I don't think this qualifies as trivial patch.
I'm not against extending scripts/qmp/qmp this way, but this
deserves some coordination to allow usage of QMP addresses that
are not unix sockets in other scripts too. Supporting libvirt's
qemu-monitor-command would be another use case for this. See:
https://www.mail-archive.com/qemu-block@nongnu.org/msg41351.html
I suggest adding a new option name (e.g. --tcp) to explicitly
tell the script you have a hostname:port pair, for simplicity.
It doesn't make sense to overload an option named "path" for
something that is not a path.
>
> if len(args):
> command, args = args[0], args[1:]
> @@ -74,7 +84,7 @@ def main(args):
> if command in ['help']:
> os.execlp('man', 'man', 'qmp')
>
> - srv = QEMUMonitorProtocol(path)
> + srv = QEMUMonitorProtocol(addr)
> srv.connect()
>
> def do_command(srv, cmd, **kwds):
> @@ -99,7 +109,7 @@ def main(args):
> raise
> return 0
>
> - srv = QEMUMonitorProtocol(path)
> + srv = QEMUMonitorProtocol(addr)
> srv.connect()
>
> arguments = {}
> --
> 2.7.4
>
--
Eduardo
© 2016 - 2025 Red Hat, Inc.