diff mbox

[08/12] virtio: add a queue_index to VirtQueue

Message ID 1356690724-37891-9-git-send-email-jasowang@redhat.com
State New
Headers show

Commit Message

Jason Wang Dec. 28, 2012, 10:32 a.m. UTC
Add a queue_index to VirtQueue and a helper to fetch it, this could be used by
multiqueue supported device.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 hw/virtio.c |    8 ++++++++
 hw/virtio.h |    1 +
 2 files changed, 9 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/hw/virtio.c b/hw/virtio.c
index bc3c9c3..726c139 100644
--- a/hw/virtio.c
+++ b/hw/virtio.c
@@ -72,6 +72,8 @@  struct VirtQueue
     /* Notification enabled? */
     bool notification;
 
+    uint16_t queue_index;
+
     int inuse;
 
     uint16_t vector;
@@ -929,6 +931,7 @@  VirtIODevice *virtio_common_init(const char *name, uint16_t device_id,
     for(i = 0; i < VIRTIO_PCI_QUEUE_MAX; i++) {
         vdev->vq[i].vector = VIRTIO_NO_VECTOR;
         vdev->vq[i].vdev = vdev;
+        vdev->vq[i].queue_index = i;
     }
 
     vdev->name = name;
@@ -1008,6 +1011,11 @@  VirtQueue *virtio_get_queue(VirtIODevice *vdev, int n)
     return vdev->vq + n;
 }
 
+uint16_t virtio_get_queue_index(VirtQueue *vq)
+{
+    return vq->queue_index;
+}
+
 static void virtio_queue_guest_notifier_read(EventNotifier *n)
 {
     VirtQueue *vq = container_of(n, VirtQueue, guest_notifier);
diff --git a/hw/virtio.h b/hw/virtio.h
index f6cb0f9..07b38d6 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -237,6 +237,7 @@  hwaddr virtio_queue_get_ring_size(VirtIODevice *vdev, int n);
 uint16_t virtio_queue_get_last_avail_idx(VirtIODevice *vdev, int n);
 void virtio_queue_set_last_avail_idx(VirtIODevice *vdev, int n, uint16_t idx);
 VirtQueue *virtio_get_queue(VirtIODevice *vdev, int n);
+uint16_t virtio_get_queue_index(VirtQueue *vq);
 int virtio_queue_get_id(VirtQueue *vq);
 EventNotifier *virtio_queue_get_guest_notifier(VirtQueue *vq);
 void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign,