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

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