* [Qemu-devel] [PATCH] virtio: fix up VQ checks
@ 2010-11-23 20:02 Michael S. Tsirkin
2010-11-23 20:17 ` [Qemu-devel] " Juan Quintela
0 siblings, 1 reply; 2+ messages in thread
From: Michael S. Tsirkin @ 2010-11-23 20:02 UTC (permalink / raw)
To: qemu-devel, Juan Quintela
When migration triggers before a VQ is initialized,
base pa is 0 and last_used_index must be 0 too:
we don't have a ring to compare to.
This fixes a bug introduced in
258dc7c96bb4b7ca71d5bee811e73933310e168c.
Reporrted-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
Compile-tested only.
Juan, could you tell me whether this fixes the bug
you see please?
hw/virtio.c | 23 ++++++++++++++---------
1 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/hw/virtio.c b/hw/virtio.c
index a2a657e..1df3578 100644
--- a/hw/virtio.c
+++ b/hw/virtio.c
@@ -681,7 +681,6 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f)
uint32_t features;
uint32_t supported_features =
vdev->binding->get_features(vdev->binding_opaque);
- uint16_t num_heads;
if (vdev->binding->load_config) {
ret = vdev->binding->load_config(vdev->binding_opaque, f);
@@ -712,17 +711,23 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f)
qemu_get_be16s(f, &vdev->vq[i].last_avail_idx);
if (vdev->vq[i].pa) {
+ uint16_t nheads;
virtqueue_init(&vdev->vq[i]);
- }
- num_heads = vring_avail_idx(&vdev->vq[i]) - vdev->vq[i].last_avail_idx;
- /* Check it isn't doing very strange things with descriptor numbers. */
- if (num_heads > vdev->vq[i].vring.num) {
- fprintf(stderr, "VQ %d size 0x%x Guest index 0x%x "
+ nheads = vring_avail_idx(&vdev->vq[i]) - vdev->vq[i].last_avail_idx;
+ /* Check it isn't doing very strange things with descriptor numbers. */
+ if (nheads > vdev->vq[i].vring.num) {
+ fprintf(stderr, "VQ %d size 0x%x Guest index 0x%x "
"inconsistent with Host index 0x%x: delta 0x%x\n",
- i, vdev->vq[i].vring.num,
+ i, vdev->vq[i].vring.num,
vring_avail_idx(&vdev->vq[i]),
- vdev->vq[i].last_avail_idx, num_heads);
- return -1;
+ vdev->vq[i].last_avail_idx, nheads);
+ return -1;
+ }
+ } else if (vdev->vq[i].last_avail_idx) {
+ fprintf(stderr, "VQ %d address 0x0 "
+ "inconsistent with Host index 0x%x\n",
+ i, vdev->vq[i].last_avail_idx);
+ return -1;
}
if (vdev->binding->load_queue) {
ret = vdev->binding->load_queue(vdev->binding_opaque, i, f);
--
1.7.3.2.91.g446ac
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [Qemu-devel] Re: [PATCH] virtio: fix up VQ checks
2010-11-23 20:02 [Qemu-devel] [PATCH] virtio: fix up VQ checks Michael S. Tsirkin
@ 2010-11-23 20:17 ` Juan Quintela
0 siblings, 0 replies; 2+ messages in thread
From: Juan Quintela @ 2010-11-23 20:17 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel
"Michael S. Tsirkin" <mst@redhat.com> wrote:
> When migration triggers before a VQ is initialized,
> base pa is 0 and last_used_index must be 0 too:
> we don't have a ring to compare to.
>
> This fixes a bug introduced in
> 258dc7c96bb4b7ca71d5bee811e73933310e168c.
>
> Reporrted-by: Juan Quintela <quintela@redhat.com>
extra 'r'
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>
> Compile-tested only.
> Juan, could you tell me whether this fixes the bug
> you see please?
Fixes it.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-11-23 20:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-23 20:02 [Qemu-devel] [PATCH] virtio: fix up VQ checks Michael S. Tsirkin
2010-11-23 20:17 ` [Qemu-devel] " Juan Quintela
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).