aboutsummaryrefslogtreecommitdiff
path: root/hw/virtio
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2017-01-27 16:40:19 +0100
committerMichael S. Tsirkin <mst@redhat.com>2017-02-17 21:52:30 +0200
commitca0176ad8368668c5ad2b428361652e05984e930 (patch)
tree6f4b4f5b64834ab1904e0e18e4b08dccd399653e /hw/virtio
parent991976f751c98c79bd174f0cd48250ac2120d04c (diff)
downloadqemu-ca0176ad8368668c5ad2b428361652e05984e930.zip
qemu-ca0176ad8368668c5ad2b428361652e05984e930.tar.gz
qemu-ca0176ad8368668c5ad2b428361652e05984e930.tar.bz2
virtio: check for vring setup in virtio_queue_update_used_idx
If the vring has not been set up, it is not necessary for vring_used_idx to do anything (as is already the case when the caller is virtio_load). This is harmless for now, but it will be a problem when the MemoryRegionCache has not been set up. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/virtio')
-rw-r--r--hw/virtio/virtio.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index d62509d..cdafcec 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -2156,7 +2156,9 @@ void virtio_queue_set_last_avail_idx(VirtIODevice *vdev, int n, uint16_t idx)
void virtio_queue_update_used_idx(VirtIODevice *vdev, int n)
{
- vdev->vq[n].used_idx = vring_used_idx(&vdev->vq[n]);
+ if (vdev->vq[n].vring.desc) {
+ vdev->vq[n].used_idx = vring_used_idx(&vdev->vq[n]);
+ }
}
void virtio_queue_invalidate_signalled_used(VirtIODevice *vdev, int n)