virtio: generation counter support
authorMichael S. Tsirkin <mst@redhat.com>
Thu, 4 Jun 2015 10:34:23 +0000 (12:34 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 10 Jun 2015 16:15:05 +0000 (18:15 +0200)
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
hw/virtio/virtio-pci.c
hw/virtio/virtio.c
include/hw/virtio/virtio.h

index 8fc3c4ea9b29c0f752071aaa87453c5f33521a90..7805bddc741435d5860b99070d7a903ccec790ac 100644 (file)
@@ -977,7 +977,7 @@ static uint64_t virtio_pci_common_read(void *opaque, hwaddr addr,
         val = vdev->status;
         break;
     case VIRTIO_PCI_COMMON_CFGGENERATION:
-        val = 0; /* TODO */
+        val = vdev->generation;
         break;
     case VIRTIO_PCI_COMMON_Q_SELECT:
         val = vdev->queue_sel;
index 8a6ebae368409a0a16a17434894a754a97c27480..cae5ecab19cb0f7c47442f626c7f6fa9844f83f1 100644 (file)
@@ -930,6 +930,7 @@ void virtio_notify_config(VirtIODevice *vdev)
         return;
 
     vdev->isr |= 0x03;
+    vdev->generation++;
     virtio_notify_vector(vdev, vdev->config_vector);
 }
 
index df8991357fe412cffef002cb34a94887acbdeab9..b9e36f95d381f76c34e83724df24cdc579068503 100644 (file)
@@ -78,6 +78,7 @@ struct VirtIODevice
     size_t config_len;
     void *config;
     uint16_t config_vector;
+    uint32_t generation;
     int nvectors;
     VirtQueue *vq;
     uint16_t device_id;