diff mbox

[20/25] qapi: add socket address types

Message ID 1349877786-23514-21-git-send-email-pbonzini@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini Oct. 10, 2012, 2:03 p.m. UTC
Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 qapi-schema.json | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file modificato, 53 inserzioni(+)

Comments

Markus Armbruster Oct. 17, 2012, 4:43 p.m. UTC | #1
Paolo Bonzini <pbonzini@redhat.com> writes:

> Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  qapi-schema.json | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file modificato, 53 inserzioni(+)
>
> diff --git a/qapi-schema.json b/qapi-schema.json
> index f9dbdae..d40b5fc 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -2505,6 +2505,59 @@
>      'opts': 'NetClientOptions' } }
>  
>  ##
> +# @IPSocketAddress
> +#
> +# Captures the destination address of an IP socket

What's a "destination address of an IP socket"?

> +#
> +# @host: host part of the address
> +#
> +# @port: port part of the address, or lowest port if @to is present
> +#
> +# @to: highest port to try
> +#
> +# @ipv4: whether to accept IPv4 addresses, default try both IPv4 and IPv6
> +#        #optional
> +#
> +# @ipv6: whether to accept IPv6 addresses, default try both IPv4 and IPv6
> +#        #optional
> +#
> +# Since 1.3
> +##
> +{ 'type': 'IPSocketAddress',
> +  'data': {
> +    'host': 'str',
> +    'port': 'str',
> +    '*to': 'uint16',

Two port members, one is 'str', the other is 'uint16'.  Ugly.

> +    '*ipv4': 'bool',
> +    '*ipv6': 'bool' } }
> +
> +##
> +# @UnixSocketAddress
> +#
> +# Captures the destination address of a Unix socket

What's a "destination address of a Unix socket"?

> +#
> +# @path: filesystem path to use
> +#
> +# Since 1.3
> +##
> +{ 'type': 'UnixSocketAddress',
> +  'data': {
> +    'path': 'str' } }
> +
> +##
> +# @SocketAddress
> +#
> +# Captures the address of a socket, which could also be a named file descriptor
> +#
> +# Since 1.3
> +##
> +{ 'union': 'SocketAddress',
> +  'data': {
> +    'inet': 'IPSocketAddress',

Call it InetSocketAddress, like 'inet', AF_INET, PF_INET, and so forth.

> +    'unix': 'UnixSocketAddress',
> +    'fd': 'String' } }
> +
> +##
>  # @getfd:
>  #
>  # Receive a file descriptor via SCM rights and assign it a name
Paolo Bonzini Oct. 17, 2012, 4:48 p.m. UTC | #2
Il 17/10/2012 18:43, Markus Armbruster ha scritto:
> Paolo Bonzini <pbonzini@redhat.com> writes:
> 
>> Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>>  qapi-schema.json | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>>  1 file modificato, 53 inserzioni(+)
>>
>> diff --git a/qapi-schema.json b/qapi-schema.json
>> index f9dbdae..d40b5fc 100644
>> --- a/qapi-schema.json
>> +++ b/qapi-schema.json
>> @@ -2505,6 +2505,59 @@
>>      'opts': 'NetClientOptions' } }
>>  
>>  ##
>> +# @IPSocketAddress
>> +#
>> +# Captures the destination address of an IP socket
> 
> What's a "destination address of an IP socket"?

Any suggestions?

>> +#
>> +# @host: host part of the address
>> +#
>> +# @port: port part of the address, or lowest port if @to is present
>> +#
>> +# @to: highest port to try
>> +#
>> +# @ipv4: whether to accept IPv4 addresses, default try both IPv4 and IPv6
>> +#        #optional
>> +#
>> +# @ipv6: whether to accept IPv6 addresses, default try both IPv4 and IPv6
>> +#        #optional
>> +#
>> +# Since 1.3
>> +##
>> +{ 'type': 'IPSocketAddress',
>> +  'data': {
>> +    'host': 'str',
>> +    'port': 'str',
>> +    '*to': 'uint16',
> 
> Two port members, one is 'str', the other is 'uint16'.  Ugly.

This is because port can be a service name.  Using a union was deemed
overkill.

>> +    '*ipv4': 'bool',
>> +    '*ipv6': 'bool' } }
>> +
>> +##
>> +# @UnixSocketAddress
>> +#
>> +# Captures the destination address of a Unix socket
> 
> What's a "destination address of a Unix socket"?
> 
>> +#
>> +# @path: filesystem path to use
>> +#
>> +# Since 1.3
>> +##
>> +{ 'type': 'UnixSocketAddress',
>> +  'data': {
>> +    'path': 'str' } }
>> +
>> +##
>> +# @SocketAddress
>> +#
>> +# Captures the address of a socket, which could also be a named file descriptor
>> +#
>> +# Since 1.3
>> +##
>> +{ 'union': 'SocketAddress',
>> +  'data': {
>> +    'inet': 'IPSocketAddress',
> 
> Call it InetSocketAddress, like 'inet', AF_INET, PF_INET, and so forth.

Ok.  Luiz, at this point please unqueue the series.  I'll send a pull
request myself to Anthony.

Paolo

>> +    'unix': 'UnixSocketAddress',
>> +    'fd': 'String' } }
>> +
>> +##
>>  # @getfd:
>>  #
>>  # Receive a file descriptor via SCM rights and assign it a name
Luiz Capitulino Oct. 17, 2012, 4:50 p.m. UTC | #3
On Wed, 17 Oct 2012 18:48:08 +0200
Paolo Bonzini <pbonzini@redhat.com> wrote:

> Il 17/10/2012 18:43, Markus Armbruster ha scritto:
> > Paolo Bonzini <pbonzini@redhat.com> writes:
> > 
> >> Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
> >> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> >> ---
> >>  qapi-schema.json | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> >>  1 file modificato, 53 inserzioni(+)
> >>
> >> diff --git a/qapi-schema.json b/qapi-schema.json
> >> index f9dbdae..d40b5fc 100644
> >> --- a/qapi-schema.json
> >> +++ b/qapi-schema.json
> >> @@ -2505,6 +2505,59 @@
> >>      'opts': 'NetClientOptions' } }
> >>  
> >>  ##
> >> +# @IPSocketAddress
> >> +#
> >> +# Captures the destination address of an IP socket
> > 
> > What's a "destination address of an IP socket"?
> 
> Any suggestions?
> 
> >> +#
> >> +# @host: host part of the address
> >> +#
> >> +# @port: port part of the address, or lowest port if @to is present
> >> +#
> >> +# @to: highest port to try
> >> +#
> >> +# @ipv4: whether to accept IPv4 addresses, default try both IPv4 and IPv6
> >> +#        #optional
> >> +#
> >> +# @ipv6: whether to accept IPv6 addresses, default try both IPv4 and IPv6
> >> +#        #optional
> >> +#
> >> +# Since 1.3
> >> +##
> >> +{ 'type': 'IPSocketAddress',
> >> +  'data': {
> >> +    'host': 'str',
> >> +    'port': 'str',
> >> +    '*to': 'uint16',
> > 
> > Two port members, one is 'str', the other is 'uint16'.  Ugly.
> 
> This is because port can be a service name.  Using a union was deemed
> overkill.
> 
> >> +    '*ipv4': 'bool',
> >> +    '*ipv6': 'bool' } }
> >> +
> >> +##
> >> +# @UnixSocketAddress
> >> +#
> >> +# Captures the destination address of a Unix socket
> > 
> > What's a "destination address of a Unix socket"?
> > 
> >> +#
> >> +# @path: filesystem path to use
> >> +#
> >> +# Since 1.3
> >> +##
> >> +{ 'type': 'UnixSocketAddress',
> >> +  'data': {
> >> +    'path': 'str' } }
> >> +
> >> +##
> >> +# @SocketAddress
> >> +#
> >> +# Captures the address of a socket, which could also be a named file descriptor
> >> +#
> >> +# Since 1.3
> >> +##
> >> +{ 'union': 'SocketAddress',
> >> +  'data': {
> >> +    'inet': 'IPSocketAddress',
> > 
> > Call it InetSocketAddress, like 'inet', AF_INET, PF_INET, and so forth.
> 
> Ok.  Luiz, at this point please unqueue the series.  I'll send a pull
> request myself to Anthony.

Done.
Markus Armbruster Oct. 19, 2012, 8:10 a.m. UTC | #4
Paolo Bonzini <pbonzini@redhat.com> writes:

> Il 17/10/2012 18:43, Markus Armbruster ha scritto:
>> Paolo Bonzini <pbonzini@redhat.com> writes:
>> 
>>> Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
>>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>>> ---
>>>  qapi-schema.json | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>>>  1 file modificato, 53 inserzioni(+)
>>>
>>> diff --git a/qapi-schema.json b/qapi-schema.json
>>> index f9dbdae..d40b5fc 100644
>>> --- a/qapi-schema.json
>>> +++ b/qapi-schema.json
>>> @@ -2505,6 +2505,59 @@
>>>      'opts': 'NetClientOptions' } }
>>>  
>>>  ##
>>> +# @IPSocketAddress
>>> +#
>>> +# Captures the destination address of an IP socket
>> 
>> What's a "destination address of an IP socket"?
>
> Any suggestions?

"socket address in the Internet namespace"?

Actually, it's either an address or an address range (when @to is
present).

>>> +#
>>> +# @host: host part of the address
>>> +#
>>> +# @port: port part of the address, or lowest port if @to is present
>>> +#
>>> +# @to: highest port to try
>>> +#
>>> +# @ipv4: whether to accept IPv4 addresses, default try both IPv4 and IPv6
>>> +#        #optional
>>> +#
>>> +# @ipv6: whether to accept IPv6 addresses, default try both IPv4 and IPv6
>>> +#        #optional
>>> +#
>>> +# Since 1.3
>>> +##
>>> +{ 'type': 'IPSocketAddress',
>>> +  'data': {
>>> +    'host': 'str',
>>> +    'port': 'str',
>>> +    '*to': 'uint16',
>> 
>> Two port members, one is 'str', the other is 'uint16'.  Ugly.
>
> This is because port can be a service name.  Using a union was deemed
> overkill.

Two ways to reduce the ugliness:

1. Make @to a string, too.  Yes, users don't normally want to specify
the upper bound as service name, but if a user wanted to, it would work
just fine.

2. Use a number of ports instead of an upper port bound: replace @to by
@port+@nports.

>>> +    '*ipv4': 'bool',
>>> +    '*ipv6': 'bool' } }
>>> +
>>> +##
>>> +# @UnixSocketAddress
>>> +#
>>> +# Captures the destination address of a Unix socket
>> 
>> What's a "destination address of a Unix socket"?

"Socket address in the local namespace"

[...]
>>> +#
>>> +# @path: filesystem path to use
>>> +#
>>> +# Since 1.3
>>> +##
>>> +{ 'type': 'UnixSocketAddress',
>>> +  'data': {
>>> +    'path': 'str' } }
>>> +
>>> +##
>>> +# @SocketAddress
>>> +#
>>> +# Captures the address of a socket, which could also be a named
>>> file descriptor
>>> +#
>>> +# Since 1.3
>>> +##
>>> +{ 'union': 'SocketAddress',
>>> +  'data': {
>>> +    'inet': 'IPSocketAddress',
>> 
>> Call it InetSocketAddress, like 'inet', AF_INET, PF_INET, and so forth.
>
> Ok.  Luiz, at this point please unqueue the series.  I'll send a pull
> request myself to Anthony.
>
> Paolo
>
>>> +    'unix': 'UnixSocketAddress',
>>> +    'fd': 'String' } }

'String'?  Do you mean 'str'?

>>> +
>>> +##
>>>  # @getfd:
>>>  #
>>>  # Receive a file descriptor via SCM rights and assign it a name
Paolo Bonzini Oct. 19, 2012, 8:39 a.m. UTC | #5
> >> Two port members, one is 'str', the other is 'uint16'.  Ugly.
> >
> > This is because port can be a service name.  Using a union was
> > deemed
> > overkill.
> 
> Two ways to reduce the ugliness:
> 
> 1. Make @to a string, too.  Yes, users don't normally want to specify
> the upper bound as service name, but if a user wanted to, it would
> work just fine.
> 
> 2. Use a number of ports instead of an upper port bound: replace @to
> by @port+@nports.

Both considered, but they make it an absolute pain to deal with the
current QemuOpts code that expects a @to and expects it to be an
integer.

> >>> +    '*ipv4': 'bool',
> >>> +    '*ipv6': 'bool' } }
> >>> +
> >>> +##
> >>> +# @UnixSocketAddress
> >>> +#
> >>> +# Captures the destination address of a Unix socket
> >> 
> >> What's a "destination address of a Unix socket"?
> 
> "Socket address in the local namespace"

Ok.

> >>> +    'unix': 'UnixSocketAddress',
> >>> +    'fd': 'String' } }
> 
> 'String'?  Do you mean 'str'?

'String' is a boxed 'str'.  It gives more freedom to extend the API
later in a backwards-compatible way.

Paolo
diff mbox

Patch

diff --git a/qapi-schema.json b/qapi-schema.json
index f9dbdae..d40b5fc 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -2505,6 +2505,59 @@ 
     'opts': 'NetClientOptions' } }
 
 ##
+# @IPSocketAddress
+#
+# Captures the destination address of an IP socket
+#
+# @host: host part of the address
+#
+# @port: port part of the address, or lowest port if @to is present
+#
+# @to: highest port to try
+#
+# @ipv4: whether to accept IPv4 addresses, default try both IPv4 and IPv6
+#        #optional
+#
+# @ipv6: whether to accept IPv6 addresses, default try both IPv4 and IPv6
+#        #optional
+#
+# Since 1.3
+##
+{ 'type': 'IPSocketAddress',
+  'data': {
+    'host': 'str',
+    'port': 'str',
+    '*to': 'uint16',
+    '*ipv4': 'bool',
+    '*ipv6': 'bool' } }
+
+##
+# @UnixSocketAddress
+#
+# Captures the destination address of a Unix socket
+#
+# @path: filesystem path to use
+#
+# Since 1.3
+##
+{ 'type': 'UnixSocketAddress',
+  'data': {
+    'path': 'str' } }
+
+##
+# @SocketAddress
+#
+# Captures the address of a socket, which could also be a named file descriptor
+#
+# Since 1.3
+##
+{ 'union': 'SocketAddress',
+  'data': {
+    'inet': 'IPSocketAddress',
+    'unix': 'UnixSocketAddress',
+    'fd': 'String' } }
+
+##
 # @getfd:
 #
 # Receive a file descriptor via SCM rights and assign it a name