[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] usb-host: insert usb device into hostdevs to be sca
From: |
linzhecheng |
Subject: |
[Qemu-devel] [PATCH] usb-host: insert usb device into hostdevs to be scaned |
Date: |
Thu, 16 Aug 2018 17:43:56 +0800 |
According to the comment of usb_host_post_load_bh, after removing the
usb device passed through, we will kick host to scan it again, but the emulated
usb device is not added to global list hostdevs, so it can never be discovered
then.
So just do it before usb_host_auto_check. What's more, it's futile to walk devs
in
usb_host_auto_check periodically if hostdevs is empty, so let's delete the
usb_auto_timer.
Signed-off-by: linzhecheng <address@hidden>
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index f31e9cbbb8..632abaa390 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -1534,6 +1534,10 @@ static void usb_host_post_load_bh(void *opaque)
usb_device_detach(udev);
}
dev->bh_postld_pending = false;
+ if (!dev->needs_autoscan) {
+ dev->needs_autoscan = true;
+ QTAILQ_INSERT_TAIL(&hostdevs, dev, next);
+ }
usb_host_auto_check(NULL);
}
@@ -1631,6 +1635,14 @@ static void usb_host_auto_check(void *unused)
int unconnected = 0;
int i, n;
+ if (QTAILQ_EMPTY(&hostdevs)) {
+ if (usb_auto_timer) {
+ timer_del(usb_auto_timer);
+ usb_auto_timer = NULL;
+ }
+ return;
+ }
+
if (usb_host_init() != 0) {
return;
}
@@ -1682,6 +1694,8 @@ static void usb_host_auto_check(void *unused)
s->errcount++;
continue;
}
+ s->needs_autoscan = false;
+ QTAILQ_REMOVE(&hostdevs, s, next);
break;
}
}
--
2.12.2.windows.2
- [Qemu-devel] [PATCH] usb-host: insert usb device into hostdevs to be scaned,
linzhecheng <=
- Re: [Qemu-devel] [PATCH] usb-host: insert usb device into hostdevs to be scaned, Gerd Hoffmann, 2018/08/16
- Re: [Qemu-devel] [PATCH] usb-host: insert usb device into hostdevs to be scaned, linzhecheng, 2018/08/16
- Re: [Qemu-devel] [PATCH] usb-host: insert usb device into hostdevs to be scaned, Gerd Hoffmann, 2018/08/16
- Re: [Qemu-devel] [PATCH] usb-host: insert usb device into hostdevs to be scaned, CheneyLin, 2018/08/16
- Re: [Qemu-devel] [PATCH] usb-host: insert usb device into hostdevs to be scaned, gerd hoffmann, 2018/08/17
- Re: [Qemu-devel] [PATCH] usb-host: insert usb device into hostdevs to be scaned, linzhecheng, 2018/08/19
- Re: [Qemu-devel] [PATCH] usb-host: insert usb device into hostdevs to be scaned, gerd hoffmann, 2018/08/20