qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Jason Wang
Subject: Re: [RFC 03/10] virtio: Add virtio_queue_get_idx
Date: Mon, 1 Feb 2021 14:10:39 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0


On 2021/1/30 上午4:54, Eugenio Pérez wrote:
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;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]