[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-trivial] [PATCH] Add support for TCP path/QMP_PATH in scripts/
From: |
Eduardo Habkost |
Subject: |
Re: [Qemu-trivial] [PATCH] Add support for TCP path/QMP_PATH in scripts/qmp/qmp |
Date: |
Wed, 29 Aug 2018 14:10:21 -0300 |
User-agent: |
Mutt/1.9.2 (2017-12-15) |
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 <address@hidden>
> ---
> 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/address@hidden/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