qemu-e2k/net
Laurent Vivier f3eedcddba qapi: net: introduce a way to bypass qemu_opts_parse_noisily()
As qemu_opts_parse_noisily() flattens the QAPI structures ("type" field
of Netdev structure can collides with "type" field of SocketAddress),
we introduce a way to bypass qemu_opts_parse_noisily() and use directly
visit_type_Netdev() to parse the backend parameters.

More details from Markus:

qemu_init() passes the argument of -netdev, -nic, and -net to
net_client_parse().

net_client_parse() parses with qemu_opts_parse_noisily(), passing
QemuOptsList qemu_netdev_opts for -netdev, qemu_nic_opts for -nic, and
qemu_net_opts for -net.  Their desc[] are all empty, which means any
keys are accepted.  The result of the parse (a QemuOpts) is stored in
the QemuOptsList.

Note that QemuOpts is flat by design.  In some places, we layer non-flat
on top using dotted keys convention, but not here.

net_init_clients() iterates over the stored QemuOpts, and passes them to
net_init_netdev(), net_param_nic(), or net_init_client(), respectively.

These functions pass the QemuOpts to net_client_init().  They also do
other things with the QemuOpts, which we can ignore here.

net_client_init() uses the opts visitor to convert the (flat) QemOpts to
a (non-flat) QAPI object Netdev.  Netdev is also the argument of QMP
command netdev_add.

The opts visitor was an early attempt to support QAPI in
(QemuOpts-based) CLI.  It restricts QAPI types to a certain shape; see
commit eb7ee2cbeb "qapi: introduce OptsVisitor".

A more modern way to support QAPI is qobject_input_visitor_new_str().
It uses keyval_parse() instead of QemuOpts for KEY=VALUE,... syntax, and
it also supports JSON syntax.  The former isn't quite as expressive as
JSON, but it's a lot closer than QemuOpts + opts visitor.

This commit paves the way to use of the modern way instead.

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
2022-10-28 13:28:52 +08:00
..
can util/log: Remove qemu_log_flush 2022-04-20 10:51:11 -07:00
announce.c include: move C/util-related declarations to cutils.h 2022-04-06 14:31:43 +02:00
checksum.c net/checksum: Remove unused variable in net_checksum_add_iov 2021-07-26 07:06:58 -10:00
clients.h net/vmnet: add vmnet backends to qapi/net 2022-05-17 16:48:23 +08:00
colo-compare.c net/colo: Fix a "double free" crash to clear the conn_list 2022-07-20 16:58:08 +08:00
colo-compare.h Add the function of colo_compare_cleanup 2021-06-11 10:30:13 +08:00
colo.c net/colo.c: Fix the pointer issue reported by Coverity. 2022-09-02 10:22:39 +08:00
colo.h net/colo.c: Fix the pointer issue reported by Coverity. 2022-09-02 10:22:39 +08:00
dump.c rtc: Move RTC function prototypes to their own header 2022-01-28 14:29:46 +00:00
eth.c net/eth: Don't consider ESP to be an IPv6 option header 2022-02-14 11:50:44 +08:00
filter-buffer.c netfilter: Use class properties 2020-12-15 10:02:07 -05:00
filter-mirror.c net/filter: Optimize filter_send to coroutine 2022-02-14 11:50:44 +08:00
filter-replay.c hw: Do not include qemu/log.h if it is not necessary 2021-05-02 17:24:50 +02:00
filter-rewriter.c net/colo: Fix a "double free" crash to clear the conn_list 2022-07-20 16:58:08 +08:00
filter.c netfilter: Use class properties 2020-12-15 10:02:07 -05:00
hub.c hw/net: Make NetCanReceive() return a boolean 2020-03-31 21:14:35 +08:00
hub.h net: Remove deprecated [hub_id name] tuple of 'hostfwd_add' / 'hostfwd_remove' 2020-03-09 18:44:04 +00:00
l2tpv3.c util: rename qemu_*block() socket functions 2022-05-03 15:53:20 +04:00
meson.build vhost-net-vdpa: add stubs for when no virtio-net device is present 2022-07-20 16:58:08 +08:00
net.c qapi: net: introduce a way to bypass qemu_opts_parse_noisily() 2022-10-28 13:28:52 +08:00
netmap.c Do not include sysemu/sysemu.h if it's not really necessary 2021-05-02 17:24:50 +02:00
queue.c net: introduce qemu_receive_packet() 2021-03-15 16:41:22 +08:00
slirp.c net: slirp: add support for CFI-friendly timer API 2022-05-12 12:29:44 +02:00
socket.c util: rename qemu_*block() socket functions 2022-05-03 15:53:20 +04:00
tap-bsd.c Replace fcntl(O_NONBLOCK) with g_unix_set_fd_nonblocking() 2022-05-03 15:47:38 +04:00
tap-linux.c Replace fcntl(O_NONBLOCK) with g_unix_set_fd_nonblocking() 2022-05-03 15:47:38 +04:00
tap-linux.h net/tap: Added TUNSETSTEERINGEBPF code. 2021-06-04 15:25:46 +08:00
tap-solaris.c Replace fcntl(O_NONBLOCK) with g_unix_set_fd_nonblocking() 2022-05-03 15:47:38 +04:00
tap-stub.c net: Added SetSteeringEBPF method for NetClientState. 2021-06-04 15:25:46 +08:00
tap-win32.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
tap.c virtio: del net client if net_init_tap_one failed 2022-09-27 15:14:37 +08:00
tap_int.h net: Added SetSteeringEBPF method for NetClientState. 2021-06-04 15:25:46 +08:00
trace-events net/colo.c: Fix the pointer issue reported by Coverity. 2022-09-02 10:22:39 +08:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00
util.c net: Clean up includes 2016-02-04 17:41:30 +00:00
util.h Replace config-time define HOST_WORDS_BIGENDIAN 2022-04-06 10:50:37 +02:00
vde.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
vhost-user-stub.c vhost-net-user: add stubs for when no virtio-net device is present 2019-02-21 12:28:01 -05:00
vhost-user.c net/vhost-user: Fix device compatibility check 2021-10-15 16:05:46 +02:00
vhost-vdpa-stub.c vhost-net-vdpa: add stubs for when no virtio-net device is present 2022-07-20 16:58:08 +08:00
vhost-vdpa.c vhost-vdpa: allow passing opened vhostfd to vhost-vdpa 2022-10-28 13:28:52 +08:00
vmnet-bridged.m net/vmnet: implement bridged mode (vmnet-bridged) 2022-05-17 16:48:23 +08:00
vmnet-common.m net/vmnet: implement shared mode (vmnet-shared) 2022-05-17 16:48:23 +08:00
vmnet-host.c net/vmnet: implement host mode (vmnet-host) 2022-05-17 16:48:23 +08:00
vmnet-shared.c net/vmnet: implement shared mode (vmnet-shared) 2022-05-17 16:48:23 +08:00
vmnet_int.h net/vmnet: implement shared mode (vmnet-shared) 2022-05-17 16:48:23 +08:00