qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: Martin Cerveny <M.Cerveny@computer.org>, qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Luiz Capitulino <lcapitulino@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 1/2] scripts: qom-*: add network syntax
Date: Tue, 19 May 2015 14:51:37 +0200	[thread overview]
Message-ID: <555B31D9.2090806@suse.de> (raw)
In-Reply-To: <1431519294-8873-2-git-send-email-M.Cerveny@computer.org>

Am 13.05.2015 um 14:14 schrieb Martin Cerveny:
> Add network syntax parsing (ip address, port) to qom-* scripts.
> 
> Signed-off-by: Martin Cerveny <M.Cerveny@computer.org>
> ---
>  scripts/qmp/qom-fuse |   13 ++++++++++++-
>  scripts/qmp/qom-get  |   12 +++++++++++-
>  scripts/qmp/qom-list |   12 +++++++++++-
>  scripts/qmp/qom-set  |   12 +++++++++++-
>  scripts/qmp/qom-tree |   12 +++++++++++-
>  5 files changed, 56 insertions(+), 5 deletions(-)

Could some Python guru please take a look at this?

Martin, could you clarify what this fixes or adds exactly so that we can
extend the commit message accordingly?

Thanks,
Andreas

> 
> diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse
> index 5c6754a..d49f36d 100755
> --- a/scripts/qmp/qom-fuse
> +++ b/scripts/qmp/qom-fuse
> @@ -134,5 +134,16 @@ class QOMFS(Fuse):
>  if __name__ == '__main__':
>      import sys, os
>  
> -    fs = QOMFS(QEMUMonitorProtocol(os.environ['QMP_SOCKET']))
> +    socket_path = os.environ['QMP_SOCKET']
> +    connection = socket_path.split(':')
> +    if len(connection) == 2:
> +        try:
> +            port = int(connection[1])
> +        except ValueError:
> +            raise QMPBadPort
> +        connection = ( connection[0], port )
> +    else:
> +        connection = socket_path
> +
> +    fs = QOMFS(QEMUMonitorProtocol(connection))
>      fs.main(sys.argv)
> diff --git a/scripts/qmp/qom-get b/scripts/qmp/qom-get
> index 0172c69..f12eb52 100755
> --- a/scripts/qmp/qom-get
> +++ b/scripts/qmp/qom-get
> @@ -56,7 +56,17 @@ if len(args) > 0:
>  else:
>      usage_error("not enough arguments")
>  
> -srv = QEMUMonitorProtocol(socket_path)
> +connection = socket_path.split(':')
> +if len(connection) == 2:
> +    try:
> +         port = int(connection[1])
> +    except ValueError:
> +         raise QMPBadPort
> +    connection = ( connection[0], port )
> +else:
> +    connection = socket_path
> +
> +srv = QEMUMonitorProtocol(connection)
>  srv.connect()
>  
>  rsp = srv.command('qom-get', path=path, property=prop)
> diff --git a/scripts/qmp/qom-list b/scripts/qmp/qom-list
> index 1e7cc6c..fadcce4 100755
> --- a/scripts/qmp/qom-list
> +++ b/scripts/qmp/qom-list
> @@ -48,7 +48,17 @@ if not socket_path:
>      else:
>          usage_error("no QMP socket path or address given");
>  
> -srv = QEMUMonitorProtocol(socket_path)
> +connection = socket_path.split(':')
> +if len(connection) == 2:
> +    try:
> +         port = int(connection[1])
> +    except ValueError:
> +         raise QMPBadPort
> +    connection = ( connection[0], port )
> +else:
> +    connection = socket_path
> +
> +srv = QEMUMonitorProtocol(connection)
>  srv.connect()
>  
>  if len(args) == 0:
> diff --git a/scripts/qmp/qom-set b/scripts/qmp/qom-set
> index 54ecfec..b05fae3 100755
> --- a/scripts/qmp/qom-set
> +++ b/scripts/qmp/qom-set
> @@ -58,7 +58,17 @@ if len(args) > 1:
>  else:
>      usage_error("not enough arguments")
>  
> -srv = QEMUMonitorProtocol(socket_path)
> +connection = socket_path.split(':')
> +if len(connection) == 2:
> +    try:
> +         port = int(connection[1])
> +    except ValueError:
> +         raise QMPBadPort
> +    connection = ( connection[0], port )
> +else:
> +    connection = socket_path
> +
> +srv = QEMUMonitorProtocol(connection)
>  srv.connect()
>  
>  print srv.command('qom-set', path=path, property=prop, value=sys.argv[2])
> diff --git a/scripts/qmp/qom-tree b/scripts/qmp/qom-tree
> index aea11d4..07f8a9d 100755
> --- a/scripts/qmp/qom-tree
> +++ b/scripts/qmp/qom-tree
> @@ -50,7 +50,17 @@ if not socket_path:
>      else:
>          usage_error("no QMP socket path or address given");
>  
> -srv = QEMUMonitorProtocol(socket_path)
> +connection = socket_path.split(':')
> +if len(connection) == 2:
> +    try:
> +         port = int(connection[1])
> +    except ValueError:
> +         raise QMPBadPort
> +    connection = ( connection[0], port )
> +else:
> +    connection = socket_path
> +
> +srv = QEMUMonitorProtocol(connection)
>  srv.connect()
>  
>  def list_node(path):
> 


-- 
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Dilip Upmanyu, Graham Norton; HRB
21284 (AG Nürnberg)

  reply	other threads:[~2015-05-19 12:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-13 12:14 [Qemu-devel] [PATCH 0/2] Some fixes to qom scripts Martin Cerveny
2015-05-13 12:14 ` [Qemu-devel] [PATCH 1/2] scripts: qom-*: add network syntax Martin Cerveny
2015-05-19 12:51   ` Andreas Färber [this message]
2015-05-19 13:56     ` Eric Blake
2015-05-19 14:12       ` Martin Cerveny
2015-05-19 14:17         ` Eric Blake
2015-05-19 14:23           ` Andreas Färber
2015-05-19 14:16   ` Daniel P. Berrange
2015-05-13 12:14 ` [Qemu-devel] [PATCH 2/2] scripts: qom-tree: add support of path as argument Martin Cerveny
2015-05-14 10:00   ` Paolo Bonzini
2015-05-14 11:41     ` Martin Cerveny
2015-05-14 11:47       ` Paolo Bonzini
2015-05-19 12:47         ` Andreas Färber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=555B31D9.2090806@suse.de \
    --to=afaerber@suse.de \
    --cc=M.Cerveny@computer.org \
    --cc=armbru@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).