[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 16/31] vhost: pass queue index to vhost_vq_get_addr
|
From: |
Eugenio Perez Martin |
|
Subject: |
Re: [PATCH 16/31] vhost: pass queue index to vhost_vq_get_addr |
|
Date: |
Mon, 31 Jan 2022 18:44:30 +0100 |
On Sat, Jan 29, 2022 at 9:20 AM Jason Wang <jasowang@redhat.com> wrote:
>
>
> 在 2022/1/22 上午4:27, Eugenio Pérez 写道:
> > Doing that way allows vhost backend to know what address to return.
> >
> > Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> > ---
> > hw/virtio/vhost.c | 6 +++---
> > 1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> > index 7b03efccec..64b955ba0c 100644
> > --- a/hw/virtio/vhost.c
> > +++ b/hw/virtio/vhost.c
> > @@ -798,9 +798,10 @@ static int vhost_virtqueue_set_addr(struct vhost_dev
> > *dev,
> > struct vhost_virtqueue *vq,
> > unsigned idx, bool enable_log)
> > {
> > - struct vhost_vring_addr addr;
> > + struct vhost_vring_addr addr = {
> > + .index = idx,
> > + };
> > int r;
> > - memset(&addr, 0, sizeof(struct vhost_vring_addr));
> >
> > if (dev->vhost_ops->vhost_vq_get_addr) {
> > r = dev->vhost_ops->vhost_vq_get_addr(dev, &addr, vq);
> > @@ -813,7 +814,6 @@ static int vhost_virtqueue_set_addr(struct vhost_dev
> > *dev,
> > addr.avail_user_addr = (uint64_t)(unsigned long)vq->avail;
> > addr.used_user_addr = (uint64_t)(unsigned long)vq->used;
> > }
>
>
> I'm a bit lost in the logic above, any reason we need call
> vhost_vq_get_addr() :) ?
>
It's the way vhost_virtqueue_set_addr works if the backend has a
vhost_vq_get_addr operation (currently, only vhost-vdpa). vhost first
ask the address to the back end and then set it.
Previously, index was not needed because all the information was in
vhost_virtqueue. However to extract queue index from vhost_virtqueue
is tricky, so I think it's easier to simply have that information at
request, something similar to get_base or get_num when asking vdpa
device. We can extract the index from vq - dev->vqs or something
similar if it's prefered.
Thanks!
> Thanks
>
>
> > - addr.index = idx;
> > addr.log_guest_addr = vq->used_phys;
> > addr.flags = enable_log ? (1 << VHOST_VRING_F_LOG) : 0;
> > r = dev->vhost_ops->vhost_set_vring_addr(dev, &addr);
>
- [PATCH 11/31] vhost: Add vhost_svq_valid_device_features to shadow vq, (continued)
- [PATCH 11/31] vhost: Add vhost_svq_valid_device_features to shadow vq, Eugenio Pérez, 2022/01/21
- [PATCH 13/31] vhost: Add vhost_svq_ack_guest_features to shadow vq, Eugenio Pérez, 2022/01/21
- [PATCH 14/31] virtio: Add vhost_shadow_vq_get_vring_addr, Eugenio Pérez, 2022/01/21
- [PATCH 15/31] vdpa: Add vhost_svq_get_num, Eugenio Pérez, 2022/01/21
- [PATCH 16/31] vhost: pass queue index to vhost_vq_get_addr, Eugenio Pérez, 2022/01/21
- [PATCH 17/31] vdpa: adapt vhost_ops callbacks to svq, Eugenio Pérez, 2022/01/21
- [PATCH 18/31] vhost: Shadow virtqueue buffers forwarding, Eugenio Pérez, 2022/01/21
- [PATCH 19/31] utils: Add internal DMAMap to iova-tree, Eugenio Pérez, 2022/01/21
- [PATCH 21/31] util: Add iova_tree_alloc, Eugenio Pérez, 2022/01/21