qemu-patch-raspberry4/net
Laszlo Ersek 6687b79d63 convert net_client_init() to OptsVisitor
The net_client_init() prototype is kept intact.

Based on "is_netdev", the QemuOpts-rooted QemuOpt-list is parsed as a
Netdev or a NetLegacy. The original meat of net_client_init() is moved to
and simplified in net_client_init1():

Fields not common between -net and -netdev are clearly separated. Getting
the name for the init functions is cleaner: Netdev::id is mandatory, and
all init functions handle a NULL NetLegacy::name. NetLegacy::vlan
explicitly depends on -net (see below).

Verifying the "type=" option for -netdev can be turned into a switch.

Format validation with qemu_opts_validate() can be removed because the
visitor covers it. Relatedly, the "net_client_types" array is reduced to
an array of init functions that can be directly indexed by opts->kind.
(Help text is available in the schema JSON.)

The outermost negation in the condition around qemu_find_vlan() was
flattened, because it expresses the dependent code's requirements more
clearly.

VLAN lookup is avoided if there's no init function to pass the VLAN to.

Whenever the value of type=... is needed, we substitute
NetClientOptionsKind_lookup[kind].

The individual init functions are not converted yet, thus the original
QemuOpts instance is passed transparently.

v1->v2:
- NetLegacy::name is optional. Tracked it through all init functions: they
  all handle a NULL name. Updated commit message accordingly.

v2->v3:
- NetLegacy::id is allowed and takes precedence over NetLegacy::name.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2012-07-23 11:55:18 +01:00
..
Makefile.objs build: move net/ objects to nested Makefile.objs 2012-06-07 09:21:13 +02:00
checksum.c Change license from GPLv2 to GPLv2+ 2012-02-01 16:24:54 -06:00
checksum.h net: move net-checksum.c under net/ 2009-10-30 08:39:26 -05:00
dump.c convert net_client_init() to OptsVisitor 2012-07-23 11:55:18 +01:00
dump.h convert net_client_init() to OptsVisitor 2012-07-23 11:55:18 +01:00
queue.c Use glib memory allocation and free functions 2011-08-20 23:01:08 -05:00
queue.h net: move net-queue.[ch] under net/ 2009-10-30 08:39:26 -05:00
slirp.c convert net_client_init() to OptsVisitor 2012-07-23 11:55:18 +01:00
slirp.h convert net_client_init() to OptsVisitor 2012-07-23 11:55:18 +01:00
socket.c convert net_client_init() to OptsVisitor 2012-07-23 11:55:18 +01:00
socket.h convert net_client_init() to OptsVisitor 2012-07-23 11:55:18 +01:00
tap-aix.c tap: add APIs for vnet header length 2010-09-07 20:27:33 +03:00
tap-bsd.c do not include <libutil.h> needlessly or if it doesn't exist 2012-06-09 10:30:08 +00:00
tap-haiku.c tap: Add stub for Haiku 2010-10-03 06:31:41 +00:00
tap-linux.c net: tap-linux: Fix unhelpful error message 2011-11-01 06:23:48 +00:00
tap-linux.h tap: add APIs for vnet header length 2010-09-07 20:27:33 +03:00
tap-solaris.c fix typo: delete redundant semicolon 2011-12-06 09:56:41 +00:00
tap-win32.c convert net_client_init() to OptsVisitor 2012-07-23 11:55:18 +01:00
tap.c convert net_client_init() to OptsVisitor 2012-07-23 11:55:18 +01:00
tap.h convert net_client_init() to OptsVisitor 2012-07-23 11:55:18 +01:00
util.c net: move parse_macaddr() to net/util.[ch] 2009-12-03 09:41:34 -06:00
util.h net: move parse_macaddr() to net/util.[ch] 2009-12-03 09:41:34 -06:00
vde.c convert net_client_init() to OptsVisitor 2012-07-23 11:55:18 +01:00
vde.h convert net_client_init() to OptsVisitor 2012-07-23 11:55:18 +01:00