]> git.proxmox.com Git - pve-qemu-kvm.git/blob - debian/patches/extra/0006-virtio-recalculate-vq-inuse-after-migration.patch
bump version to 2.6.1-7
[pve-qemu-kvm.git] / debian / patches / extra / 0006-virtio-recalculate-vq-inuse-after-migration.patch
1 From ed3112487835fb5c5ec685e15032641c25018f87 Mon Sep 17 00:00:00 2001
2 From: Stefan Hajnoczi <stefanha@redhat.com>
3 Date: Mon, 15 Aug 2016 13:54:15 +0100
4 Subject: [PATCH 06/10] virtio: recalculate vq->inuse after migration
5
6 The vq->inuse field is not migrated. Many devices don't hold
7 VirtQueueElements across migration so it doesn't matter that vq->inuse
8 starts at 0 on the destination QEMU.
9
10 At least virtio-serial, virtio-blk, and virtio-balloon migrate while
11 holding VirtQueueElements. For these devices we need to recalculate
12 vq->inuse upon load so the value is correct.
13
14 Cc: qemu-stable@nongnu.org
15 Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
16 Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
17 Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
18 Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
19 Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
20 ---
21 hw/virtio/virtio.c | 15 +++++++++++++++
22 1 file changed, 15 insertions(+)
23
24 diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
25 index 111ad8e..486147b 100644
26 --- a/hw/virtio/virtio.c
27 +++ b/hw/virtio/virtio.c
28 @@ -1629,6 +1629,21 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id)
29 }
30 vdev->vq[i].used_idx = vring_used_idx(&vdev->vq[i]);
31 vdev->vq[i].shadow_avail_idx = vring_avail_idx(&vdev->vq[i]);
32 +
33 + /*
34 + * Some devices migrate VirtQueueElements that have been popped
35 + * from the avail ring but not yet returned to the used ring.
36 + */
37 + vdev->vq[i].inuse = vdev->vq[i].last_avail_idx -
38 + vdev->vq[i].used_idx;
39 + if (vdev->vq[i].inuse > vdev->vq[i].vring.num) {
40 + error_report("VQ %d size 0x%x < last_avail_idx 0x%x - "
41 + "used_idx 0x%x",
42 + i, vdev->vq[i].vring.num,
43 + vdev->vq[i].last_avail_idx,
44 + vdev->vq[i].used_idx);
45 + return -1;
46 + }
47 }
48 }
49
50 --
51 2.1.4
52