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>
Showing
- net.c 96 additions, 333 deletionsnet.c
- net/dump.c 2 additions, 1 deletionnet/dump.c
- net/dump.h 3 additions, 1 deletionnet/dump.h
- net/slirp.c 2 additions, 1 deletionnet/slirp.c
- net/slirp.h 3 additions, 1 deletionnet/slirp.h
- net/socket.c 2 additions, 1 deletionnet/socket.c
- net/socket.h 3 additions, 1 deletionnet/socket.h
- net/tap-win32.c 2 additions, 1 deletionnet/tap-win32.c
- net/tap.c 4 additions, 2 deletionsnet/tap.c
- net/tap.h 5 additions, 2 deletionsnet/tap.h
- net/vde.c 2 additions, 1 deletionnet/vde.c
- net/vde.h 3 additions, 1 deletionnet/vde.h
Loading
Please register or sign in to comment