This patch introduces a helper that can get the queue index of a
VirtQueue. This is useful when traversing the list of VirtQueues.
Cc: Anthony Liguori <address@hidden>
Cc: Michael S. Tsirkin <address@hidden>
Signed-off-by: Jason Wang <address@hidden>
---
hw/virtio/virtio.c | 5 +++++
include/hw/virtio/virtio.h | 1 +
2 files changed, 6 insertions(+)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 5e6b879..bd32518 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -725,6 +725,11 @@ hwaddr virtio_queue_get_addr(VirtIODevice
*vdev, int n)
return vdev->vq[n].pa;
}
+int virtio_queue_get_index(VirtIODevice *vdev, VirtQueue *vq)
+{
+ return vq - vdev->vq;