All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>,
	lersek@redhat.com, Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>,
	Zhi Yong Wu <wuzhy@cn.ibm.com>
Subject: [Qemu-devel] [PATCH 02/16] net: Use hubs for the vlan feature
Date: Fri, 20 Jul 2012 13:01:35 +0100	[thread overview]
Message-ID: <1342785709-3152-3-git-send-email-stefanha@linux.vnet.ibm.com> (raw)
In-Reply-To: <1342785709-3152-1-git-send-email-stefanha@linux.vnet.ibm.com>

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 <stefanha@linux.vnet.ibm.com>
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
---
 net.c           |   38 +++++++++++++++++++++-----------------
 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    |   52 +++++++++++++++++++++++++++-------------------------
 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, 89 insertions(+), 76 deletions(-)

diff --git a/net.c b/net.c
index e7a8d81..f2752c7 100644
--- a/net.c
+++ b/net.c
@@ -25,6 +25,7 @@
 
 #include "config-host.h"
 
+#include "net/hub.h"
 #include "net/tap.h"
 #include "net/socket.h"
 #include "net/dump.h"
@@ -157,23 +158,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 +753,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 +779,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 +819,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 +879,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 +1088,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..4aae25a 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);
+        unsigned 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%u.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..a1beb0d 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 *vlan);
 
 #endif /* QEMU_NET_DUMP_H */
diff --git a/net/hub.c b/net/hub.c
index cc58d41..e0ce476 100644
--- a/net/hub.c
+++ b/net/hub.c
@@ -206,15 +206,15 @@ int net_hub_id_for_client(VLANClientState *nc, unsigned 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 06939b3..b642c13 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(unsigned int hub_id, const char *name);
 void net_hub_info(Monitor *mon);
 int net_hub_id_for_client(VLANClientState *nc, unsigned 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..da9897c 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 *vlan);
 
 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..cac3922 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,15 +390,17 @@ static void net_socket_accept(void *opaque)
             break;
         }
     }
-    s1 = net_socket_fd_init(s->vlan, s->model, s->name, fd, 1);
-    if (s1) {
+    s1 = net_socket_fd_init(s->peer, s->model, s->name, fd, 1);
+    if (!s1) {
+        closesocket(fd);
+    } else {
         snprintf(s1->nc.info_str, sizeof(s1->nc.info_str),
                  "socket: connection from %s:%d",
                  inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
     }
 }
 
-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 +440,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 +448,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 +489,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 +498,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 +524,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 +537,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 +575,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 +589,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 +612,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 +636,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 +648,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 */
 
-- 
1.7.10.4

  parent reply	other threads:[~2012-07-20 12:02 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-20 12:01 [Qemu-devel] [PATCH 00/16] net: Move legacy QEMU VLAN code into net/hub.c Stefan Hajnoczi
2012-07-20 12:01 ` [Qemu-devel] [PATCH 01/16] net: Add a hub net client Stefan Hajnoczi
2012-07-23 12:45   ` Laszlo Ersek
2012-07-23 13:49     ` Stefan Hajnoczi
2012-07-23 14:05       ` Laszlo Ersek
2012-07-23 14:52         ` Stefan Hajnoczi
2012-07-23 15:16           ` Laszlo Ersek
2012-07-23 15:23             ` Stefan Hajnoczi
2012-07-23 16:33               ` Andreas Färber
2012-07-23 17:11                 ` Markus Armbruster
2012-07-23 19:01                 ` Blue Swirl
2012-07-20 12:01 ` Stefan Hajnoczi [this message]
2012-07-23 13:55   ` [Qemu-devel] [PATCH 02/16] net: Use hubs for the vlan feature Laszlo Ersek
2012-07-23 14:56     ` Stefan Hajnoczi
2012-07-20 12:01 ` [Qemu-devel] [PATCH 03/16] net: Look up 'vlan' net clients using hubs Stefan Hajnoczi
2012-07-23 15:04   ` Laszlo Ersek
2012-07-23 15:21     ` Stefan Hajnoczi
2012-07-20 12:01 ` [Qemu-devel] [PATCH 04/16] hub: Check that hubs are configured correctly Stefan Hajnoczi
2012-07-23 19:15   ` Laszlo Ersek
2012-07-20 12:01 ` [Qemu-devel] [PATCH 05/16] net: Drop vlan argument to qemu_new_net_client() Stefan Hajnoczi
2012-07-23 19:35   ` Laszlo Ersek
2012-07-20 12:01 ` [Qemu-devel] [PATCH 06/16] net: Convert qdev_prop_vlan to peer with hub Stefan Hajnoczi
2012-07-23 20:07   ` Laszlo Ersek
2012-07-24 10:49     ` Stefan Hajnoczi
2012-07-20 12:01 ` [Qemu-devel] [PATCH 07/16] net: Remove vlan code from net.c Stefan Hajnoczi
2012-07-20 12:01 ` [Qemu-devel] [PATCH 08/16] net: Remove VLANState Stefan Hajnoczi
2012-07-23 20:57   ` Laszlo Ersek
2012-07-24 10:33     ` Stefan Hajnoczi
2012-07-20 12:01 ` [Qemu-devel] [PATCH 09/16] net: Rename non_vlan_clients to net_clients Stefan Hajnoczi
2012-07-20 12:01 ` [Qemu-devel] [PATCH 10/16] net: Rename VLANClientState to NetClientState Stefan Hajnoczi
2012-07-20 12:01 ` [Qemu-devel] [PATCH 11/16] net: Rename vc local variables to nc Stefan Hajnoczi
2012-07-20 12:01 ` [Qemu-devel] [PATCH 12/16] net: Rename qemu_del_vlan_client() to qemu_del_net_client() Stefan Hajnoczi
2012-07-20 12:01 ` [Qemu-devel] [PATCH 13/16] net: Make "info network" output more readable info Stefan Hajnoczi
2012-07-23 21:54   ` Laszlo Ersek
2012-07-24 10:26     ` Stefan Hajnoczi
2012-07-20 12:01 ` [Qemu-devel] [PATCH 14/16] net: cleanup deliver/deliver_iov func pointers Stefan Hajnoczi
2012-07-20 12:01 ` [Qemu-devel] [PATCH 15/16] net: determine if packets can be sent before net queue deliver packets Stefan Hajnoczi
2012-07-20 12:01 ` [Qemu-devel] [PATCH 16/16] hub: add the support for hub own flow control Stefan Hajnoczi
2012-07-23 22:27   ` Laszlo Ersek
2012-07-24  6:42     ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1342785709-3152-3-git-send-email-stefanha@linux.vnet.ibm.com \
    --to=stefanha@linux.vnet.ibm.com \
    --cc=lersek@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=wuzhy@cn.ibm.com \
    --cc=wuzhy@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.