[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC 03/10] virtio: Add virtio_queue_get_idx
From: |
Eugenio Perez Martin |
Subject: |
Re: [RFC 03/10] virtio: Add virtio_queue_get_idx |
Date: |
Mon, 1 Feb 2021 08:20:49 +0100 |
On Mon, Feb 1, 2021 at 7:10 AM Jason Wang <jasowang@redhat.com> wrote:
>
>
> 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.
>
You are right, I don't know why but missed it! It will be used in the
next series.
Thanks!
> Thanks
>
>
> > +
> > int virtio_queue_ready(VirtQueue *vq)
> > {
> > return vq->vring.avail != 0;
>