From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PULL 3/3] usb-host: skip open on pending postload bh
Date: Mon, 7 May 2018 11:44:48 +0200 [thread overview]
Message-ID: <20180507094448.32386-4-kraxel@redhat.com> (raw)
In-Reply-To: <20180507094448.32386-1-kraxel@redhat.com>
usb-host emulates a device unplug after live migration, because the
device state is unknown and unplug/replug makes sure the guest
re-initializes the device into a working state. This can't be done in
post-load though, so post-load just schedules a bottom half which
executes after vmload is complete.
It can happen that the device autoscan timer hits the race window
between scheduling and running the bottom half, which in turn can
triggers an assert().
Fix that issue by just ignoring the usb_host_open() call in case the
bottom half didn't execute yet.
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1572851
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20180503062932.17233-1-kraxel@redhat.com
---
hw/usb/host-libusb.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index dc0a8fe295..f31e9cbbb8 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -102,6 +102,7 @@ struct USBHostDevice {
/* callbacks & friends */
QEMUBH *bh_nodev;
QEMUBH *bh_postld;
+ bool bh_postld_pending;
Notifier exit;
/* request queues */
@@ -870,6 +871,10 @@ static int usb_host_open(USBHostDevice *s, libusb_device *dev)
int rc;
Error *local_err = NULL;
+ if (s->bh_postld_pending) {
+ return -1;
+ }
+
trace_usb_host_open_started(bus_num, addr);
if (s->dh != NULL) {
@@ -1528,6 +1533,7 @@ static void usb_host_post_load_bh(void *opaque)
if (udev->attached) {
usb_device_detach(udev);
}
+ dev->bh_postld_pending = false;
usb_host_auto_check(NULL);
}
@@ -1539,6 +1545,7 @@ static int usb_host_post_load(void *opaque, int version_id)
dev->bh_postld = qemu_bh_new(usb_host_post_load_bh, dev);
}
qemu_bh_schedule(dev->bh_postld);
+ dev->bh_postld_pending = true;
return 0;
}
--
2.9.3
next prev parent reply other threads:[~2018-05-07 9:45 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-07 9:44 [Qemu-devel] [PULL 0/3] Usb 20180507 patches Gerd Hoffmann
2018-05-07 9:44 ` [Qemu-devel] [PULL 1/3] usb-mtp: Add some NULL checks for issues pointed out by coverity Gerd Hoffmann
2018-05-15 18:50 ` Peter Maydell
2018-05-17 21:41 ` Bandan Das
2018-05-18 18:22 ` [Qemu-devel] [PATCH] usb-mtp: Assert on suspicious TYPE_DATA packet from initiator Bandan Das
2018-05-18 18:25 ` Peter Maydell
2018-05-18 18:38 ` Bandan Das
2018-05-18 18:49 ` Peter Maydell
2018-05-18 19:04 ` Bandan Das
2018-05-18 18:49 ` [Qemu-devel] [PATCH v2] usb-mtp: Return error " Bandan Das
2018-05-18 18:25 ` [Qemu-devel] [PULL 1/3] usb-mtp: Add some NULL checks for issues pointed out by coverity Bandan Das
2018-05-07 9:44 ` [Qemu-devel] [PULL 2/3] usb-mtp: Unconditionally check for the readonly bit Gerd Hoffmann
2018-05-07 9:44 ` Gerd Hoffmann [this message]
2018-05-08 13:22 ` [Qemu-devel] [PULL 0/3] Usb 20180507 patches Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180507094448.32386-4-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).