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

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