From d33d93b2c40b820c2cfab1e2e6da631f12091957 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Tue, 24 Jul 2012 16:35:05 +0100 Subject: 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 Signed-off-by: Zhi Yong Wu Reviewed-by: Laszlo Ersek --- net/dump.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'net/dump.c') 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); } -- cgit v1.1