On 03/23/2017 05:55 AM, Markus Armbruster wrote: > We use InetSocketAddress in the QAPI schema. However, the code > doesn't use inet_connect_saddr(), but formats "host" and "port" into a > configuration string for rados_conf_set(). Thus, members "numeric", > "to", "ipv4" and "ipv6" are silently ignored. Not nice. > > Factor a suitable InetSocketAddressBase out of InetSocketAddress, and > use that. "numeric", "to", "ipv4" and "ipv6" are now rejected. > > Signed-off-by: Markus Armbruster <[email protected]> > --- > qapi-schema.json | 21 ++++++++++++++------- > qapi/block-core.json | 2 +- > 2 files changed, 15 insertions(+), 8 deletions(-) > > diff --git a/qapi-schema.json b/qapi-schema.json > index 68a4327..b921994 100644 > --- a/qapi-schema.json > +++ b/qapi-schema.json > @@ -4051,19 +4051,27 @@ > 'data': [ 'all', 'rx', 'tx' ] } > > ## > +# @InetSocketAddressBase: > +# > +# @host: host part of the address > +# @port: port part of the address > +##
No Since: - but we've argued that 'Since' on types is somewhat awkward
anyways, so I'm fine with it.
> +{ 'struct': 'InetSocketAddressBase',
> + 'data': {
> + 'host': 'str',
> + 'port': 'str' } }
> +
> +##
> @@ -4072,9 +4080,8 @@
> # Since: 1.3
> ##
> { 'struct': 'InetSocketAddress',
> + 'base': 'InetSocketAddressBase',
> 'data': {
> - 'host': 'str',
> - 'port': 'str',
> '*numeric': 'bool',
> '*to': 'uint16',
> '*ipv4': 'bool',
Slick example of how to split out the common portion into a base class
when refactoring (now I can point the thread on IOThrottle back to this
patch).
> diff --git a/qapi/block-core.json b/qapi/block-core.json
> index fe1e40f..a57c9e8 100644
> --- a/qapi/block-core.json
> +++ b/qapi/block-core.json
> @@ -2641,7 +2641,7 @@
> '*conf': 'str',
> '*snapshot': 'str',
> '*user': 'str',
> - '*server': ['InetSocketAddress'],
> + '*server': ['InetSocketAddressBase'],
> '*auth-supported': ['RbdAuthMethod'],
> '*password-secret': 'str' } }
>
>
Reviewed-by: Eric Blake <[email protected]>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
