diff options
| author | Laszlo Ersek <lersek@redhat.com> | 2012-07-17 16:17:13 +0200 |
|---|---|---|
| committer | Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> | 2012-07-23 11:55:18 +0100 |
| commit | 6687b79d636cd60ed9adb1177d0d946b58fa7717 (patch) | |
| tree | 26380fc6c6a92c1774bbc6b2d3620a6a97c39dbe /net/tap.h | |
| parent | 2be64a68ed05c65fc510dc450a1eb1823edf9330 (diff) | |
| download | focaccia-qemu-6687b79d636cd60ed9adb1177d0d946b58fa7717.tar.gz focaccia-qemu-6687b79d636cd60ed9adb1177d0d946b58fa7717.zip | |
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>
Diffstat (limited to 'net/tap.h')
| -rw-r--r-- | net/tap.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/net/tap.h b/net/tap.h index b2a9450aab..44e31cefa9 100644 --- a/net/tap.h +++ b/net/tap.h @@ -28,11 +28,13 @@ #include "qemu-common.h" #include "qemu-option.h" +#include "qapi-types.h" #define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup" #define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown" -int net_init_tap(QemuOpts *opts, const char *name, VLANState *vlan); +int net_init_tap(QemuOpts *opts, const NetClientOptions *new_opts, + const char *name, VLANState *vlan); int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required); @@ -57,6 +59,7 @@ int tap_get_fd(VLANClientState *vc); struct vhost_net; struct vhost_net *tap_get_vhost_net(VLANClientState *vc); -int net_init_bridge(QemuOpts *opts, const char *name, VLANState *vlan); +int net_init_bridge(QemuOpts *opts, const NetClientOptions *new_opts, + const char *name, VLANState *vlan); #endif /* QEMU_NET_TAP_H */ |