[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-stable] [PATCH 03/25] virtio: recalculate vq->inuse after migratio
From: |
Michael Roth |
Subject: |
[Qemu-stable] [PATCH 03/25] virtio: recalculate vq->inuse after migration |
Date: |
Tue, 20 Sep 2016 12:05:19 -0500 |
From: Stefan Hajnoczi <address@hidden>
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: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Reviewed-by: Cornelia Huck <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
(cherry picked from commit bccdef6b1a204db0f41ffb6e24ce373e4d7890d4)
Signed-off-by: Michael Roth <address@hidden>
---
hw/virtio/virtio.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 8ed260a..0333bb8 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1624,6 +1624,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;
+ }
}
}
--
1.9.1
- [Qemu-stable] [PATCH 24/25] scsi-disk: Cleaning up around tray open state, (continued)
- [Qemu-stable] [PATCH 24/25] scsi-disk: Cleaning up around tray open state, Michael Roth, 2016/09/20
- [Qemu-stable] [PATCH 02/25] ui: fix refresh of VNC server surface, Michael Roth, 2016/09/20
- [Qemu-stable] [PATCH 25/25] virtio-scsi: Don't abort when media is ejected, Michael Roth, 2016/09/20
- [Qemu-stable] [PATCH 08/25] 9pfs: forbid illegal path names, Michael Roth, 2016/09/20
- [Qemu-stable] [PATCH 07/25] net: vmxnet: use g_new for pkt initialisation, Michael Roth, 2016/09/20
- [Qemu-stable] [PATCH 17/25] qemu-char: avoid segfault if user lacks of permisson of a given logfile, Michael Roth, 2016/09/20
- [Qemu-stable] [PATCH 05/25] iscsi: pass SCSI status back for SG_IO, Michael Roth, 2016/09/20
- [Qemu-stable] [PATCH 06/25] net: vmxnet: check IP header length, Michael Roth, 2016/09/20
- [Qemu-stable] [PATCH 16/25] scsi: pvscsi: limit process IO loop to ring size, Michael Roth, 2016/09/20
- [Qemu-stable] [PATCH 23/25] iothread: Stop threads before main() quits, Michael Roth, 2016/09/20
- [Qemu-stable] [PATCH 03/25] virtio: recalculate vq->inuse after migration,
Michael Roth <=
- [Qemu-stable] [PATCH 04/25] virtio: decrement vq->inuse in virtqueue_discard(), Michael Roth, 2016/09/20
- Re: [Qemu-stable] [Qemu-devel] [PATCH 00/25] Patch Round-up for stable 2.6.2, freeze on 2016-08-26, Eric Blake, 2016/09/20
- Re: [Qemu-stable] [PATCH 00/25] Patch Round-up for stable 2.6.2, freeze on 2016-08-26, Michael Roth, 2016/09/20
- Re: [Qemu-stable] [Qemu-devel] [PATCH 00/25] Patch Round-up for stable 2.6.2, freeze on 2016-08-26, John Snow, 2016/09/22