Commit b535b7b2f73803146fcd442c7df8f90d48b1967f
1 parent
fbe78f4f
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
Showing
1 changed file
with
18 additions
and
0 deletions
net.c
| ... | ... | @@ -620,6 +620,21 @@ typedef struct TAPState { |
| 620 | 620 | char down_script[1024]; |
| 621 | 621 | } TAPState; |
| 622 | 622 | |
| 623 | +#ifdef HAVE_IOVEC | |
| 624 | +static ssize_t tap_receive_iov(void *opaque, const struct iovec *iov, | |
| 625 | + int iovcnt) | |
| 626 | +{ | |
| 627 | + TAPState *s = opaque; | |
| 628 | + ssize_t len; | |
| 629 | + | |
| 630 | + do { | |
| 631 | + len = writev(s->fd, iov, iovcnt); | |
| 632 | + } while (len == -1 && (errno == EINTR || errno == EAGAIN)); | |
| 633 | + | |
| 634 | + return len; | |
| 635 | +} | |
| 636 | +#endif | |
| 637 | + | |
| 623 | 638 | static void tap_receive(void *opaque, const uint8_t *buf, int size) |
| 624 | 639 | { |
| 625 | 640 | TAPState *s = opaque; |
| ... | ... | @@ -664,6 +679,9 @@ static TAPState *net_tap_fd_init(VLANState *vlan, int fd) |
| 664 | 679 | return NULL; |
| 665 | 680 | s->fd = fd; |
| 666 | 681 | s->vc = qemu_new_vlan_client(vlan, tap_receive, NULL, s); |
| 682 | +#ifdef HAVE_IOVEC | |
| 683 | + s->vc->fd_readv = tap_receive_iov; | |
| 684 | +#endif | |
| 667 | 685 | qemu_set_fd_handler(s->fd, tap_send, NULL, s); |
| 668 | 686 | snprintf(s->vc->info_str, sizeof(s->vc->info_str), "tap: fd=%d", fd); |
| 669 | 687 | return s; | ... | ... |