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

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