diff options
Diffstat (limited to 'net/dump.c')
-rw-r--r-- | net/dump.c | 19 |
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); } |