]> git.proxmox.com Git - mirror_qemu.git/commit
virtio: add missing region cache init in virtio_load()
authorStefan Hajnoczi <stefanha@redhat.com>
Wed, 22 Feb 2017 16:37:34 +0000 (16:37 +0000)
committerMichael S. Tsirkin <mst@redhat.com>
Thu, 2 Mar 2017 05:14:28 +0000 (07:14 +0200)
commit874adf45dbfbae2810423527d777ba37bc5ca974
treed20d7ef2675cfd6208661a1e43013b3400e523d0
parent3cdf847329a9911780372e6d8239839446d09d9f
virtio: add missing region cache init in virtio_load()

Commit 97cd965c070152bc626c7507df9fb356bbe1cd81 ("virtio: use
VRingMemoryRegionCaches for avail and used rings") switched to a memory
region cache to avoid repeated map/unmap operations.

The virtio_load() process is a little tricky because vring addresses are
serialized in two separate places.  VIRTIO 1.0 devices serialize desc
and then a subsection with used and avail.  Legacy devices only
serialize desc.

Live migration of VIRTIO 1.0 devices fails on the destination host with:

  VQ 0 size 0x80 < last_avail_idx 0x12f8 - used_idx 0x0
  Failed to load virtio-blk:virtio
  error while loading state for instance 0x0 of device '0000:00:04.0/virtio-blk'

This happens because the memory region cache is only initialized after
desc is loaded and not after the used and avail subsection is loaded.
If the guest chose memory addresses that don't match the legacy ring
layout then the wrong guest memory location is accessed.

Wait until all ring addresses are known before trying to initialize the
region cache.  Also clarify the incomplete comment about VIRTIO-1 ring
address subsection.

Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Tested-by: Eric Auger <eric.auger@redhat.com>
hw/virtio/virtio.c