[PATCH] Update virtio to latest ABI

Anthony Liguori
2008-01-24T20:00:06Z

This patch updates KVM's virtio implementation to the latest virtio ABI. This
includes a change in the network header and support for reset.

With this patch, the block and network driver from Rusty's latest queue are
functioning. Module unload and reload work and I no longer see an error when
repeatedly bringing a network interface up and down.

Signed-off-by: Anthony Liguori <aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>

diff --git a/qemu/hw/virtio-net.c b/qemu/hw/virtio-net.c
index 296edf6..86f9e5a 100644
--- a/qemu/hw/virtio-net.c
+++ b/qemu/hw/virtio-net.c
@@ -23,11 +23,8 @@

/* The feature bitmap for virtio net */
#define VIRTIO_NET_F_NO_CSUM 0
-#define VIRTIO_NET_F_TSO4 1
-#define VIRTIO_NET_F_UFO 2
-#define VIRTIO_NET_F_TSO4_ECN 3
-#define VIRTIO_NET_F_TSO6 4
#define VIRTIO_NET_F_MAC 5
+#define VIRTIO_NET_F_GS0 6

#define TX_TIMER_INTERVAL (1000 / 500)

@@ -49,7 +46,9 @@ struct virtio_net_hdr
#define VIRTIO_NET_HDR_GSO_TCPV4_ECN 2 // GSO frame, IPv4 TCP w/ ECN
#define VIRTIO_NET_HDR_GSO_UDP 3 // GSO frame, IPv4 UDP (UFO)
#define VIRTIO_NET_HDR_GSO_TCPV6 4 // GSO frame, IPv6 TCP
+#define VIRTIO_NET_HDR_GSO_ECN 0x80 // TCP has ECN set
uint8_t gso_type;
+ uint16_t hdr_len;
uint16_t gso_size;
uint16_t csum_start;
uint16_t csum_offset;
diff --git a/qemu/hw/virtio.c b/qemu/hw/virtio.c
index b78c2c5..bbcb44c 100644
--- a/qemu/hw/virtio.c
+++ b/qemu/hw/virtio.c
@@ -210,6 +210,8 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
break;
case VIRTIO_PCI_STATUS:
vdev->status = val & 0xFF;
+ if (vdev->status == 0)
+ virtio_reset(vdev);
break;
}
}