From patchwork Tue Jul 24 15:35:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 172897 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BF0AB2C008C for ; Wed, 25 Jul 2012 01:35:59 +1000 (EST) Received: from localhost ([::1]:48587 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sth9R-0001Tb-DF for incoming@patchwork.ozlabs.org; Tue, 24 Jul 2012 11:35:57 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56877) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sth98-0001TI-GC for qemu-devel@nongnu.org; Tue, 24 Jul 2012 11:35:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sth92-0006Qs-IY for qemu-devel@nongnu.org; Tue, 24 Jul 2012 11:35:37 -0400 Received: from e06smtp11.uk.ibm.com ([195.75.94.107]:38891) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sth92-0006O0-1j for qemu-devel@nongnu.org; Tue, 24 Jul 2012 11:35:32 -0400 Received: from /spool/local by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 24 Jul 2012 16:35:30 +0100 Received: from d06nrmr1507.portsmouth.uk.ibm.com (9.149.38.233) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 24 Jul 2012 16:35:27 +0100 Received: from d06av06.portsmouth.uk.ibm.com (d06av06.portsmouth.uk.ibm.com [9.149.37.217]) by d06nrmr1507.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q6OFZQja2560022 for ; Tue, 24 Jul 2012 16:35:26 +0100 Received: from d06av06.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q6OFZQCU007219 for ; Tue, 24 Jul 2012 09:35:26 -0600 Received: from localhost (stefanha-thinkpad.manchester-maybrook.uk.ibm.com [9.174.219.145]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q6OFZQEV007216; Tue, 24 Jul 2012 09:35:26 -0600 From: Stefan Hajnoczi To: Date: Tue, 24 Jul 2012 16:35:05 +0100 Message-Id: <1343144119-18757-3-git-send-email-stefanha@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1343144119-18757-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1343144119-18757-1-git-send-email-stefanha@linux.vnet.ibm.com> x-cbid: 12072415-5024-0000-0000-000003513416 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 195.75.94.107 Cc: Paolo Bonzini , Zhi Yong Wu , Laszlo Ersek , Stefan Hajnoczi , Zhi Yong Wu Subject: [Qemu-devel] [PATCH v2 02/16] net: Use hubs for the vlan feature X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Stop using the special-case vlan code in net.c. Instead use the hub net client to implement the vlan feature. The next patch will remove vlan code from net.c completely. Signed-off-by: Stefan Hajnoczi Signed-off-by: Zhi Yong Wu --- net.c | 37 ++++++++++++++++++++----------------- net/dump.c | 19 +++++++++++++------ net/dump.h | 2 +- net/hub.c | 6 +++--- net/hub.h | 2 +- net/slirp.c | 8 ++++---- net/slirp.h | 2 +- net/socket.c | 48 ++++++++++++++++++++++++------------------------ net/socket.h | 2 +- net/tap-win32.c | 8 ++++---- net/tap.c | 12 ++++++------ net/tap.h | 4 ++-- net/vde.c | 8 ++++---- net/vde.h | 2 +- 14 files changed, 85 insertions(+), 75 deletions(-) diff --git a/net.c b/net.c index e7a8d81..4feca6c 100644 --- a/net.c +++ b/net.c @@ -157,23 +157,25 @@ void qemu_macaddr_default_if_unset(MACAddr *macaddr) macaddr->a[5] = 0x56 + index++; } +/** + * Generate a name for net client + * + * Only net clients created with the legacy -net option need this. Naming is + * mandatory for net clients created with -netdev. + */ static char *assign_name(VLANClientState *vc1, const char *model) { - VLANState *vlan; VLANClientState *vc; char buf[256]; int id = 0; - QTAILQ_FOREACH(vlan, &vlans, next) { - QTAILQ_FOREACH(vc, &vlan->clients, next) { - if (vc != vc1 && strcmp(vc->model, model) == 0) { - id++; - } - } - } - QTAILQ_FOREACH(vc, &non_vlan_clients, next) { - if (vc != vc1 && strcmp(vc->model, model) == 0) { + if (vc == vc1) { + continue; + } + /* For compatibility only bump id for net clients on a vlan */ + if (strcmp(vc->model, model) == 0 && + net_hub_id_for_client(vc, NULL) == 0) { id++; } } @@ -750,7 +752,7 @@ int net_handle_fd_param(Monitor *mon, const char *param) } static int net_init_nic(const NetClientOptions *opts, const char *name, - VLANState *vlan) + VLANClientState *peer) { int idx; NICInfo *nd; @@ -776,8 +778,8 @@ static int net_init_nic(const NetClientOptions *opts, const char *name, return -1; } } else { - assert(vlan); - nd->vlan = vlan; + assert(peer); + nd->netdev = peer; } if (name) { nd->name = g_strdup(name); @@ -816,7 +818,7 @@ static int net_init_nic(const NetClientOptions *opts, const char *name, static int (* const net_client_init_fun[NET_CLIENT_OPTIONS_KIND_MAX])( const NetClientOptions *opts, const char *name, - VLANState *vlan) = { + VLANClientState *peer) = { [NET_CLIENT_OPTIONS_KIND_NIC] = net_init_nic, #ifdef CONFIG_SLIRP [NET_CLIENT_OPTIONS_KIND_USER] = net_init_slirp, @@ -876,17 +878,17 @@ static int net_client_init1(const void *object, int is_netdev, Error **errp) } if (net_client_init_fun[opts->kind]) { - VLANState *vlan = NULL; + VLANClientState *peer = NULL; /* Do not add to a vlan if it's a -netdev or a nic with a netdev= * parameter. */ if (!is_netdev && (opts->kind != NET_CLIENT_OPTIONS_KIND_NIC || !opts->nic->has_netdev)) { - vlan = qemu_find_vlan(u.net->has_vlan ? u.net->vlan : 0, true); + peer = net_hub_add_port(u.net->has_vlan ? u.net->vlan : 0, NULL); } - if (net_client_init_fun[opts->kind](opts, name, vlan) < 0) { + if (net_client_init_fun[opts->kind](opts, name, peer) < 0) { /* TODO push error reporting into init() methods */ error_set(errp, QERR_DEVICE_INIT_FAILED, NetClientOptionsKind_lookup[opts->kind]); @@ -1085,6 +1087,7 @@ void do_info_network(Monitor *mon) print_net_client(mon, peer); } } + net_hub_info(mon); } void qmp_set_link(const char *name, bool up, Error **errp) diff --git a/net/dump.c b/net/dump.c index b575430..9d7bf3b 100644 --- a/net/dump.c +++ b/net/dump.c @@ -27,6 +27,7 @@ #include "qemu-error.h" #include "qemu-log.h" #include "qemu-timer.h" +#include "hub.h" typedef struct DumpState { VLANClientState nc; @@ -99,7 +100,7 @@ static NetClientInfo net_dump_info = { .cleanup = dump_cleanup, }; -static int net_dump_init(VLANState *vlan, const char *device, +static int net_dump_init(VLANClientState *peer, const char *device, const char *name, const char *filename, int len) { struct pcap_file_hdr hdr; @@ -128,7 +129,7 @@ static int net_dump_init(VLANState *vlan, const char *device, return -1; } - nc = qemu_new_net_client(&net_dump_info, vlan, NULL, device, name); + nc = qemu_new_net_client(&net_dump_info, NULL, peer, device, name); snprintf(nc->info_str, sizeof(nc->info_str), "dump to %s (len=%d)", filename, len); @@ -145,7 +146,7 @@ static int net_dump_init(VLANState *vlan, const char *device, } int net_init_dump(const NetClientOptions *opts, const char *name, - VLANState *vlan) + VLANClientState *peer) { int len; const char *file; @@ -155,12 +156,18 @@ int net_init_dump(const NetClientOptions *opts, const char *name, assert(opts->kind == NET_CLIENT_OPTIONS_KIND_DUMP); dump = opts->dump; - assert(vlan); + assert(peer); if (dump->has_file) { file = dump->file; } else { - snprintf(def_file, sizeof(def_file), "qemu-vlan%d.pcap", vlan->id); + int id; + int ret; + + ret = net_hub_id_for_client(peer, &id); + assert(ret == 0); /* peer must be on a hub */ + + snprintf(def_file, sizeof(def_file), "qemu-vlan%d.pcap", id); file = def_file; } @@ -174,5 +181,5 @@ int net_init_dump(const NetClientOptions *opts, const char *name, len = 65536; } - return net_dump_init(vlan, "dump", name, file, len); + return net_dump_init(peer, "dump", name, file, len); } diff --git a/net/dump.h b/net/dump.h index 0fa2dd7..9d70195 100644 --- a/net/dump.h +++ b/net/dump.h @@ -28,6 +28,6 @@ #include "qapi-types.h" int net_init_dump(const NetClientOptions *opts, const char *name, - VLANState *vlan); + VLANClientState *peer); #endif /* QEMU_NET_DUMP_H */ diff --git a/net/hub.c b/net/hub.c index be6e014..ee9d878 100644 --- a/net/hub.c +++ b/net/hub.c @@ -206,15 +206,15 @@ int net_hub_id_for_client(VLANClientState *nc, int *id) } int net_init_hubport(const NetClientOptions *opts, const char *name, - VLANState *vlan) + VLANClientState *peer) { const NetdevHubPortOptions *hubport; assert(opts->kind == NET_CLIENT_OPTIONS_KIND_HUBPORT); hubport = opts->hubport; - /* The hub is a "vlan" so this option makes no sense. */ - if (vlan) { + /* Treat hub port like a backend, NIC must be the one to peer */ + if (peer) { return -EINVAL; } diff --git a/net/hub.h b/net/hub.h index f0d98f2..a5fa2ba 100644 --- a/net/hub.h +++ b/net/hub.h @@ -18,7 +18,7 @@ #include "qemu-common.h" int net_init_hubport(const NetClientOptions *opts, const char *name, - VLANState *vlan); + VLANClientState *peer); VLANClientState *net_hub_add_port(int hub_id, const char *name); void net_hub_info(Monitor *mon); int net_hub_id_for_client(VLANClientState *nc, int *id); diff --git a/net/slirp.c b/net/slirp.c index 5c2e6b2..97e380c 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -135,7 +135,7 @@ static NetClientInfo net_slirp_info = { .cleanup = net_slirp_cleanup, }; -static int net_slirp_init(VLANState *vlan, const char *model, +static int net_slirp_init(VLANClientState *peer, const char *model, const char *name, int restricted, const char *vnetwork, const char *vhost, const char *vhostname, const char *tftp_export, @@ -238,7 +238,7 @@ static int net_slirp_init(VLANState *vlan, const char *model, } #endif - nc = qemu_new_net_client(&net_slirp_info, vlan, NULL, model, name); + nc = qemu_new_net_client(&net_slirp_info, NULL, peer, model, name); snprintf(nc->info_str, sizeof(nc->info_str), "net=%s,restrict=%s", inet_ntoa(net), @@ -703,7 +703,7 @@ net_init_slirp_configs(const StringList *fwd, int flags) } int net_init_slirp(const NetClientOptions *opts, const char *name, - VLANState *vlan) + VLANClientState *peer) { struct slirp_config_str *config; char *vnet; @@ -722,7 +722,7 @@ int net_init_slirp(const NetClientOptions *opts, const char *name, net_init_slirp_configs(user->hostfwd, SLIRP_CFG_HOSTFWD); net_init_slirp_configs(user->guestfwd, 0); - ret = net_slirp_init(vlan, "user", name, user->restrict, vnet, user->host, + ret = net_slirp_init(peer, "user", name, user->restrict, vnet, user->host, user->hostname, user->tftp, user->bootfile, user->dhcpstart, user->dns, user->smb, user->smbserver); diff --git a/net/slirp.h b/net/slirp.h index e2c71ee..1ff21b0 100644 --- a/net/slirp.h +++ b/net/slirp.h @@ -32,7 +32,7 @@ #ifdef CONFIG_SLIRP int net_init_slirp(const NetClientOptions *opts, const char *name, - VLANState *vlan); + VLANClientState *peer); void net_slirp_hostfwd_add(Monitor *mon, const QDict *qdict); void net_slirp_hostfwd_remove(Monitor *mon, const QDict *qdict); diff --git a/net/socket.c b/net/socket.c index 600c287..09bdc66 100644 --- a/net/socket.c +++ b/net/socket.c @@ -44,7 +44,7 @@ typedef struct NetSocketState { } NetSocketState; typedef struct NetSocketListenState { - VLANState *vlan; + VLANClientState *peer; char *model; char *name; int fd; @@ -245,7 +245,7 @@ static NetClientInfo net_dgram_socket_info = { .cleanup = net_socket_cleanup, }; -static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan, +static NetSocketState *net_socket_fd_init_dgram(VLANClientState *peer, const char *model, const char *name, int fd, int is_connected) @@ -287,7 +287,7 @@ static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan, } } - nc = qemu_new_net_client(&net_dgram_socket_info, vlan, NULL, model, name); + nc = qemu_new_net_client(&net_dgram_socket_info, NULL, peer, model, name); snprintf(nc->info_str, sizeof(nc->info_str), "socket: fd=%d (%s mcast=%s:%d)", @@ -323,7 +323,7 @@ static NetClientInfo net_socket_info = { .cleanup = net_socket_cleanup, }; -static NetSocketState *net_socket_fd_init_stream(VLANState *vlan, +static NetSocketState *net_socket_fd_init_stream(VLANClientState *peer, const char *model, const char *name, int fd, int is_connected) @@ -331,7 +331,7 @@ static NetSocketState *net_socket_fd_init_stream(VLANState *vlan, VLANClientState *nc; NetSocketState *s; - nc = qemu_new_net_client(&net_socket_info, vlan, NULL, model, name); + nc = qemu_new_net_client(&net_socket_info, NULL, peer, model, name); snprintf(nc->info_str, sizeof(nc->info_str), "socket: fd=%d", fd); @@ -347,7 +347,7 @@ static NetSocketState *net_socket_fd_init_stream(VLANState *vlan, return s; } -static NetSocketState *net_socket_fd_init(VLANState *vlan, +static NetSocketState *net_socket_fd_init(VLANClientState *peer, const char *model, const char *name, int fd, int is_connected) { @@ -362,13 +362,13 @@ static NetSocketState *net_socket_fd_init(VLANState *vlan, } switch(so_type) { case SOCK_DGRAM: - return net_socket_fd_init_dgram(vlan, model, name, fd, is_connected); + return net_socket_fd_init_dgram(peer, model, name, fd, is_connected); case SOCK_STREAM: - return net_socket_fd_init_stream(vlan, model, name, fd, is_connected); + return net_socket_fd_init_stream(peer, model, name, fd, is_connected); default: /* who knows ... this could be a eg. a pty, do warn and continue as stream */ fprintf(stderr, "qemu: warning: socket type=%d for fd=%d is not SOCK_DGRAM or SOCK_STREAM\n", so_type, fd); - return net_socket_fd_init_stream(vlan, model, name, fd, is_connected); + return net_socket_fd_init_stream(peer, model, name, fd, is_connected); } return NULL; } @@ -390,7 +390,7 @@ static void net_socket_accept(void *opaque) break; } } - s1 = net_socket_fd_init(s->vlan, s->model, s->name, fd, 1); + s1 = net_socket_fd_init(s->peer, s->model, s->name, fd, 1); if (s1) { snprintf(s1->nc.info_str, sizeof(s1->nc.info_str), "socket: connection from %s:%d", @@ -398,7 +398,7 @@ static void net_socket_accept(void *opaque) } } -static int net_socket_listen_init(VLANState *vlan, +static int net_socket_listen_init(VLANClientState *peer, const char *model, const char *name, const char *host_str) @@ -438,7 +438,7 @@ static int net_socket_listen_init(VLANState *vlan, closesocket(fd); return -1; } - s->vlan = vlan; + s->peer = peer; s->model = g_strdup(model); s->name = name ? g_strdup(name) : NULL; s->fd = fd; @@ -446,7 +446,7 @@ static int net_socket_listen_init(VLANState *vlan, return 0; } -static int net_socket_connect_init(VLANState *vlan, +static int net_socket_connect_init(VLANClientState *peer, const char *model, const char *name, const char *host_str) @@ -487,7 +487,7 @@ static int net_socket_connect_init(VLANState *vlan, break; } } - s = net_socket_fd_init(vlan, model, name, fd, connected); + s = net_socket_fd_init(peer, model, name, fd, connected); if (!s) return -1; snprintf(s->nc.info_str, sizeof(s->nc.info_str), @@ -496,7 +496,7 @@ static int net_socket_connect_init(VLANState *vlan, return 0; } -static int net_socket_mcast_init(VLANState *vlan, +static int net_socket_mcast_init(VLANClientState *peer, const char *model, const char *name, const char *host_str, @@ -522,7 +522,7 @@ static int net_socket_mcast_init(VLANState *vlan, if (fd < 0) return -1; - s = net_socket_fd_init(vlan, model, name, fd, 0); + s = net_socket_fd_init(peer, model, name, fd, 0); if (!s) return -1; @@ -535,7 +535,7 @@ static int net_socket_mcast_init(VLANState *vlan, } -static int net_socket_udp_init(VLANState *vlan, +static int net_socket_udp_init(VLANClientState *peer, const char *model, const char *name, const char *rhost, @@ -573,7 +573,7 @@ static int net_socket_udp_init(VLANState *vlan, return -1; } - s = net_socket_fd_init(vlan, model, name, fd, 0); + s = net_socket_fd_init(peer, model, name, fd, 0); if (!s) { return -1; } @@ -587,7 +587,7 @@ static int net_socket_udp_init(VLANState *vlan, } int net_init_socket(const NetClientOptions *opts, const char *name, - VLANState *vlan) + VLANClientState *peer) { const NetdevSocketOptions *sock; @@ -610,21 +610,21 @@ int net_init_socket(const NetClientOptions *opts, const char *name, int fd; fd = net_handle_fd_param(cur_mon, sock->fd); - if (fd == -1 || !net_socket_fd_init(vlan, "socket", name, fd, 1)) { + if (fd == -1 || !net_socket_fd_init(peer, "socket", name, fd, 1)) { return -1; } return 0; } if (sock->has_listen) { - if (net_socket_listen_init(vlan, "socket", name, sock->listen) == -1) { + if (net_socket_listen_init(peer, "socket", name, sock->listen) == -1) { return -1; } return 0; } if (sock->has_connect) { - if (net_socket_connect_init(vlan, "socket", name, sock->connect) == + if (net_socket_connect_init(peer, "socket", name, sock->connect) == -1) { return -1; } @@ -634,7 +634,7 @@ int net_init_socket(const NetClientOptions *opts, const char *name, if (sock->has_mcast) { /* if sock->localaddr is missing, it has been initialized to "all bits * zero" */ - if (net_socket_mcast_init(vlan, "socket", name, sock->mcast, + if (net_socket_mcast_init(peer, "socket", name, sock->mcast, sock->localaddr) == -1) { return -1; } @@ -646,7 +646,7 @@ int net_init_socket(const NetClientOptions *opts, const char *name, error_report("localaddr= is mandatory with udp="); return -1; } - if (net_socket_udp_init(vlan, "udp", name, sock->udp, sock->localaddr) == + if (net_socket_udp_init(peer, "udp", name, sock->udp, sock->localaddr) == -1) { return -1; } diff --git a/net/socket.h b/net/socket.h index c4809ad..82b4d16 100644 --- a/net/socket.h +++ b/net/socket.h @@ -28,6 +28,6 @@ #include "qapi-types.h" int net_init_socket(const NetClientOptions *opts, const char *name, - VLANState *vlan); + VLANClientState *peer); #endif /* QEMU_NET_SOCKET_H */ diff --git a/net/tap-win32.c b/net/tap-win32.c index 2328072..0e3b883 100644 --- a/net/tap-win32.c +++ b/net/tap-win32.c @@ -673,7 +673,7 @@ static NetClientInfo net_tap_win32_info = { .cleanup = tap_cleanup, }; -static int tap_win32_init(VLANState *vlan, const char *model, +static int tap_win32_init(VLANClientState *peer, const char *model, const char *name, const char *ifname) { VLANClientState *nc; @@ -685,7 +685,7 @@ static int tap_win32_init(VLANState *vlan, const char *model, return -1; } - nc = qemu_new_net_client(&net_tap_win32_info, vlan, NULL, model, name); + nc = qemu_new_net_client(&net_tap_win32_info, NULL, peer, model, name); s = DO_UPCAST(TAPState, nc, nc); @@ -700,7 +700,7 @@ static int tap_win32_init(VLANState *vlan, const char *model, } int net_init_tap(const NetClientOptions *opts, const char *name, - VLANState *vlan) + VLANClientState *peer) { const NetdevTapOptions *tap; @@ -712,7 +712,7 @@ int net_init_tap(const NetClientOptions *opts, const char *name, return -1; } - if (tap_win32_init(vlan, "tap", name, tap->ifname) == -1) { + if (tap_win32_init(peer, "tap", name, tap->ifname) == -1) { return -1; } diff --git a/net/tap.c b/net/tap.c index 7206227..43c3fcd 100644 --- a/net/tap.c +++ b/net/tap.c @@ -322,7 +322,7 @@ static NetClientInfo net_tap_info = { .cleanup = tap_cleanup, }; -static TAPState *net_tap_fd_init(VLANState *vlan, +static TAPState *net_tap_fd_init(VLANClientState *peer, const char *model, const char *name, int fd, @@ -331,7 +331,7 @@ static TAPState *net_tap_fd_init(VLANState *vlan, VLANClientState *nc; TAPState *s; - nc = qemu_new_net_client(&net_tap_info, vlan, NULL, model, name); + nc = qemu_new_net_client(&net_tap_info, NULL, peer, model, name); s = DO_UPCAST(TAPState, nc, nc); @@ -514,7 +514,7 @@ static int net_bridge_run_helper(const char *helper, const char *bridge) } int net_init_bridge(const NetClientOptions *opts, const char *name, - VLANState *vlan) + VLANClientState *peer) { const NetdevBridgeOptions *bridge; const char *helper, *br; @@ -537,7 +537,7 @@ int net_init_bridge(const NetClientOptions *opts, const char *name, vnet_hdr = tap_probe_vnet_hdr(fd); - s = net_tap_fd_init(vlan, "bridge", name, fd, vnet_hdr); + s = net_tap_fd_init(peer, "bridge", name, fd, vnet_hdr); if (!s) { close(fd); return -1; @@ -587,7 +587,7 @@ static int net_tap_init(const NetdevTapOptions *tap, int *vnet_hdr, } int net_init_tap(const NetClientOptions *opts, const char *name, - VLANState *vlan) + VLANClientState *peer) { const NetdevTapOptions *tap; @@ -650,7 +650,7 @@ int net_init_tap(const NetClientOptions *opts, const char *name, model = "tap"; } - s = net_tap_fd_init(vlan, model, name, fd, vnet_hdr); + s = net_tap_fd_init(peer, model, name, fd, vnet_hdr); if (!s) { close(fd); return -1; diff --git a/net/tap.h b/net/tap.h index 19dea58..113906f 100644 --- a/net/tap.h +++ b/net/tap.h @@ -33,7 +33,7 @@ #define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown" int net_init_tap(const NetClientOptions *opts, const char *name, - VLANState *vlan); + VLANClientState *peer); int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required); @@ -59,6 +59,6 @@ struct vhost_net; struct vhost_net *tap_get_vhost_net(VLANClientState *vc); int net_init_bridge(const NetClientOptions *opts, const char *name, - VLANState *vlan); + VLANClientState *peer); #endif /* QEMU_NET_TAP_H */ diff --git a/net/vde.c b/net/vde.c index ee19f5c..302a022 100644 --- a/net/vde.c +++ b/net/vde.c @@ -75,7 +75,7 @@ static NetClientInfo net_vde_info = { .cleanup = vde_cleanup, }; -static int net_vde_init(VLANState *vlan, const char *model, +static int net_vde_init(VLANClientState *peer, const char *model, const char *name, const char *sock, int port, const char *group, int mode) { @@ -96,7 +96,7 @@ static int net_vde_init(VLANState *vlan, const char *model, return -1; } - nc = qemu_new_net_client(&net_vde_info, vlan, NULL, model, name); + nc = qemu_new_net_client(&net_vde_info, NULL, peer, model, name); snprintf(nc->info_str, sizeof(nc->info_str), "sock=%s,fd=%d", sock, vde_datafd(vde)); @@ -111,7 +111,7 @@ static int net_vde_init(VLANState *vlan, const char *model, } int net_init_vde(const NetClientOptions *opts, const char *name, - VLANState *vlan) + VLANClientState *peer) { const NetdevVdeOptions *vde; @@ -119,7 +119,7 @@ int net_init_vde(const NetClientOptions *opts, const char *name, vde = opts->vde; /* missing optional values have been initialized to "all bits zero" */ - if (net_vde_init(vlan, "vde", name, vde->sock, vde->port, vde->group, + if (net_vde_init(peer, "vde", name, vde->sock, vde->port, vde->group, vde->has_mode ? vde->mode : 0700) == -1) { return -1; } diff --git a/net/vde.h b/net/vde.h index ad502ef..d6f7af4 100644 --- a/net/vde.h +++ b/net/vde.h @@ -30,7 +30,7 @@ #ifdef CONFIG_VDE int net_init_vde(const NetClientOptions *opts, const char *name, - VLANState *vlan); + VLANClientState *peer); #endif /* CONFIG_VDE */