* [Qemu-devel] [PATCH 1/2] scripts: qom-*: add network syntax
@ 2015-05-13 12:14 ` Martin Cerveny
0 siblings, 0 replies; 26+ messages in thread
From: Martin Cerveny @ 2015-05-13 12:14 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, 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(-)
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):
--
1.7.4.1
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [Qemu-trivial] [Qemu-devel] [PATCH 1/2] scripts: qom-*: add network syntax
2015-05-13 12:14 ` [Qemu-devel] " Martin Cerveny
@ 2015-05-19 12:51 ` Andreas Färber
-1 siblings, 0 replies; 26+ messages in thread
From: Andreas Färber @ 2015-05-19 12:51 UTC (permalink / raw)
To: Martin Cerveny, qemu-devel
Cc: qemu-trivial, Paolo Bonzini, Eric Blake, Markus Armbruster,
Luiz Capitulino
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)
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [Qemu-devel] [PATCH 1/2] scripts: qom-*: add network syntax
@ 2015-05-19 12:51 ` Andreas Färber
0 siblings, 0 replies; 26+ messages in thread
From: Andreas Färber @ 2015-05-19 12:51 UTC (permalink / raw)
To: Martin Cerveny, qemu-devel
Cc: qemu-trivial, Paolo Bonzini, Markus Armbruster, Luiz Capitulino
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)
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [Qemu-trivial] [Qemu-devel] [PATCH 1/2] scripts: qom-*: add network syntax
2015-05-19 12:51 ` Andreas Färber
@ 2015-05-19 13:56 ` Eric Blake
-1 siblings, 0 replies; 26+ messages in thread
From: Eric Blake @ 2015-05-19 13:56 UTC (permalink / raw)
To: Andreas Färber, Martin Cerveny, qemu-devel
Cc: qemu-trivial, Paolo Bonzini, Markus Armbruster, Luiz Capitulino
[-- Attachment #1: Type: text/plain, Size: 1245 bytes --]
On 05/19/2015 06:51 AM, Andreas Färber wrote:
> 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?
That disqualifies me (still a python newbie), but I still see something
questionable:
>>
>> -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 )
Won't that mishandle IPv6 connections, such as something like [::1]:8000
for connecting to port 8000 on localhost, since it splits into more than
2 pieces when splitting on :?
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [Qemu-devel] [PATCH 1/2] scripts: qom-*: add network syntax
@ 2015-05-19 13:56 ` Eric Blake
0 siblings, 0 replies; 26+ messages in thread
From: Eric Blake @ 2015-05-19 13:56 UTC (permalink / raw)
To: Andreas Färber, Martin Cerveny, qemu-devel
Cc: qemu-trivial, Paolo Bonzini, Markus Armbruster, Luiz Capitulino
[-- Attachment #1: Type: text/plain, Size: 1245 bytes --]
On 05/19/2015 06:51 AM, Andreas Färber wrote:
> 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?
That disqualifies me (still a python newbie), but I still see something
questionable:
>>
>> -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 )
Won't that mishandle IPv6 connections, such as something like [::1]:8000
for connecting to port 8000 on localhost, since it splits into more than
2 pieces when splitting on :?
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [Qemu-trivial] [Qemu-devel] [PATCH 1/2] scripts: qom-*: add network syntax
2015-05-19 13:56 ` Eric Blake
@ 2015-05-19 14:12 ` Martin Cerveny
-1 siblings, 0 replies; 26+ messages in thread
From: Martin Cerveny @ 2015-05-19 14:12 UTC (permalink / raw)
To: Eric Blake
Cc: qemu-devel, qemu-trivial, Markus Armbruster, Luiz Capitulino,
Martin Cerveny, Paolo Bonzini, Andreas Färber
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1402 bytes --]
Hello.
On Tue, 19 May 2015, Eric Blake wrote:
> On 05/19/2015 06:51 AM, Andreas Färber wrote:
>> 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?
>
> That disqualifies me (still a python newbie), but I still see something
> questionable:
>
>>>
>>> -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 )
>
> Won't that mishandle IPv6 connections, such as something like [::1]:8000
> for connecting to port 8000 on localhost, since it splits into more than
> 2 pieces when splitting on :?
Yes, this is problem, but I copy-paste the same construct from
scripts/qmp/qmp-shell to be compatible.
Is the IPv6 support for utilities mandatory ?
If yes I can make V2.
M.C>
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [Qemu-devel] [PATCH 1/2] scripts: qom-*: add network syntax
@ 2015-05-19 14:12 ` Martin Cerveny
0 siblings, 0 replies; 26+ messages in thread
From: Martin Cerveny @ 2015-05-19 14:12 UTC (permalink / raw)
To: Eric Blake
Cc: qemu-devel, qemu-trivial, Markus Armbruster, Luiz Capitulino,
Martin Cerveny, Paolo Bonzini, Andreas Färber
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1402 bytes --]
Hello.
On Tue, 19 May 2015, Eric Blake wrote:
> On 05/19/2015 06:51 AM, Andreas Färber wrote:
>> 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?
>
> That disqualifies me (still a python newbie), but I still see something
> questionable:
>
>>>
>>> -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 )
>
> Won't that mishandle IPv6 connections, such as something like [::1]:8000
> for connecting to port 8000 on localhost, since it splits into more than
> 2 pieces when splitting on :?
Yes, this is problem, but I copy-paste the same construct from
scripts/qmp/qmp-shell to be compatible.
Is the IPv6 support for utilities mandatory ?
If yes I can make V2.
M.C>
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [Qemu-trivial] [Qemu-devel] [PATCH 1/2] scripts: qom-*: add network syntax
2015-05-19 14:12 ` Martin Cerveny
@ 2015-05-19 14:17 ` Eric Blake
-1 siblings, 0 replies; 26+ messages in thread
From: Eric Blake @ 2015-05-19 14:17 UTC (permalink / raw)
To: Martin Cerveny
Cc: qemu-devel, qemu-trivial, Markus Armbruster, Luiz Capitulino,
Paolo Bonzini, Andreas Färber
[-- Attachment #1: Type: text/plain, Size: 1683 bytes --]
On 05/19/2015 08:12 AM, Martin Cerveny wrote:
> Hello.
>
> On Tue, 19 May 2015, Eric Blake wrote:
>> On 05/19/2015 06:51 AM, Andreas Färber wrote:
>>> 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?
>>>> +if len(connection) == 2:
>>>> + try:
>>>> + port = int(connection[1])
>>>> + except ValueError:
>>>> + raise QMPBadPort
>>>> + connection = ( connection[0], port )
>>
>> Won't that mishandle IPv6 connections, such as something like [::1]:8000
>> for connecting to port 8000 on localhost, since it splits into more than
>> 2 pieces when splitting on :?
>
> Yes, this is problem, but I copy-paste the same construct from
> scripts/qmp/qmp-shell to be compatible.
Might be worth mentioning that, as justification in the commit message.
> Is the IPv6 support for utilities mandatory ?
I don't have any strong feelings about it (I'm okay if you don't). But
others might.
> If yes I can make V2.
If so, it would be good to fix qmp-shell, too - which makes it sound
like it would be a separate commit.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] scripts: qom-*: add network syntax
@ 2015-05-19 14:17 ` Eric Blake
0 siblings, 0 replies; 26+ messages in thread
From: Eric Blake @ 2015-05-19 14:17 UTC (permalink / raw)
To: Martin Cerveny
Cc: qemu-devel, qemu-trivial, Markus Armbruster, Luiz Capitulino,
Paolo Bonzini, Andreas Färber
[-- Attachment #1: Type: text/plain, Size: 1683 bytes --]
On 05/19/2015 08:12 AM, Martin Cerveny wrote:
> Hello.
>
> On Tue, 19 May 2015, Eric Blake wrote:
>> On 05/19/2015 06:51 AM, Andreas Färber wrote:
>>> 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?
>>>> +if len(connection) == 2:
>>>> + try:
>>>> + port = int(connection[1])
>>>> + except ValueError:
>>>> + raise QMPBadPort
>>>> + connection = ( connection[0], port )
>>
>> Won't that mishandle IPv6 connections, such as something like [::1]:8000
>> for connecting to port 8000 on localhost, since it splits into more than
>> 2 pieces when splitting on :?
>
> Yes, this is problem, but I copy-paste the same construct from
> scripts/qmp/qmp-shell to be compatible.
Might be worth mentioning that, as justification in the commit message.
> Is the IPv6 support for utilities mandatory ?
I don't have any strong feelings about it (I'm okay if you don't). But
others might.
> If yes I can make V2.
If so, it would be good to fix qmp-shell, too - which makes it sound
like it would be a separate commit.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-trivial] [Qemu-devel] [PATCH 1/2] scripts: qom-*: add network syntax
2015-05-19 14:17 ` Eric Blake
@ 2015-05-19 14:23 ` Andreas Färber
-1 siblings, 0 replies; 26+ messages in thread
From: Andreas Färber @ 2015-05-19 14:23 UTC (permalink / raw)
To: Eric Blake, Martin Cerveny
Cc: qemu-trivial, Markus Armbruster, Paolo Bonzini, qemu-devel,
Luiz Capitulino
[-- Attachment #1: Type: text/plain, Size: 1939 bytes --]
Am 19.05.2015 um 16:17 schrieb Eric Blake:
> On 05/19/2015 08:12 AM, Martin Cerveny wrote:
>> Hello.
>>
>> On Tue, 19 May 2015, Eric Blake wrote:
>>> On 05/19/2015 06:51 AM, Andreas Färber wrote:
>>>> 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?
>
>>>>> +if len(connection) == 2:
>>>>> + try:
>>>>> + port = int(connection[1])
>>>>> + except ValueError:
>>>>> + raise QMPBadPort
>>>>> + connection = ( connection[0], port )
>>>
>>> Won't that mishandle IPv6 connections, such as something like [::1]:8000
>>> for connecting to port 8000 on localhost, since it splits into more than
>>> 2 pieces when splitting on :?
>>
>> Yes, this is problem, but I copy-paste the same construct from
>> scripts/qmp/qmp-shell to be compatible.
>
> Might be worth mentioning that, as justification in the commit message.
>
>> Is the IPv6 support for utilities mandatory ?
>
> I don't have any strong feelings about it (I'm okay if you don't). But
> others might.
>
>> If yes I can make V2.
>
> If so, it would be good to fix qmp-shell, too - which makes it sound
> like it would be a separate commit.
Is there a chance this can be fixed in a way that we don't need to
replicate that code? :)
Andreas
--
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Dilip Upmanyu, Graham Norton; HRB
21284 (AG Nürnberg)
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] scripts: qom-*: add network syntax
@ 2015-05-19 14:23 ` Andreas Färber
0 siblings, 0 replies; 26+ messages in thread
From: Andreas Färber @ 2015-05-19 14:23 UTC (permalink / raw)
To: Eric Blake, Martin Cerveny
Cc: qemu-trivial, Markus Armbruster, Paolo Bonzini, qemu-devel,
Luiz Capitulino
[-- Attachment #1: Type: text/plain, Size: 1939 bytes --]
Am 19.05.2015 um 16:17 schrieb Eric Blake:
> On 05/19/2015 08:12 AM, Martin Cerveny wrote:
>> Hello.
>>
>> On Tue, 19 May 2015, Eric Blake wrote:
>>> On 05/19/2015 06:51 AM, Andreas Färber wrote:
>>>> 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?
>
>>>>> +if len(connection) == 2:
>>>>> + try:
>>>>> + port = int(connection[1])
>>>>> + except ValueError:
>>>>> + raise QMPBadPort
>>>>> + connection = ( connection[0], port )
>>>
>>> Won't that mishandle IPv6 connections, such as something like [::1]:8000
>>> for connecting to port 8000 on localhost, since it splits into more than
>>> 2 pieces when splitting on :?
>>
>> Yes, this is problem, but I copy-paste the same construct from
>> scripts/qmp/qmp-shell to be compatible.
>
> Might be worth mentioning that, as justification in the commit message.
>
>> Is the IPv6 support for utilities mandatory ?
>
> I don't have any strong feelings about it (I'm okay if you don't). But
> others might.
>
>> If yes I can make V2.
>
> If so, it would be good to fix qmp-shell, too - which makes it sound
> like it would be a separate commit.
Is there a chance this can be fixed in a way that we don't need to
replicate that code? :)
Andreas
--
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Dilip Upmanyu, Graham Norton; HRB
21284 (AG Nürnberg)
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-trivial] [Qemu-devel] [PATCH 1/2] scripts: qom-*: add network syntax
2015-05-13 12:14 ` [Qemu-devel] " Martin Cerveny
@ 2015-05-19 14:16 ` Daniel P. Berrange
-1 siblings, 0 replies; 26+ messages in thread
From: Daniel P. Berrange @ 2015-05-19 14:16 UTC (permalink / raw)
To: Martin Cerveny; +Cc: qemu-trivial, qemu-devel
On Wed, May 13, 2015 at 02:14:53PM +0200, Martin Cerveny wrote:
> 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(-)
>
> 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)
Rather than duplicate this code in every single command line tool
I think it'd be better to add a static method to QEMUMonitorProtocol
eg
@staticmethod
def from_address_string(addr_string):
connection = socket_path.split(':')
if len(connection) == 2:
try:
port = int(connection[1])
except ValueError:
raise QMPBadPort
connection = ( connection[0], port )
else:
connection = addr_string
return QEMUMonitorProtocol(connection)
Then each script can just do
srv = QEMUMonitorProtocol.from_address_string(
os.environ['QMP_SOCKET'])
Really the from_address_string should check for None eg
if addr_string is None:
print >>sys.stderr "Address string is required"
sys.exit(1)
And as Eric says, splitting on ':' doesn't work with
IPv6
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [Qemu-devel] [PATCH 1/2] scripts: qom-*: add network syntax
@ 2015-05-19 14:16 ` Daniel P. Berrange
0 siblings, 0 replies; 26+ messages in thread
From: Daniel P. Berrange @ 2015-05-19 14:16 UTC (permalink / raw)
To: Martin Cerveny; +Cc: qemu-trivial, qemu-devel
On Wed, May 13, 2015 at 02:14:53PM +0200, Martin Cerveny wrote:
> 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(-)
>
> 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)
Rather than duplicate this code in every single command line tool
I think it'd be better to add a static method to QEMUMonitorProtocol
eg
@staticmethod
def from_address_string(addr_string):
connection = socket_path.split(':')
if len(connection) == 2:
try:
port = int(connection[1])
except ValueError:
raise QMPBadPort
connection = ( connection[0], port )
else:
connection = addr_string
return QEMUMonitorProtocol(connection)
Then each script can just do
srv = QEMUMonitorProtocol.from_address_string(
os.environ['QMP_SOCKET'])
Really the from_address_string should check for None eg
if addr_string is None:
print >>sys.stderr "Address string is required"
sys.exit(1)
And as Eric says, splitting on ':' doesn't work with
IPv6
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
^ permalink raw reply [flat|nested] 26+ messages in thread