aboutsummaryrefslogtreecommitdiff
path: root/net/dump.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2012-07-23 13:15:34 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2012-07-23 13:15:34 -0500
commita21143486b9c6d7a50b7b62877c02b3c686943cb (patch)
tree4bbc889465188e469317bfd89b110a99867a72e8 /net/dump.c
parentef6bbdf9e5eb6da5cbdea1bf55e08709c6e181d5 (diff)
parent1a0c09583df097d62b0580f9073ba45c9d18351a (diff)
Merge remote-tracking branch 'stefanha/net' into staging
* stefanha/net: remove unused QemuOpts parameter from net init functions convert net_init_bridge() to NetClientOptions convert net_init_tap() to NetClientOptions convert net_init_vde() to NetClientOptions convert net_init_socket() to NetClientOptions convert net_init_slirp() to NetClientOptions convert net_init_dump() to NetClientOptions convert net_init_nic() to NetClientOptions convert net_client_init() to OptsVisitor hw, net: "net_client_type" -> "NetClientOptionsKind" (qapi-generated) qapi schema: add Netdev types qapi schema: remove trailing whitespace qapi: introduce OptsVisitor expose QemuOpt and QemuOpts struct definitions to interested parties qapi: introduce "size" type qapi: generate C types for fixed-width integers qapi: add test case for deallocating traversal of incomplete structure qapi: fix error propagation MAINTAINERS: Replace net maintainer Mark McLoughlin with Stefan Hajnoczi
Diffstat (limited to 'net/dump.c')
-rw-r--r--net/dump.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/net/dump.c b/net/dump.c
index f835c51187..b575430787 100644
--- a/net/dump.c
+++ b/net/dump.c
@@ -93,7 +93,7 @@ static void dump_cleanup(VLANClientState *nc)
}
static NetClientInfo net_dump_info = {
- .type = NET_CLIENT_TYPE_DUMP,
+ .type = NET_CLIENT_OPTIONS_KIND_DUMP,
.size = sizeof(DumpState),
.receive = dump_receive,
.cleanup = dump_cleanup,
@@ -144,21 +144,35 @@ static int net_dump_init(VLANState *vlan, const char *device,
return 0;
}
-int net_init_dump(QemuOpts *opts, const char *name, VLANState *vlan)
+int net_init_dump(const NetClientOptions *opts, const char *name,
+ VLANState *vlan)
{
int len;
const char *file;
char def_file[128];
+ const NetdevDumpOptions *dump;
+
+ assert(opts->kind == NET_CLIENT_OPTIONS_KIND_DUMP);
+ dump = opts->dump;
assert(vlan);
- file = qemu_opt_get(opts, "file");
- if (!file) {
+ if (dump->has_file) {
+ file = dump->file;
+ } else {
snprintf(def_file, sizeof(def_file), "qemu-vlan%d.pcap", vlan->id);
file = def_file;
}
- len = qemu_opt_get_size(opts, "len", 65536);
+ if (dump->has_len) {
+ if (dump->len > INT_MAX) {
+ error_report("invalid length: %"PRIu64, dump->len);
+ return -1;
+ }
+ len = dump->len;
+ } else {
+ len = 65536;
+ }
return net_dump_init(vlan, "dump", name, file, len);
}