Thread (1 message) flat view 1 message, 1 author, 2021-02-01

Re: [RFC 03/10] virtio: Add virtio_queue_get_idx

From: Jason Wang <hidden>
Date: 2021-02-01 06:11:42
Also in: qemu-devel

On 2021/1/30 上午4:54, Eugenio Pérez wrote:
quoted hunk
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
  include/hw/virtio/virtio.h | 2 ++
  hw/virtio/virtio.c         | 5 +++++
  2 files changed, 7 insertions(+)
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index 9988c6d5c9..9013c03424 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -399,6 +399,8 @@ static inline bool virtio_device_disabled(VirtIODevice *vdev)
      return unlikely(vdev->disabled || vdev->broken);
  }
  
+unsigned virtio_queue_get_idx(const VirtIODevice *vdev, const VirtQueue *vq);
+
  bool virtio_legacy_allowed(VirtIODevice *vdev);
  bool virtio_legacy_check_disabled(VirtIODevice *vdev);
  
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index ebb780fb42..3d14b0ef74 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -500,6 +500,11 @@ void virtio_queue_set_notification(VirtQueue *vq, int enable)
      }
  }
  
+unsigned virtio_queue_get_idx(const VirtIODevice *vdev, const VirtQueue *vq)
+{
+    return vq - vdev->vq;
+}

It looks to me we had a dedicated index stored in VirtQueue: 
vq->queue_index.

Thanks

+
  int virtio_queue_ready(VirtQueue *vq)
  {
      return vq->vring.avail != 0;
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help