? 2023/2/8 17:42, Eugenio P?rez ??:> At this moment it is only possible to migrate to a vdpa device running
> with x-svq=on. As a protective measure, the rewind of the inflight
> descriptors was done at the destination. That way if the source sent a
> virtqueue with inuse descriptors they are always discarded.
>
> Since this series allows to migrate also to passthrough devices with no
> SVQ, the right thing to do is to rewind at the source so the base of
> vrings are correct.
>
> Support for inflight descriptors may be added in the future.
>
> Signed-off-by: Eugenio P?rez <eperezma at redhat.com>
Acked-by: Jason Wang <jasowang at redhat.com>
Thanks
> ---
> hw/virtio/vhost-vdpa.c | 24 +++++++++++++-----------
> 1 file changed, 13 insertions(+), 11 deletions(-)
>
> diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
> index 26e38a6aab..d99db0bd03 100644
> --- a/hw/virtio/vhost-vdpa.c
> +++ b/hw/virtio/vhost-vdpa.c
> @@ -1211,18 +1211,7 @@ static int vhost_vdpa_set_vring_base(struct
vhost_dev *dev,
> struct vhost_vring_state *ring)
> {
> struct vhost_vdpa *v = dev->opaque;
> - VirtQueue *vq = virtio_get_queue(dev->vdev, ring->index);
>
> - /*
> - * vhost-vdpa devices does not support in-flight requests. Set all of
them
> - * as available.
> - *
> - * TODO: This is ok for networking, but other kinds of devices might
> - * have problems with these retransmissions.
> - */
> - while (virtqueue_rewind(vq, 1)) {
> - continue;
> - }
> if (v->shadow_vqs_enabled) {
> /*
> * Device vring base was set at device start. SVQ base is handled
by
> @@ -1241,6 +1230,19 @@ static int vhost_vdpa_get_vring_base(struct
vhost_dev *dev,
> int ret;
>
> if (v->shadow_vqs_enabled) {
> + VirtQueue *vq = virtio_get_queue(dev->vdev, ring->index);
> +
> + /*
> + * vhost-vdpa devices does not support in-flight requests. Set all
of
> + * them as available.
> + *
> + * TODO: This is ok for networking, but other kinds of devices
might
> + * have problems with these retransmissions.
> + */
> + while (virtqueue_rewind(vq, 1)) {
> + continue;
> + }
> +
> ring->num = virtio_queue_get_last_avail_idx(dev->vdev,
ring->index);
> return 0;
> }