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 v2 2/5] net/dump: Move DumpState into NetClientState
Date: Mon, 13 Jul 2015 09:39:23 +0200 [thread overview]
Message-ID: <1436773166-12113-3-git-send-email-thuth@redhat.com> (raw)
In-Reply-To: <1436773166-12113-1-git-send-email-thuth@redhat.com>
We want to provide (almost) every netdev device with the ability
to dump network traffic, so let's embed the DumpState into the
NetClientState structure.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
include/net/net.h | 7 +++++++
net/dump.c | 17 +++++------------
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/include/net/net.h b/include/net/net.h
index 6a6cbef..b265047 100644
--- a/include/net/net.h
+++ b/include/net/net.h
@@ -58,6 +58,12 @@ typedef void (SetVnetHdrLen)(NetClientState *, int);
typedef int (SetVnetLE)(NetClientState *, bool);
typedef int (SetVnetBE)(NetClientState *, bool);
+typedef struct NetDumpState {
+ int64_t start_ts;
+ int fd;
+ int pcap_caplen;
+} NetDumpState;
+
typedef struct NetClientInfo {
NetClientOptionsKind type;
size_t size;
@@ -92,6 +98,7 @@ struct NetClientState {
NetClientDestructor *destructor;
unsigned int queue_index;
unsigned rxfilter_notify_enabled:1;
+ NetDumpState nds;
};
typedef struct NICState {
diff --git a/net/dump.c b/net/dump.c
index 935918e..a430b96 100644
--- a/net/dump.c
+++ b/net/dump.c
@@ -30,13 +30,6 @@
#include "qemu/timer.h"
#include "hub.h"
-typedef struct DumpState {
- NetClientState nc;
- int64_t start_ts;
- int fd;
- int pcap_caplen;
-} DumpState;
-
#define PCAP_MAGIC 0xa1b2c3d4
struct pcap_file_hdr {
@@ -61,7 +54,7 @@ struct pcap_sf_pkthdr {
ssize_t net_dump_receive_iov(NetClientState *nc, const struct iovec *iov,
int cnt)
{
- DumpState *s = DO_UPCAST(DumpState, nc, nc);
+ NetDumpState *s = &nc->nds;
struct pcap_sf_pkthdr hdr;
int64_t ts;
int caplen;
@@ -105,14 +98,14 @@ ssize_t net_dump_receive(NetClientState *nc, const uint8_t *buf, size_t size)
void net_dump_cleanup(NetClientState *nc)
{
- DumpState *s = DO_UPCAST(DumpState, nc, nc);
+ NetDumpState *s = &nc->nds;
close(s->fd);
}
static NetClientInfo net_dump_info = {
.type = NET_CLIENT_OPTIONS_KIND_DUMP,
- .size = sizeof(DumpState),
+ .size = sizeof(NetClientState),
.receive = net_dump_receive,
.receive_iov = net_dump_receive_iov,
.cleanup = net_dump_cleanup,
@@ -124,7 +117,7 @@ static int net_dump_init(NetClientState *peer, const char *device,
{
struct pcap_file_hdr hdr;
NetClientState *nc;
- DumpState *s;
+ NetDumpState *s;
struct tm tm;
int fd;
@@ -153,7 +146,7 @@ static int net_dump_init(NetClientState *peer, const char *device,
snprintf(nc->info_str, sizeof(nc->info_str),
"dump to %s (len=%d)", filename, len);
- s = DO_UPCAST(DumpState, nc, nc);
+ s = &nc->nds;
s->fd = fd;
s->pcap_caplen = len;
--
1.8.3.1
next prev parent reply other threads:[~2015-07-13 7:39 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-13 7:39 [Qemu-devel] [PATCH v2 0/5] For QEMU 2.5: Network traffic dumping for -netdev devices Thomas Huth
2015-07-13 7:39 ` [Qemu-devel] [PATCH v2 1/5] net/dump: Add support for receive_iov function Thomas Huth
2015-07-13 7:39 ` Thomas Huth [this message]
2015-07-13 7:39 ` [Qemu-devel] [PATCH v2 3/5] net/dump: Rework net-dump init functions Thomas Huth
2015-07-13 7:39 ` [Qemu-devel] [PATCH v2 4/5] net/dump: Add dump option for netdev devices Thomas Huth
2015-07-13 7:39 ` [Qemu-devel] [PATCH v2 5/5] qemu options: Add information about dumpfile to help text Thomas Huth
2015-07-22 6:35 ` [Qemu-devel] [PATCH v2 0/5] For QEMU 2.5: Network traffic dumping for -netdev devices Jason Wang
2015-07-22 10:52 ` Yang Hongyang
2015-07-22 10:55 ` [Qemu-devel] [PATCH] RFC/net: Add a net filter Yang Hongyang
2015-07-22 11:06 ` Daniel P. Berrange
2015-07-22 15:16 ` Yang Hongyang
2015-07-22 13:05 ` Thomas Huth
2015-07-22 15:06 ` Yang Hongyang
2015-07-22 13:26 ` Stefan Hajnoczi
2015-07-22 14:57 ` Yang Hongyang
2015-07-23 11:57 ` Stefan Hajnoczi
2015-07-23 5:59 ` Jason Wang
2015-07-27 5:27 ` Yang Hongyang
2015-07-27 6:02 ` Yang Hongyang
2015-07-27 6:39 ` Jason Wang
2015-07-27 7:00 ` Yang Hongyang
2015-07-27 7:31 ` Jason Wang
2015-07-27 7:45 ` Yang Hongyang
2015-07-27 8:01 ` Jason Wang
2015-07-27 8:39 ` Yang Hongyang
2015-07-27 9:16 ` Jason Wang
2015-07-27 10:03 ` Yang Hongyang
2015-07-28 3:28 ` Jason Wang
2015-07-28 4:00 ` Yang Hongyang
2015-07-28 8:52 ` Yang Hongyang
2015-07-28 9:19 ` Yang Hongyang
2015-07-28 9:30 ` Jason Wang
2015-07-28 9:41 ` Yang Hongyang
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=1436773166-12113-3-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).