|
|
9ae3a8 |
From 4d0430b1f847d672a39c76e6567bb5e88bc33c78 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
Date: Fri, 16 Sep 2016 08:38:18 +0200
|
|
|
9ae3a8 |
Subject: [PATCH] virtio: recalculate vq->inuse after migration
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1474015098-11019-2-git-send-email-stefanha@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 72372
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.3 qemu-kvm PATCH 1/1] virtio: recalculate vq->inuse after migration
|
|
|
9ae3a8 |
Bugzilla: 1376542
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
The vq->inuse field is not migrated. Many devices don't hold
|
|
|
9ae3a8 |
VirtQueueElements across migration so it doesn't matter that vq->inuse
|
|
|
9ae3a8 |
starts at 0 on the destination QEMU.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
At least virtio-serial, virtio-blk, and virtio-balloon migrate while
|
|
|
9ae3a8 |
holding VirtQueueElements. For these devices we need to recalculate
|
|
|
9ae3a8 |
vq->inuse upon load so the value is correct.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Cc: qemu-stable@nongnu.org
|
|
|
9ae3a8 |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
|
|
|
9ae3a8 |
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit bccdef6b1a204db0f41ffb6e24ce373e4d7890d4)
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Conflicts:
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
hw/virtio/virtio.c
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Downstream does not have the vq->used_idx field which was added
|
|
|
9ae3a8 |
upstream as a performance optimization reducing guest memory accesses.
|
|
|
9ae3a8 |
Replace vq->used_idx with vring_used_idx(&vdev->vq[i]).
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/virtio/virtio.c | 15 +++++++++++++++
|
|
|
9ae3a8 |
1 file changed, 15 insertions(+)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
|
|
|
9ae3a8 |
index e67337b..0df4ed3 100644
|
|
|
9ae3a8 |
--- a/hw/virtio/virtio.c
|
|
|
9ae3a8 |
+++ b/hw/virtio/virtio.c
|
|
|
9ae3a8 |
@@ -932,6 +932,21 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f)
|
|
|
9ae3a8 |
vdev->vq[i].last_avail_idx, nheads);
|
|
|
9ae3a8 |
return -1;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ /*
|
|
|
9ae3a8 |
+ * Some devices migrate VirtQueueElements that have been popped
|
|
|
9ae3a8 |
+ * from the avail ring but not yet returned to the used ring.
|
|
|
9ae3a8 |
+ */
|
|
|
9ae3a8 |
+ vdev->vq[i].inuse = vdev->vq[i].last_avail_idx -
|
|
|
9ae3a8 |
+ vring_used_idx(&vdev->vq[i]);
|
|
|
9ae3a8 |
+ if (vdev->vq[i].inuse > vdev->vq[i].vring.num) {
|
|
|
9ae3a8 |
+ error_report("VQ %d size 0x%x < last_avail_idx 0x%x - "
|
|
|
9ae3a8 |
+ "used_idx 0x%x",
|
|
|
9ae3a8 |
+ i, vdev->vq[i].vring.num,
|
|
|
9ae3a8 |
+ vdev->vq[i].last_avail_idx,
|
|
|
9ae3a8 |
+ vring_used_idx(&vdev->vq[i]));
|
|
|
9ae3a8 |
+ return -1;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
} else if (vdev->vq[i].last_avail_idx) {
|
|
|
9ae3a8 |
error_report("VQ %d address 0x0 "
|
|
|
9ae3a8 |
"inconsistent with Host index 0x%x",
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|