Blame SOURCES/kvm-virtio-rng-process-pending-requests-on-DRIVER_OK.patch

383d26
From 01ad4c3dbed4a506e4c7988026336181aa5fd991 Mon Sep 17 00:00:00 2001
383d26
From: Pankaj Gupta <pagupta@redhat.com>
383d26
Date: Fri, 13 Jul 2018 12:52:28 +0200
383d26
Subject: [PATCH 42/89] virtio-rng: process pending requests on DRIVER_OK
383d26
383d26
RH-Author: Pankaj Gupta <pagupta@redhat.com>
383d26
Message-id: <20180713125228.14458-1-pagupta@redhat.com>
383d26
Patchwork-id: 81347
383d26
O-Subject: [RHEL7.6 qemu-kvm-rhev PATCH] virtio-rng: process pending requests on DRIVER_OK
383d26
Bugzilla: 1576743
383d26
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
383d26
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
383d26
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
383d26
383d26
virtio-rng device causes old guest kernels(2.6.32) to hang on latest qemu.
383d26
The driver attempts to read from the virtio-rng device too early in it's
383d26
initialization. Qemu detects guest is not ready and returns, resulting in
383d26
hang.
383d26
383d26
To fix handle pending requests when guest is running and driver status is
383d26
set to 'VIRTIO_CONFIG_S_DRIVER_OK'.
383d26
383d26
CC: qemu-stable@nongnu.org
383d26
Reported-by: Sergio lopez <slopezpa@redhat.com>
383d26
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
383d26
Signed-off-by: Pankaj Gupta <pagupta@redhat.com>
383d26
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
383d26
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
383d26
(cherry picked from commit 5d9c9ea22ab4f3b3ee497523e34b6f4d3281f62d)
383d26
Signed-off-by: Pankaj Gupta <pagupta@redhat.com>
383d26
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
383d26
---
383d26
 hw/virtio/virtio-rng.c | 14 ++++++++++++++
383d26
 1 file changed, 14 insertions(+)
383d26
383d26
diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c
383d26
index 289bbca..855f1b4 100644
383d26
--- a/hw/virtio/virtio-rng.c
383d26
+++ b/hw/virtio/virtio-rng.c
383d26
@@ -156,6 +156,19 @@ static void check_rate_limit(void *opaque)
383d26
     vrng->activate_timer = true;
383d26
 }
383d26
 
383d26
+static void virtio_rng_set_status(VirtIODevice *vdev, uint8_t status)
383d26
+{
383d26
+    VirtIORNG *vrng = VIRTIO_RNG(vdev);
383d26
+
383d26
+    if (!vdev->vm_running) {
383d26
+        return;
383d26
+    }
383d26
+    vdev->status = status;
383d26
+
383d26
+    /* Something changed, try to process buffers */
383d26
+    virtio_rng_process(vrng);
383d26
+}
383d26
+
383d26
 static void virtio_rng_device_realize(DeviceState *dev, Error **errp)
383d26
 {
383d26
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
383d26
@@ -261,6 +274,7 @@ static void virtio_rng_class_init(ObjectClass *klass, void *data)
383d26
     vdc->realize = virtio_rng_device_realize;
383d26
     vdc->unrealize = virtio_rng_device_unrealize;
383d26
     vdc->get_features = get_features;
383d26
+    vdc->set_status = virtio_rng_set_status;
383d26
 }
383d26
 
383d26
 static const TypeInfo virtio_rng_info = {
383d26
-- 
383d26
1.8.3.1
383d26