summaryrefslogtreecommitdiff
path: root/net/dump.c
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@linux.vnet.ibm.com>2012-07-24 16:35:05 +0100
committerStefan Hajnoczi <stefanha@linux.vnet.ibm.com>2012-08-01 12:28:51 +0100
commitd33d93b2c40b820c2cfab1e2e6da631f12091957 (patch)
treea63f93f8c768b451774c11b59c41dc074d2d22a0 /net/dump.c
parentf6c874e3002b944f83d887b84051654e5c5b7821 (diff)
downloadqemu-d33d93b2c40b820c2cfab1e2e6da631f12091957.tar.gz
net: Use hubs for the vlan feature
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> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Diffstat (limited to 'net/dump.c')
-rw-r--r--net/dump.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/net/dump.c b/net/dump.c
index b575430787..9d7bf3be4d 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);
}