[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH for-2.7 1/4] virtio: recalculate vq->inuse after
From: |
Cornelia Huck |
Subject: |
Re: [Qemu-devel] [PATCH for-2.7 1/4] virtio: recalculate vq->inuse after migration |
Date: |
Mon, 15 Aug 2016 10:23:35 +0200 |
On Fri, 12 Aug 2016 16:32:55 +0100
Stefan Hajnoczi <address@hidden> wrote:
> The vq->inuse field is not migrated. Many devices don't hold
> VirtQueueElements across migration so it doesn't matter that vq->inuse
> starts at 0 on the destination QEMU.
>
> At least virtio-serial, virtio-blk, and virtio-balloon migrate while
> holding VirtQueueElements. For these devices we need to recalculate
> vq->inuse upon load so the value is correct.
>
> Signed-off-by: Stefan Hajnoczi <address@hidden>
> ---
> hw/virtio/virtio.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index 15ee3a7..4df8274 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -1648,6 +1648,20 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int
> version_id)
> }
> vdev->vq[i].used_idx = vring_used_idx(&vdev->vq[i]);
> vdev->vq[i].shadow_avail_idx = vring_avail_idx(&vdev->vq[i]);
> +
> + /* Some devices migrate VirtQueueElements that have been popped
Make this
/*
* Some...
?
> + * from the avail ring but not yet returned to the used ring.
> + */
> + vdev->vq[i].inuse = vdev->vq[i].last_avail_idx -
> + vdev->vq[i].used_idx;
> + if (vdev->vq[i].inuse > vdev->vq[i].vring.num) {
> + error_report("VQ %d size 0x%x < last_avail_idx 0x%x - "
> + "used_idx 0x%x"
...as you need to add the comma here anyway.
> + i, vdev->vq[i].vring.num,
> + vdev->vq[i].last_avail_idx,
> + vdev->vq[i].used_idx);
> + return -1;
> + }
> }
> }
>
Reviewed-by: Cornelia Huck <address@hidden>
- [Qemu-devel] [PATCH for-2.7 2/4] virtio: decrement vq->inuse in virtqueue_discard(), (continued)
- [Qemu-devel] [PATCH for-2.7 2/4] virtio: decrement vq->inuse in virtqueue_discard(), Stefan Hajnoczi, 2016/08/12
- [Qemu-devel] [PATCH for-2.7 4/4] virtio-balloon: fix stats vq migration, Stefan Hajnoczi, 2016/08/12
- [Qemu-devel] [PATCH for-2.7 3/4] virtio: add virtqueue_rewind(), Stefan Hajnoczi, 2016/08/12
- [Qemu-devel] [PATCH for-2.7 1/4] virtio: recalculate vq->inuse after migration, Stefan Hajnoczi, 2016/08/12
- Re: [Qemu-devel] [PATCH for-2.7 0/4] virtio-balloon: fix stats vq migration, no-reply, 2016/08/12
- Re: [Qemu-devel] [PATCH for-2.7 0/4] virtio-balloon: fix stats vq migration, Gaudenz Steinlin, 2016/08/15