From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>,
Jason Wang <jasowang@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Subject: [Qemu-devel] [PATCH 3/5] net/dump: Rework net-dump init functions
Date: Wed, 24 Jun 2015 17:56:19 +0200 [thread overview]
Message-ID: <1435161381-31521-4-git-send-email-thuth@redhat.com> (raw)
In-Reply-To: <1435161381-31521-1-git-send-email-thuth@redhat.com>
Moved the creation of the dump client from net_dump_init() into
net_init_dump(), renamed net_dump_init() to net_dump_state_init()
and make it available for other parts of the source code, too,
so we can use it for the -netdev option in a later patch.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
net/clients.h | 2 ++
net/dump.c | 24 +++++++++++++-----------
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/net/clients.h b/net/clients.h
index 5092f3d..fc76503 100644
--- a/net/clients.h
+++ b/net/clients.h
@@ -29,6 +29,8 @@
int net_init_dump(const NetClientOptions *opts, const char *name,
NetClientState *peer, Error **errp);
+int net_dump_state_init(NetClientState *nc, const char *filename, int len,
+ Error **errp);
ssize_t net_dump_receive(NetClientState *nc, const uint8_t *buf, size_t size);
ssize_t net_dump_receive_iov(NetClientState *nc, const struct iovec *iov,
int cnt);
diff --git a/net/dump.c b/net/dump.c
index b7a8b30..48a8087 100644
--- a/net/dump.c
+++ b/net/dump.c
@@ -125,12 +125,10 @@ static NetClientInfo net_dump_info = {
.cleanup = net_dump_cleanup,
};
-static int net_dump_init(NetClientState *peer, const char *device,
- const char *name, const char *filename, int len,
- Error **errp)
+int net_dump_state_init(NetClientState *nc, const char *filename, int len,
+ Error **errp)
{
struct pcap_file_hdr hdr;
- NetClientState *nc;
NetDumpState *s;
struct tm tm;
int fd;
@@ -155,11 +153,6 @@ static int net_dump_init(NetClientState *peer, const char *device,
return -1;
}
- nc = qemu_new_net_client(&net_dump_info, peer, device, name);
-
- snprintf(nc->info_str, sizeof(nc->info_str),
- "dump to %s (len=%d)", filename, len);
-
s = &nc->nds;
s->fd = fd;
@@ -174,10 +167,11 @@ static int net_dump_init(NetClientState *peer, const char *device,
int net_init_dump(const NetClientOptions *opts, const char *name,
NetClientState *peer, Error **errp)
{
- int len;
+ int len, rc;
const char *file;
char def_file[128];
const NetdevDumpOptions *dump;
+ NetClientState *nc;
assert(opts->kind == NET_CLIENT_OPTIONS_KIND_DUMP);
dump = opts->dump;
@@ -207,5 +201,13 @@ int net_init_dump(const NetClientOptions *opts, const char *name,
len = 65536;
}
- return net_dump_init(peer, "dump", name, file, len, errp);
+ nc = qemu_new_net_client(&net_dump_info, peer, "dump", name);
+ snprintf(nc->info_str, sizeof(nc->info_str),
+ "dump to %s (len=%d)", file, len);
+
+ rc = net_dump_state_init(nc, file, len, errp);
+ if (rc) {
+ qemu_del_net_client(nc);
+ }
+ return rc;
}
--
1.8.3.1
next prev parent reply other threads:[~2015-06-24 15:56 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-24 15:56 [Qemu-devel] [PATCH 0/5] Network traffic dumping for -netdev, second try Thomas Huth
2015-06-24 15:56 ` [Qemu-devel] [PATCH 1/5] net/dump: Add support for receive_iov function Thomas Huth
2015-06-26 6:38 ` Jason Wang
2015-06-26 7:06 ` Thomas Huth
2015-07-03 11:06 ` Markus Armbruster
2015-07-10 18:09 ` Thomas Huth
2015-06-24 15:56 ` [Qemu-devel] [PATCH 2/5] net/dump: Move DumpState into NetClientState Thomas Huth
2015-06-24 15:56 ` Thomas Huth [this message]
2015-07-03 11:19 ` [Qemu-devel] [PATCH 3/5] net/dump: Rework net-dump init functions Markus Armbruster
2015-06-24 15:56 ` [Qemu-devel] [PATCH 4/5] net/dump: Add dump option for netdev devices Thomas Huth
2015-06-26 6:50 ` Jason Wang
2015-06-26 9:44 ` Stefan Hajnoczi
2015-06-29 9:57 ` Thomas Huth
2015-06-30 15:12 ` Stefan Hajnoczi
2015-06-30 10:37 ` Thomas Huth
2015-07-01 8:36 ` Stefan Hajnoczi
2015-07-03 11:28 ` Markus Armbruster
2015-07-10 18:27 ` Thomas Huth
2015-06-24 15:56 ` [Qemu-devel] [PATCH 5/5] qemu options: Add information about dumpfile to help text Thomas Huth
2015-07-03 11:30 ` Markus Armbruster
2015-06-26 9:41 ` [Qemu-devel] [PATCH 0/5] Network traffic dumping for -netdev, second try Stefan Hajnoczi
2015-07-03 11:30 ` Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1435161381-31521-4-git-send-email-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=armbru@redhat.com \
--cc=jasowang@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).