From: Benjamin Poirier <benjamin.poirier@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] net: Use iov helper functions
Date: Wed, 23 Feb 2011 19:57:21 -0500 [thread overview]
Message-ID: <1298509041-1811-1-git-send-email-benjamin.poirier@gmail.com> (raw)
Signed-off-by: Benjamin Poirier <benjamin.poirier@gmail.com>
---
net.c | 28 ++++++----------------------
1 files changed, 6 insertions(+), 22 deletions(-)
diff --git a/net.c b/net.c
index ec4745d..15ed40b 100644
--- a/net.c
+++ b/net.c
@@ -36,6 +36,7 @@
#include "qemu-common.h"
#include "qemu_socket.h"
#include "hw/qdev.h"
+#include "iov.h"
static QTAILQ_HEAD(, VLANState) vlans;
static QTAILQ_HEAD(, VLANClientState) non_vlan_clients;
@@ -572,30 +573,13 @@ static ssize_t vc_sendv_compat(VLANClientState *vc, const struct iovec *iov,
int iovcnt)
{
uint8_t buffer[4096];
- size_t offset = 0;
- int i;
-
- for (i = 0; i < iovcnt; i++) {
- size_t len;
+ size_t offset;
- len = MIN(sizeof(buffer) - offset, iov[i].iov_len);
- memcpy(buffer + offset, iov[i].iov_base, len);
- offset += len;
- }
+ offset = iov_to_buf(iov, iovcnt, buffer, 0, sizeof(buffer));
return vc->info->receive(vc, buffer, offset);
}
-static ssize_t calc_iov_length(const struct iovec *iov, int iovcnt)
-{
- size_t offset = 0;
- int i;
-
- for (i = 0; i < iovcnt; i++)
- offset += iov[i].iov_len;
- return offset;
-}
-
static ssize_t qemu_deliver_packet_iov(VLANClientState *sender,
unsigned flags,
const struct iovec *iov,
@@ -605,7 +589,7 @@ static ssize_t qemu_deliver_packet_iov(VLANClientState *sender,
VLANClientState *vc = opaque;
if (vc->link_down) {
- return calc_iov_length(iov, iovcnt);
+ return iov_size(iov, iovcnt);
}
if (vc->info->receive_iov) {
@@ -633,7 +617,7 @@ static ssize_t qemu_vlan_deliver_packet_iov(VLANClientState *sender,
}
if (vc->link_down) {
- ret = calc_iov_length(iov, iovcnt);
+ ret = iov_size(iov, iovcnt);
continue;
}
@@ -658,7 +642,7 @@ ssize_t qemu_sendv_packet_async(VLANClientState *sender,
NetQueue *queue;
if (sender->link_down || (!sender->peer && !sender->vlan)) {
- return calc_iov_length(iov, iovcnt);
+ return iov_size(iov, iovcnt);
}
if (sender->peer) {
--
1.7.2.3
next reply other threads:[~2011-02-24 0:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-24 0:57 Benjamin Poirier [this message]
2011-02-24 10:08 ` [Qemu-devel] [PATCH] net: Use iov helper functions Stefan Hajnoczi
2011-02-25 6:21 ` Jason Wang
2011-03-06 18:29 ` Aurelien Jarno
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=1298509041-1811-1-git-send-email-benjamin.poirier@gmail.com \
--to=benjamin.poirier@gmail.com \
--cc=qemu-devel@nongnu.org \
/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).