From: Yang Hongyang <yanghy@cn.fujitsu.com>
To: Thomas Huth <thuth@redhat.com>,
qemu-devel@nongnu.org, jasowang@redhat.com
Cc: armbru@redhat.com, stefanha@redhat.com, mst@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 1/5] net/dump: Add support for receive_iov function
Date: Wed, 14 Oct 2015 10:13:25 +0800 [thread overview]
Message-ID: <561DBA45.1040209@cn.fujitsu.com> (raw)
In-Reply-To: <1444732802-14732-2-git-send-email-thuth@redhat.com>
On 10/13/2015 06:39 PM, Thomas Huth wrote:
> Adding a proper receive_iov function to the net dump module.
> This will make it easier to support the dump filter feature for
> the -netdev option in later patches.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Yang Hongyang <yanghy@cn.fujitsu.com>
> ---
> net/dump.c | 24 +++++++++++++++++++++---
> 1 file changed, 21 insertions(+), 3 deletions(-)
>
> diff --git a/net/dump.c b/net/dump.c
> index 08259af..aa0d45d 100644
> --- a/net/dump.c
> +++ b/net/dump.c
> @@ -25,6 +25,7 @@
> #include "clients.h"
> #include "qemu-common.h"
> #include "qemu/error-report.h"
> +#include "qemu/iov.h"
> #include "qemu/log.h"
> #include "qemu/timer.h"
> #include "hub.h"
> @@ -57,12 +58,15 @@ struct pcap_sf_pkthdr {
> uint32_t len;
> };
>
> -static ssize_t dump_receive(NetClientState *nc, const uint8_t *buf, size_t size)
> +static ssize_t dump_receive_iov(NetClientState *nc, const struct iovec *iov,
> + int cnt)
> {
> DumpState *s = DO_UPCAST(DumpState, nc, nc);
> struct pcap_sf_pkthdr hdr;
> int64_t ts;
> int caplen;
> + size_t size = iov_size(iov, cnt);
> + struct iovec dumpiov[cnt + 1];
>
> /* Early return in case of previous error. */
> if (s->fd < 0) {
> @@ -76,8 +80,12 @@ static ssize_t dump_receive(NetClientState *nc, const uint8_t *buf, size_t size)
> hdr.ts.tv_usec = ts % 1000000;
> hdr.caplen = caplen;
> hdr.len = size;
> - if (write(s->fd, &hdr, sizeof(hdr)) != sizeof(hdr) ||
> - write(s->fd, buf, caplen) != caplen) {
> +
> + dumpiov[0].iov_base = &hdr;
> + dumpiov[0].iov_len = sizeof(hdr);
> + cnt = iov_copy(&dumpiov[1], cnt, iov, cnt, 0, caplen);
> +
> + if (writev(s->fd, dumpiov, cnt + 1) != sizeof(hdr) + caplen) {
> qemu_log("-net dump write error - stop dump\n");
> close(s->fd);
> s->fd = -1;
> @@ -86,6 +94,15 @@ static ssize_t dump_receive(NetClientState *nc, const uint8_t *buf, size_t size)
> return size;
> }
>
> +static ssize_t dump_receive(NetClientState *nc, const uint8_t *buf, size_t size)
> +{
> + struct iovec iov = {
> + .iov_base = (void *)buf,
> + .iov_len = size
> + };
> + return dump_receive_iov(nc, &iov, 1);
> +}
> +
> static void dump_cleanup(NetClientState *nc)
> {
> DumpState *s = DO_UPCAST(DumpState, nc, nc);
> @@ -97,6 +114,7 @@ static NetClientInfo net_dump_info = {
> .type = NET_CLIENT_OPTIONS_KIND_DUMP,
> .size = sizeof(DumpState),
> .receive = dump_receive,
> + .receive_iov = dump_receive_iov,
> .cleanup = dump_cleanup,
> };
>
>
--
Thanks,
Yang.
next prev parent reply other threads:[~2015-10-14 2:13 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-13 10:39 [Qemu-devel] [PATCH v2 0/5] Network traffic dumping via netfilter Thomas Huth
2015-10-13 10:39 ` [Qemu-devel] [PATCH v2 1/5] net/dump: Add support for receive_iov function Thomas Huth
2015-10-14 2:13 ` Yang Hongyang [this message]
2015-10-13 10:39 ` [Qemu-devel] [PATCH v2 2/5] net/dump: Rework net-dump init functions Thomas Huth
2015-10-14 2:17 ` Yang Hongyang
2015-10-13 10:40 ` [Qemu-devel] [PATCH v2 3/5] net/dump: Separate the NetClientState from the DumpState Thomas Huth
2015-10-14 2:23 ` Yang Hongyang
2015-10-13 10:40 ` [Qemu-devel] [PATCH v2 4/5] net/dump: Provide the dumping facility as a net-filter Thomas Huth
2015-10-14 2:42 ` Yang Hongyang
2015-10-13 10:40 ` [Qemu-devel] [PATCH v2 5/5] options: Add documentation for filter-dump Thomas Huth
2015-10-20 4:35 ` [Qemu-devel] [PATCH v2 0/5] Network traffic dumping via netfilter Jason Wang
-- strict thread matches above, loose matches on Subject: below --
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
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=561DBA45.1040209@cn.fujitsu.com \
--to=yanghy@cn.fujitsu.com \
--cc=armbru@redhat.com \
--cc=jasowang@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=thuth@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).