OSDN Git Service

qapi: net: add stream and dgram netdevs
authorLaurent Vivier <lvivier@redhat.com>
Fri, 21 Oct 2022 09:09:11 +0000 (11:09 +0200)
committerJason Wang <jasowang@redhat.com>
Fri, 28 Oct 2022 05:28:52 +0000 (13:28 +0800)
commit5166fe0ae46dbfed8cd7e7c3743c591caef81336
tree3af2864c21923637649831b48664158a43cd2f2b
parent53b85d9574f3c162c0aadbd988f95e207d4c6e31
qapi: net: add stream and dgram netdevs

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 (off 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>
Acked-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
hmp-commands.hx
net/clients.h
net/dgram.c [new file with mode: 0644]
net/hub.c
net/meson.build
net/net.c
net/stream.c [new file with mode: 0644]
qapi/net.json
qemu-options.hx