Commit b535b7b2 authored by aliguori's avatar aliguori

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: default avatarAnthony Liguori <>

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162
parent fbe78f4f
......@@ -620,6 +620,21 @@ typedef struct TAPState {
char down_script[1024];
} TAPState;
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;
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);
s->vc->fd_readv = tap_receive_iov;
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;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment