From patchwork Thu May 24 17:59:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhiyong Wu X-Patchwork-Id: 161181 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 B581DB6EE7 for ; Fri, 25 May 2012 04:02:20 +1000 (EST) Received: from localhost ([::1]:37333 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXcMc-0007IK-H7 for incoming@patchwork.ozlabs.org; Thu, 24 May 2012 14:02:18 -0400 Received: from eggs.gnu.org ([208.118.235.92]:52256) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXcMM-00075S-Gm for qemu-devel@nongnu.org; Thu, 24 May 2012 14:02:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SXcMG-0003F0-Ud for qemu-devel@nongnu.org; Thu, 24 May 2012 14:02:02 -0400 Received: from e36.co.us.ibm.com ([32.97.110.154]:60548) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXcMG-0003E1-K1 for qemu-devel@nongnu.org; Thu, 24 May 2012 14:01:56 -0400 Received: from /spool/local by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 24 May 2012 12:01:54 -0600 Received: from d03dlp02.boulder.ibm.com (9.17.202.178) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 24 May 2012 12:01:50 -0600 Received: from d03relay03.boulder.ibm.com (d03relay03.boulder.ibm.com [9.17.195.228]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id D71803E4004C for ; Thu, 24 May 2012 12:01:45 -0600 (MDT) Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d03relay03.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q4OI1T1k168276 for ; Thu, 24 May 2012 12:01:31 -0600 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q4OI1Itm027767 for ; Thu, 24 May 2012 12:01:20 -0600 Received: from us.ibm.com (f15.cn.ibm.com [9.115.118.120] (may be forged)) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with SMTP id q4OI1Dut026748; Thu, 24 May 2012 12:01:14 -0600 Received: by us.ibm.com (sSMTP sendmail emulation); Fri, 25 May 2012 02:01:04 +0800 From: zwu.kernel@gmail.com To: qemu-devel@nongnu.org Date: Fri, 25 May 2012 01:59:14 +0800 Message-Id: <1337882362-20100-9-git-send-email-zwu.kernel@gmail.com> X-Mailer: git-send-email 1.7.6 In-Reply-To: <1337882362-20100-1-git-send-email-zwu.kernel@gmail.com> References: <1337882362-20100-1-git-send-email-zwu.kernel@gmail.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12052418-7606-0000-0000-000000987011 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 32.97.110.154 Cc: pbonzini@redhat.com, wuzhy@linux.vnet.ibm.com, stefanha@linux.vnet.ibm.com, kvm@vger.kernel.org, jan.kiszka@siemens.com Subject: [Qemu-devel] [PATCH v3 08/16] net: Remove VLANState 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 From: Stefan Hajnoczi VLANState is no longer used and can be removed. Signed-off-by: Stefan Hajnoczi Signed-off-by: Zhi Yong Wu --- net.c | 127 ++++++++++----------------------------------------------- net.h | 8 ---- net/socket.c | 6 +- net/tap.c | 6 +- net/tap.h | 2 +- qemu-common.h | 1 - 6 files changed, 29 insertions(+), 121 deletions(-) diff --git a/net.c b/net.c index abf5a3d..eb2ad06 100644 --- a/net.c +++ b/net.c @@ -44,7 +44,6 @@ # define CONFIG_NET_BRIDGE #endif -static QTAILQ_HEAD(, VLANState) vlans; static QTAILQ_HEAD(, VLANClientState) non_vlan_clients; int default_net = 1; @@ -249,11 +248,7 @@ NICState *qemu_new_nic(NetClientInfo *info, static void qemu_cleanup_vlan_client(VLANClientState *vc) { - if (vc->vlan) { - QTAILQ_REMOVE(&vc->vlan->clients, vc, next); - } else { - QTAILQ_REMOVE(&non_vlan_clients, vc, next); - } + QTAILQ_REMOVE(&non_vlan_clients, vc, next); if (vc->info->cleanup) { vc->info->cleanup(vc); @@ -262,13 +257,11 @@ static void qemu_cleanup_vlan_client(VLANClientState *vc) static void qemu_free_vlan_client(VLANClientState *vc) { - if (!vc->vlan) { - if (vc->send_queue) { - qemu_del_net_queue(vc->send_queue); - } - if (vc->peer) { - vc->peer->peer = NULL; - } + if (vc->send_queue) { + qemu_del_net_queue(vc->send_queue); + } + if (vc->peer) { + vc->peer->peer = NULL; } g_free(vc->name); g_free(vc->model); @@ -278,7 +271,7 @@ static void qemu_free_vlan_client(VLANClientState *vc) void qemu_del_vlan_client(VLANClientState *vc) { /* If there is a peer NIC, delete and cleanup client, but do not free. */ - if (!vc->vlan && vc->peer && vc->peer->info->type == NET_CLIENT_TYPE_NIC) { + if (vc->peer && vc->peer->info->type == NET_CLIENT_TYPE_NIC) { NICState *nic = DO_UPCAST(NICState, nc, vc->peer); if (nic->peer_deleted) { return; @@ -294,7 +287,7 @@ void qemu_del_vlan_client(VLANClientState *vc) } /* If this is a peer NIC and peer has already been deleted, free it now. */ - if (!vc->vlan && vc->peer && vc->info->type == NET_CLIENT_TYPE_NIC) { + if (vc->peer && vc->info->type == NET_CLIENT_TYPE_NIC) { NICState *nic = DO_UPCAST(NICState, nc, vc); if (nic->peer_deleted) { qemu_free_vlan_client(vc->peer); @@ -308,52 +301,25 @@ void qemu_del_vlan_client(VLANClientState *vc) void qemu_foreach_nic(qemu_nic_foreach func, void *opaque) { VLANClientState *nc; - VLANState *vlan; QTAILQ_FOREACH(nc, &non_vlan_clients, next) { if (nc->info->type == NET_CLIENT_TYPE_NIC) { func(DO_UPCAST(NICState, nc, nc), opaque); } } - - QTAILQ_FOREACH(vlan, &vlans, next) { - QTAILQ_FOREACH(nc, &vlan->clients, next) { - if (nc->info->type == NET_CLIENT_TYPE_NIC) { - func(DO_UPCAST(NICState, nc, nc), opaque); - } - } - } } int qemu_can_send_packet(VLANClientState *sender) { - VLANState *vlan = sender->vlan; - VLANClientState *vc; - - if (sender->peer) { - if (sender->peer->receive_disabled) { - return 0; - } else if (sender->peer->info->can_receive && - !sender->peer->info->can_receive(sender->peer)) { - return 0; - } else { - return 1; - } - } - - if (!sender->vlan) { + if (!sender->peer) { return 1; } - QTAILQ_FOREACH(vc, &vlan->clients, next) { - if (vc == sender) { - continue; - } - - /* no can_receive() handler, they can always receive */ - if (vc->info->can_receive && !vc->info->can_receive(vc)) { - return 0; - } + if (sender->peer->receive_disabled) { + return 0; + } else if (sender->peer->info->can_receive && + !sender->peer->info->can_receive(sender->peer)) { + return 0; } return 1; } @@ -390,34 +356,18 @@ static ssize_t qemu_deliver_packet(VLANClientState *sender, void qemu_purge_queued_packets(VLANClientState *vc) { - NetQueue *queue; - - if (!vc->peer && !vc->vlan) { + if (!vc->peer) { return; } - if (vc->peer) { - queue = vc->peer->send_queue; - } else { - queue = vc->vlan->send_queue; - } - - qemu_net_queue_purge(queue, vc); + qemu_net_queue_purge(vc->peer->send_queue, vc); } void qemu_flush_queued_packets(VLANClientState *vc) { - NetQueue *queue; - vc->receive_disabled = 0; - if (vc->vlan) { - queue = vc->vlan->send_queue; - } else { - queue = vc->send_queue; - } - - qemu_net_queue_flush(queue); + qemu_net_queue_flush(vc->send_queue); } static ssize_t qemu_send_packet_async_with_flags(VLANClientState *sender, @@ -432,15 +382,11 @@ static ssize_t qemu_send_packet_async_with_flags(VLANClientState *sender, hex_dump(stdout, buf, size); #endif - if (sender->link_down || (!sender->peer && !sender->vlan)) { + if (sender->link_down || !sender->peer) { return size; } - if (sender->peer) { - queue = sender->peer->send_queue; - } else { - queue = sender->vlan->send_queue; - } + queue = sender->peer->send_queue; return qemu_net_queue_send(queue, sender, flags, buf, size, sent_cb); } @@ -500,15 +446,11 @@ ssize_t qemu_sendv_packet_async(VLANClientState *sender, { NetQueue *queue; - if (sender->link_down || (!sender->peer && !sender->vlan)) { + if (sender->link_down || !sender->peer) { return iov_size(iov, iovcnt); } - if (sender->peer) { - queue = sender->peer->send_queue; - } else { - queue = sender->vlan->send_queue; - } + queue = sender->peer->send_queue; return qemu_net_queue_send_iov(queue, sender, QEMU_NET_PACKET_FLAG_NONE, @@ -1134,18 +1076,9 @@ static void print_net_client(Monitor *mon, VLANClientState *vc) void do_info_network(Monitor *mon) { - VLANState *vlan; VLANClientState *vc, *peer; net_client_type type; - QTAILQ_FOREACH(vlan, &vlans, next) { - monitor_printf(mon, "VLAN %d devices:\n", vlan->id); - - QTAILQ_FOREACH(vc, &vlan->clients, next) { - monitor_printf(mon, " "); - print_net_client(mon, vc); - } - } monitor_printf(mon, "Devices not on any VLAN:\n"); QTAILQ_FOREACH(vc, &non_vlan_clients, next) { peer = vc->peer; @@ -1164,16 +1097,8 @@ void do_info_network(Monitor *mon) void qmp_set_link(const char *name, bool up, Error **errp) { - VLANState *vlan; VLANClientState *vc = NULL; - QTAILQ_FOREACH(vlan, &vlans, next) { - QTAILQ_FOREACH(vc, &vlan->clients, next) { - if (strcmp(vc->name, name) == 0) { - goto done; - } - } - } QTAILQ_FOREACH(vc, &non_vlan_clients, next) { if (!strcmp(vc->name, name)) { goto done; @@ -1182,7 +1107,7 @@ void qmp_set_link(const char *name, bool up, Error **errp) done: if (!vc) { - error_set(errp, QERR_DEVICE_NOT_FOUND, name); + qerror_report(QERR_DEVICE_NOT_FOUND, name); return; } @@ -1206,15 +1131,8 @@ done: void net_cleanup(void) { - VLANState *vlan; VLANClientState *vc, *next_vc; - QTAILQ_FOREACH(vlan, &vlans, next) { - QTAILQ_FOREACH_SAFE(vc, &vlan->clients, next, next_vc) { - qemu_del_vlan_client(vc); - } - } - QTAILQ_FOREACH_SAFE(vc, &non_vlan_clients, next, next_vc) { qemu_del_vlan_client(vc); } @@ -1286,7 +1204,6 @@ int net_init_clients(void) #endif } - QTAILQ_INIT(&vlans); QTAILQ_INIT(&non_vlan_clients); if (qemu_opts_foreach(qemu_find_opts("netdev"), net_init_netdev, NULL, 1) == -1) diff --git a/net.h b/net.h index a4ac48d..2482546 100644 --- a/net.h +++ b/net.h @@ -64,7 +64,6 @@ struct VLANClientState { NetClientInfo *info; int link_down; QTAILQ_ENTRY(VLANClientState) next; - struct VLANState *vlan; VLANClientState *peer; NetQueue *send_queue; char *model; @@ -80,13 +79,6 @@ typedef struct NICState { bool peer_deleted; } NICState; -struct VLANState { - int id; - QTAILQ_HEAD(, VLANClientState) clients; - QTAILQ_ENTRY(VLANState) next; - NetQueue *send_queue; -}; - VLANClientState *qemu_find_netdev(const char *id); VLANClientState *qemu_new_net_client(NetClientInfo *info, VLANClientState *peer, diff --git a/net/socket.c b/net/socket.c index bf7a793..5676bd5 100644 --- a/net/socket.c +++ b/net/socket.c @@ -536,7 +536,7 @@ static int net_socket_mcast_init(VLANClientState *peer, } -static int net_socket_udp_init(VLANState *vlan, +static int net_socket_udp_init(NetClientState *peer, const char *model, const char *name, const char *rhost, @@ -574,7 +574,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; } @@ -680,7 +680,7 @@ int net_init_socket(QemuOpts *opts, return -1; } - if (net_socket_udp_init(vlan, "udp", name, udp, localaddr) == -1) { + if (net_socket_udp_init(peer, "udp", name, udp, localaddr) == -1) { return -1; } } else { diff --git a/net/tap.c b/net/tap.c index 3a68d7e..7dbf643 100644 --- a/net/tap.c +++ b/net/tap.c @@ -513,7 +513,7 @@ static int net_bridge_run_helper(const char *helper, const char *bridge) } int net_init_bridge(QemuOpts *opts, Monitor *mon, const char *name, - VLANState *vlan) + NetClientState *peer) { TAPState *s; int fd, vnet_hdr; @@ -535,7 +535,7 @@ int net_init_bridge(QemuOpts *opts, Monitor *mon, 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; @@ -651,7 +651,7 @@ int net_init_tap(QemuOpts *opts, Monitor *mon, 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 c194684..8d949cd 100644 --- a/net/tap.h +++ b/net/tap.h @@ -59,6 +59,6 @@ struct vhost_net; struct vhost_net *tap_get_vhost_net(VLANClientState *vc); int net_init_bridge(QemuOpts *opts, Monitor *mon, const char *name, - VLANState *vlan); + NetClientState *peer); #endif /* QEMU_NET_TAP_H */ diff --git a/qemu-common.h b/qemu-common.h index cccfb42..9443c7a 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -235,7 +235,6 @@ typedef struct TextConsole TextConsole; typedef TextConsole QEMUConsole; typedef struct CharDriverState CharDriverState; typedef struct MACAddr MACAddr; -typedef struct VLANState VLANState; typedef struct VLANClientState VLANClientState; typedef struct i2c_bus i2c_bus; typedef struct ISABus ISABus;