* [Qemu-devel] [PULL 0/2] virtio: fixes
@ 2016-08-23 16:34 Michael S. Tsirkin
2016-08-23 16:34 ` [Qemu-devel] [PULL 1/2] virtio: recalculate vq->inuse after migration Michael S. Tsirkin
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Michael S. Tsirkin @ 2016-08-23 16:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell
The following changes since commit 6bbbb0ac136102098a70b97ab0c07bc7bf53131c:
target-arm: Fix warn about implicit conversion (2016-08-12 11:12:24 +0100)
are available in the git repository at:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream
for you to fetch changes up to 58a83c61496eeb0d31571a07a51bc1947e3379ac:
virtio: decrement vq->inuse in virtqueue_discard() (2016-08-23 19:20:24 +0300)
----------------------------------------------------------------
virtio: fixes
some bugfixes for virtio
balloon is still broken wrt migration
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
----------------------------------------------------------------
Stefan Hajnoczi (2):
virtio: recalculate vq->inuse after migration
virtio: decrement vq->inuse in virtqueue_discard()
hw/virtio/virtio.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] [PULL 1/2] virtio: recalculate vq->inuse after migration
2016-08-23 16:34 [Qemu-devel] [PULL 0/2] virtio: fixes Michael S. Tsirkin
@ 2016-08-23 16:34 ` Michael S. Tsirkin
2016-08-23 16:34 ` [Qemu-devel] [PULL 2/2] virtio: decrement vq->inuse in virtqueue_discard() Michael S. Tsirkin
2016-08-24 19:16 ` [Qemu-devel] [PULL 0/2] virtio: fixes Peter Maydell
2 siblings, 0 replies; 4+ messages in thread
From: Michael S. Tsirkin @ 2016-08-23 16:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Stefan Hajnoczi, qemu-stable, Cornelia Huck
From: Stefan Hajnoczi <stefanha@redhat.com>
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.
Cc: qemu-stable@nongnu.org
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/virtio/virtio.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 15ee3a7..6105c6e 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1648,6 +1648,21 @@ 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
+ * 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",
+ i, vdev->vq[i].vring.num,
+ vdev->vq[i].last_avail_idx,
+ vdev->vq[i].used_idx);
+ return -1;
+ }
}
}
--
MST
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [PULL 2/2] virtio: decrement vq->inuse in virtqueue_discard()
2016-08-23 16:34 [Qemu-devel] [PULL 0/2] virtio: fixes Michael S. Tsirkin
2016-08-23 16:34 ` [Qemu-devel] [PULL 1/2] virtio: recalculate vq->inuse after migration Michael S. Tsirkin
@ 2016-08-23 16:34 ` Michael S. Tsirkin
2016-08-24 19:16 ` [Qemu-devel] [PULL 0/2] virtio: fixes Peter Maydell
2 siblings, 0 replies; 4+ messages in thread
From: Michael S. Tsirkin @ 2016-08-23 16:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Stefan Hajnoczi, qemu-stable, Cornelia Huck
From: Stefan Hajnoczi <stefanha@redhat.com>
virtqueue_discard() moves vq->last_avail_idx back so the element can be
popped again. It's necessary to decrement vq->inuse to avoid "leaking"
the element count.
Cc: qemu-stable@nongnu.org
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/virtio/virtio.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 6105c6e..74c085c 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -268,6 +268,7 @@ void virtqueue_discard(VirtQueue *vq, const VirtQueueElement *elem,
unsigned int len)
{
vq->last_avail_idx--;
+ vq->inuse--;
virtqueue_unmap_sg(vq, elem, len);
}
--
MST
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PULL 0/2] virtio: fixes
2016-08-23 16:34 [Qemu-devel] [PULL 0/2] virtio: fixes Michael S. Tsirkin
2016-08-23 16:34 ` [Qemu-devel] [PULL 1/2] virtio: recalculate vq->inuse after migration Michael S. Tsirkin
2016-08-23 16:34 ` [Qemu-devel] [PULL 2/2] virtio: decrement vq->inuse in virtqueue_discard() Michael S. Tsirkin
@ 2016-08-24 19:16 ` Peter Maydell
2 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2016-08-24 19:16 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: QEMU Developers
On 23 August 2016 at 17:34, Michael S. Tsirkin <mst@redhat.com> wrote:
> The following changes since commit 6bbbb0ac136102098a70b97ab0c07bc7bf53131c:
>
> target-arm: Fix warn about implicit conversion (2016-08-12 11:12:24 +0100)
>
> are available in the git repository at:
>
> git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream
>
> for you to fetch changes up to 58a83c61496eeb0d31571a07a51bc1947e3379ac:
>
> virtio: decrement vq->inuse in virtqueue_discard() (2016-08-23 19:20:24 +0300)
>
> ----------------------------------------------------------------
> virtio: fixes
>
> some bugfixes for virtio
> balloon is still broken wrt migration
Is this a bug we need to fix for the release?
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>
> ----------------------------------------------------------------
> Stefan Hajnoczi (2):
> virtio: recalculate vq->inuse after migration
> virtio: decrement vq->inuse in virtqueue_discard()
>
> hw/virtio/virtio.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
Applied to master, thanks.
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-08-24 19:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-23 16:34 [Qemu-devel] [PULL 0/2] virtio: fixes Michael S. Tsirkin
2016-08-23 16:34 ` [Qemu-devel] [PULL 1/2] virtio: recalculate vq->inuse after migration Michael S. Tsirkin
2016-08-23 16:34 ` [Qemu-devel] [PULL 2/2] virtio: decrement vq->inuse in virtqueue_discard() Michael S. Tsirkin
2016-08-24 19:16 ` [Qemu-devel] [PULL 0/2] virtio: fixes Peter Maydell
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.