|
From: | Jason Wang |
Subject: | Re: [PATCH 16/31] vhost: pass queue index to vhost_vq_get_addr |
Date: | Tue, 8 Feb 2022 14:58:29 +0800 |
User-agent: | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 |
在 2022/2/1 上午1:44, Eugenio Perez Martin 写道:
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.
Right it's because vhost-vdpa doesn't use VA but GPA. But I'm not sure it's worth a dedicated vhost_ops. But consider we introduce shadow virtqueue stuffs, it should be ok now.
(In the future, we may consider to generalize non vhost-vdpa specific stuffs to VhostShadowVirtqueue, then we can get rid of this vhost_ops.
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.
It looks odd for the caller to tell the index consider vhost_virtqueue is already passed. So I think we need deduce it from vhost_virtqueue as you mentioned here.
Thanks
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);
[Prev in Thread] | Current Thread | [Next in Thread] |