aboutsummaryrefslogtreecommitdiff
path: root/hw/virtio-net.c
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2012-09-24 14:54:44 +0200
committerMichael S. Tsirkin <mst@redhat.com>2012-10-29 18:25:23 +0200
commit7b80d08efc36fd6c7881e98302f00148b5fd908a (patch)
tree935e9549400c5b05ee5047a287a7b9ea73258d85 /hw/virtio-net.c
parent14761f9cf7fbc6d058c1e51c313a139066eab256 (diff)
downloadqemu-7b80d08efc36fd6c7881e98302f00148b5fd908a.zip
qemu-7b80d08efc36fd6c7881e98302f00148b5fd908a.tar.gz
qemu-7b80d08efc36fd6c7881e98302f00148b5fd908a.tar.bz2
virtio-net: simplify rx code
Remove code duplication using guest header length that we track. Drop specific layout requirement for rx buffers: things work using generic iovec functions in any case. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/virtio-net.c')
-rw-r--r--hw/virtio-net.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 5206648..dc4a26c 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -720,12 +720,7 @@ static int32_t virtio_net_flush_tx(VirtIONet *n, VirtQueue *vq)
struct iovec *out_sg = &elem.out_sg[0];
struct iovec sg[VIRTQUEUE_MAX_SIZE];
- /* hdr_len refers to the header received from the guest */
- hdr_len = n->mergeable_rx_bufs ?
- sizeof(struct virtio_net_hdr_mrg_rxbuf) :
- sizeof(struct virtio_net_hdr);
-
- if (out_num < 1 || out_sg->iov_len != hdr_len) {
+ if (out_num < 1) {
error_report("virtio-net header not in first element");
exit(1);
}
@@ -747,7 +742,7 @@ static int32_t virtio_net_flush_tx(VirtIONet *n, VirtQueue *vq)
out_sg = sg;
}
- len = hdr_len;
+ len = n->guest_hdr_len;
ret = qemu_sendv_packet_async(&n->nic->nc, out_sg, out_num,
virtio_net_tx_complete);