aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2008-12-17 19:17:17 +0000
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2008-12-17 19:17:17 +0000
commitb535b7b2f73803146fcd442c7df8f90d48b1967f (patch)
treeb79d38de7008a1779103bda8133698a600251711
parentfbe78f4f55c6fdf1f8df3d82bf31835de9283fa3 (diff)
Add support for tap vectored send
This is adapted from kvm-userspace. It allows readv to be used with tap when the host supports it. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6074 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r--net.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/net.c b/net.c
index e18e36b20e..c796035006 100644
--- a/net.c
+++ b/net.c
@@ -620,6 +620,21 @@ typedef struct TAPState {
char down_script[1024];
} TAPState;
+#ifdef HAVE_IOVEC
+static ssize_t tap_receive_iov(void *opaque, const struct iovec *iov,
+ int iovcnt)
+{
+ TAPState *s = opaque;
+ ssize_t len;
+
+ do {
+ len = writev(s->fd, iov, iovcnt);
+ } while (len == -1 && (errno == EINTR || errno == EAGAIN));
+
+ return len;
+}
+#endif
+
static void tap_receive(void *opaque, const uint8_t *buf, int size)
{
TAPState *s = opaque;
@@ -664,6 +679,9 @@ static TAPState *net_tap_fd_init(VLANState *vlan, int fd)
return NULL;
s->fd = fd;
s->vc = qemu_new_vlan_client(vlan, tap_receive, NULL, s);
+#ifdef HAVE_IOVEC
+ s->vc->fd_readv = tap_receive_iov;
+#endif
qemu_set_fd_handler(s->fd, tap_send, NULL, s);
snprintf(s->vc->info_str, sizeof(s->vc->info_str), "tap: fd=%d", fd);
return s;