qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

virtio-rng: process pending requests on DRIVER_OK

virtio-rng device causes old guest kernels(2.6.32) to hang on latest qemu.
The driver attempts to read from the virtio-rng device too early in it's
initialization. Qemu detects guest is not ready and returns, resulting in
hang.

To fix handle pending requests when guest is running and driver status is
set to 'VIRTIO_CONFIG_S_DRIVER_OK'.

CC: qemu-stable@nongnu.org
Reported-by: Sergio lopez <slopezpa@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Pankaj Gupta <pagupta@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 5d9c9ea22ab4f3b3ee497523e34b6f4d3281f62d)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>

authored by

Pankaj Gupta and committed by
Michael Roth
d109f8eb 2379ac13

+14
+14
hw/virtio/virtio-rng.c
··· 156 156 vrng->activate_timer = true; 157 157 } 158 158 159 + static void virtio_rng_set_status(VirtIODevice *vdev, uint8_t status) 160 + { 161 + VirtIORNG *vrng = VIRTIO_RNG(vdev); 162 + 163 + if (!vdev->vm_running) { 164 + return; 165 + } 166 + vdev->status = status; 167 + 168 + /* Something changed, try to process buffers */ 169 + virtio_rng_process(vrng); 170 + } 171 + 159 172 static void virtio_rng_device_realize(DeviceState *dev, Error **errp) 160 173 { 161 174 VirtIODevice *vdev = VIRTIO_DEVICE(dev); ··· 261 274 vdc->realize = virtio_rng_device_realize; 262 275 vdc->unrealize = virtio_rng_device_unrealize; 263 276 vdc->get_features = get_features; 277 + vdc->set_status = virtio_rng_set_status; 264 278 } 265 279 266 280 static const TypeInfo virtio_rng_info = {