mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 07:13:54 -06:00
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>
This commit is contained in:
parent
f6c874e300
commit
d33d93b2c4
14 changed files with 85 additions and 75 deletions
19
net/dump.c
19
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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue