Blame SOURCES/kvm-usb-host-skip-open-on-pending-postload-bh.patch

357786
From 05af6159ba18882c0bdef512abd3c852b515430b Mon Sep 17 00:00:00 2001
357786
From: Gerd Hoffmann <kraxel@redhat.com>
357786
Date: Wed, 13 Jun 2018 14:07:30 +0200
357786
Subject: [PATCH 03/57] usb-host: skip open on pending postload bh
357786
357786
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
357786
Message-id: <20180613140730.16401-2-kraxel@redhat.com>
357786
Patchwork-id: 80667
357786
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 1/1] usb-host: skip open on pending postload bh
357786
Bugzilla: 1572851
357786
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
357786
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
357786
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
357786
357786
usb-host emulates a device unplug after live migration, because the
357786
device state is unknown and unplug/replug makes sure the guest
357786
re-initializes the device into a working state.  This can't be done in
357786
post-load though, so post-load just schedules a bottom half which
357786
executes after vmload is complete.
357786
357786
It can happen that the device autoscan timer hits the race window
357786
between scheduling and running the bottom half, which in turn can
357786
triggers an assert().
357786
357786
Fix that issue by just ignoring the usb_host_open() call in case the
357786
bottom half didn't execute yet.
357786
357786
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1572851
357786
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
357786
Message-id: 20180503062932.17233-1-kraxel@redhat.com
357786
(cherry picked from commit 3280ea8edede3814553aa19fa27a58daedd48ad9)
357786
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
357786
---
357786
 hw/usb/host-libusb.c | 7 +++++++
357786
 1 file changed, 7 insertions(+)
357786
357786
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
357786
index 1b0be07..0290fb8 100644
357786
--- a/hw/usb/host-libusb.c
357786
+++ b/hw/usb/host-libusb.c
357786
@@ -102,6 +102,7 @@ struct USBHostDevice {
357786
     /* callbacks & friends */
357786
     QEMUBH                           *bh_nodev;
357786
     QEMUBH                           *bh_postld;
357786
+    bool                             bh_postld_pending;
357786
     Notifier                         exit;
357786
 
357786
     /* request queues */
357786
@@ -866,6 +867,10 @@ static int usb_host_open(USBHostDevice *s, libusb_device *dev)
357786
     int rc;
357786
     Error *local_err = NULL;
357786
 
357786
+    if (s->bh_postld_pending) {
357786
+        return -1;
357786
+    }
357786
+
357786
     trace_usb_host_open_started(bus_num, addr);
357786
 
357786
     if (s->dh != NULL) {
357786
@@ -1524,6 +1529,7 @@ static void usb_host_post_load_bh(void *opaque)
357786
     if (udev->attached) {
357786
         usb_device_detach(udev);
357786
     }
357786
+    dev->bh_postld_pending = false;
357786
     usb_host_auto_check(NULL);
357786
 }
357786
 
357786
@@ -1535,6 +1541,7 @@ static int usb_host_post_load(void *opaque, int version_id)
357786
         dev->bh_postld = qemu_bh_new(usb_host_post_load_bh, dev);
357786
     }
357786
     qemu_bh_schedule(dev->bh_postld);
357786
+    dev->bh_postld_pending = true;
357786
     return 0;
357786
 }
357786
 
357786
-- 
357786
1.8.3.1
357786