From: Markus Armbruster <armbru@redhat.com>
To: Laurent Vivier <lvivier@redhat.com>
Cc: qemu-devel@nongnu.org, "Daniel P. Berrangé" <berrange@redhat.com>,
"Jason Wang" <jasowang@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Eric Blake" <eblake@redhat.com>,
"Stefano Brivio" <sbrivio@redhat.com>
Subject: Re: [PATCH v6 05/13] qapi: net: add stream and dgram netdevs
Date: Wed, 06 Jul 2022 16:23:00 +0200 [thread overview]
Message-ID: <87mtdml3qz.fsf@pond.sub.org> (raw)
In-Reply-To: <20220706062847.1396719-6-lvivier@redhat.com> (Laurent Vivier's message of "Wed, 6 Jul 2022 08:28:39 +0200")
Laurent Vivier <lvivier@redhat.com> writes:
> Copied from socket netdev file and modified to use SocketAddress
> to be able to introduce new features like unix socket.
>
> "udp" and "mcast" are squashed into dgram netdev, multicast is detected
> according to the IP address type.
> "listen" and "connect" modes are managed by stream netdev. An optional
> parameter "server" defines the mode (server by default)
>
> The two new types need to be parsed the modern way with -netdev, because
> with the traditional way, the "type" field of netdev structure collides with
> the "type" field of SocketAddress and prevents the correct evaluation of the
> command line option. Moreover the traditional way doesn't allow to use
> the same type (SocketAddress) several times with the -netdev option
> (needed to specify "local" and "remote" addresses).
>
> The previous commit paved the way for parsing the modern way, but
> omitted one detail: how to pick modern vs. traditional, in
> netdev_is_modern().
>
> We want to pick based on the value of parameter "type". But how to
> extract it from the option argument?
>
> Parsing the option argument, either the modern or the traditional way,
> extracts it for us, but only if parsing succeeds.
>
> If parsing fails, there is no good option. No matter which parser we
> pick, it'll be the wrong one for some arguments, and the error
> reporting will be confusing.
>
> Fortunately, the traditional parser accepts *anything* when called in
> a certain way. This maximizes our chance to extract the value of
> "type", and in turn minimizes the risk of confusing error reporting.
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
[...]
> diff --git a/qapi/net.json b/qapi/net.json
> index 9af11e9a3bb2..4c5245321947 100644
> --- a/qapi/net.json
> +++ b/qapi/net.json
> @@ -7,6 +7,7 @@
> ##
>
> { 'include': 'common.json' }
> +{ 'include': 'sockets.json' }
>
> ##
> # @set_link:
> @@ -566,6 +567,57 @@
> '*isolated': 'bool' },
> 'if': 'CONFIG_VMNET' }
>
> +##
> +# @NetdevStreamOptions:
> +#
> +# Configuration info for stream socket netdev
> +#
> +# @addr: socket address to listen on (server=true)
> +# or connect to (server=false)
> +# @server: create server socket (default: true)
> +#
> +# Only SocketAddress types 'inet' and 'fd' are supported.
> +#
> +# Since: 7.1
> +##
> +{ 'struct': 'NetdevStreamOptions',
> + 'data': {
> + 'addr': 'SocketAddress',
> + '*server': 'bool' } }
> +
> +##
> +# @NetdevDgramOptions:
> +#
> +# Configuration info for datagram socket netdev.
> +#
> +# @remote: remote address
> +# @local: local address
> +#
> +# Only SocketAddress types 'inet' and 'fd' are supported.
> +#
> +# The code checks there is at least one of these options and reports an error
> +# if not. If remote address is present and it's a multicast address, local
> +# address is optional. Otherwise local address is required and remote address
> +# is optional.
> +#
> +# Valid parameters combination table:
> +#
> +# @remote @local | okay?
> +# ----------------------------+--------
> +# absent absent | no
> +# absent present | yes
> +# multicast absent | yes
> +# multicast present | yes
> +# not multicast absent | no
> +# not multicast present | yes
You need to use suitable markup for the table. As is, it comes out like
remote local | okay? —————————-+——– absent absent | no absent present | yes multicast absent | yes multicast present | yes not multicast absent | no not multicast present | yes
in formatted documentation.
Possibly useful: https://pandemic-overview.readthedocs.io/en/latest/myGuides/reStructuredText-Tables-Examples.html
I created this table in my review of v4 to double-check I got the doc
text. Keep it only if *you* think it's useful. Feel free to delete it.
> +#
> +# Since: 7.1
> +##
> +{ 'struct': 'NetdevDgramOptions',
> + 'data': {
> + '*local': 'SocketAddress',
> + '*remote': 'SocketAddress' } }
> +
> ##
> # @NetClientDriver:
> #
> @@ -579,8 +631,9 @@
> # @vmnet-bridged since 7.1
> ##
> { 'enum': 'NetClientDriver',
> - 'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde',
> - 'bridge', 'hubport', 'netmap', 'vhost-user', 'vhost-vdpa',
> + 'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'stream',
> + 'dgram', 'vde', 'bridge', 'hubport', 'netmap', 'vhost-user',
> + 'vhost-vdpa',
> { 'name': 'vmnet-host', 'if': 'CONFIG_VMNET' },
> { 'name': 'vmnet-shared', 'if': 'CONFIG_VMNET' },
> { 'name': 'vmnet-bridged', 'if': 'CONFIG_VMNET' }] }
> @@ -610,6 +663,8 @@
> 'tap': 'NetdevTapOptions',
> 'l2tpv3': 'NetdevL2TPv3Options',
> 'socket': 'NetdevSocketOptions',
> + 'stream': 'NetdevStreamOptions',
> + 'dgram': 'NetdevDgramOptions',
> 'vde': 'NetdevVdeOptions',
> 'bridge': 'NetdevBridgeOptions',
> 'hubport': 'NetdevHubPortOptions',
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 377d22fbd82f..215a2615f13f 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -2722,6 +2722,18 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev,
> "-netdev socket,id=str[,fd=h][,udp=host:port][,localaddr=host:port]\n"
> " configure a network backend to connect to another network\n"
> " using an UDP tunnel\n"
> + "-netdev stream,id=str[,server=on|off],addr.type=inet,addr.host=host,addr.port=port\n"
> + "-netdev stream,id=str[,server=on|off],addr.type=fd,addr.str=h\n"
> + " configure a network backend to connect to another network\n"
> + " using a socket connection in stream mode.\n"
This part needs to match NetdevStreamOptions above.
Missing here: the optional members of InetSocketAddress: numeric, to,
ipv4, ... Do we care?
The next part needs to match NetdevDgramOptions above.
> + "-netdev dgram,id=str,remote.type=inet,remote.host=maddr,remote.port=port[,local.type=inet,local.host=addr]\n"
> + "-netdev dgram,id=str,remote.type=inet,remote.host=maddr,remote.port=port[,local.type=fd,local.str=h]\n"
> + " configure a network backend to connect to a multicast maddr and port\n"
> + " use ``local.host=addr`` to specify the host address to send packets from\n"
I figure this covers table rows
# @remote @local | okay?
# ----------------------------+--------
# multicast absent | yes
# multicast present | yes
for remote.type=inet and any local.type.
What about remote.type=fd?
> + "-netdev dgram,id=str,local.type=inet,local.host=addr,local.port=port[,remote.type=inet,remote.host=addr,remote.port=port]\n"
I figure this covers table rows
# absent present | yes
# not multicast present | yes
for *.type=inet.
> + "-netdev dgram,id=str,local.type=fd,local.str=h\n"
> + " configure a network backend to connect to another network\n"
> + " using an UDP tunnel\n"
I figure this covers table row
# absent present | yes
for local.type=fd.
Together, they cover table row
# absent present | yes
for any local.type. Good.
Table row
# not multicast present | yes
is only covered for *.type=inet. Could either of the types be fd?
> #ifdef CONFIG_VDE
> "-netdev vde,id=str[,sock=socketpath][,port=n][,group=groupname][,mode=octalmode]\n"
> " configure a network backend to connect to port 'n' of a vde switch\n"
next prev parent reply other threads:[~2022-07-06 14:23 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-06 6:28 [PATCH v6 00/13] qapi: net: add unix socket type support to netdev backend Laurent Vivier
2022-07-06 6:28 ` [PATCH v6 01/13] net: introduce convert_host_port() Laurent Vivier
2022-07-06 6:28 ` [PATCH v6 02/13] net: remove the @errp argument of net_client_inits() Laurent Vivier
2022-07-06 6:28 ` [PATCH v6 03/13] net: simplify net_client_parse() error management Laurent Vivier
2022-07-06 6:28 ` [PATCH v6 04/13] qapi: net: introduce a way to bypass qemu_opts_parse_noisily() Laurent Vivier
2022-07-06 6:28 ` [PATCH v6 05/13] qapi: net: add stream and dgram netdevs Laurent Vivier
2022-07-06 14:23 ` Markus Armbruster [this message]
2022-07-06 6:28 ` [PATCH v6 06/13] net: stream: Don't ignore EINVAL on netdev socket connection Laurent Vivier
2022-07-06 6:28 ` [PATCH v6 07/13] net: stream: add unix socket Laurent Vivier
2022-07-06 6:28 ` [PATCH v6 08/13] net: dgram: make dgram_dst generic Laurent Vivier
2022-07-06 6:28 ` [PATCH v6 09/13] net: dgram: move mcast specific code from net_socket_fd_init_dgram() Laurent Vivier
2022-07-06 6:28 ` [PATCH v6 10/13] net: dgram: add unix socket Laurent Vivier
2022-07-06 6:46 ` [PATCH v6 12/13] qemu-sockets: update socket_uri() to be consistent with socket_parse() Laurent Vivier
2022-07-12 12:05 ` Dr. David Alan Gilbert
2022-07-13 16:46 ` Laurent Vivier
2022-07-13 17:26 ` Daniel P. Berrangé
2022-07-06 6:46 ` [PATCH v6 13/13] net: stream: move to QIO Laurent Vivier
2022-07-06 6:53 ` [PATCH v6 11/13] qemu-sockets: move and rename SocketAddress_to_str() Laurent Vivier
-- strict thread matches above, loose matches on Subject: below --
2022-07-05 18:18 [PATCH v6 00/13] qapi: net: add unix socket type support to netdev backend Laurent Vivier
2022-07-05 18:19 ` [PATCH v6 05/13] qapi: net: add stream and dgram netdevs Laurent Vivier
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=87mtdml3qz.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=dgilbert@redhat.com \
--cc=eblake@redhat.com \
--cc=jasowang@redhat.com \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=sbrivio@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.