All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb-host: enable autoscan for bus+addr to survive host suspend/resume
@ 2025-04-16 16:19 Yuri Nesterov
  2025-04-16 17:07 ` Daniel P. Berrangé
  0 siblings, 1 reply; 5+ messages in thread
From: Yuri Nesterov @ 2025-04-16 16:19 UTC (permalink / raw)
  To: qemu-devel; +Cc: Yuri Nesterov

Currently, there is a special case for usb-host devices added using the
hostbus= and hostaddr= properties to avoid adding them to the hotplug
watchlist, since the address changes every time the device is plugged
in. However, on Linux, when the host system goes into suspend and then
resumes, those devices stop working in both the guest and the host.

Enabling autoscan and adding those devices to the watchlist allows them
to keep working in the guest after host suspend/resume.

Signed-off-by: Yuri Nesterov <yuri.nesterov@gmail.com>
---
 hw/usb/host-libusb.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index c3d642c9d3..32c0251471 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -1227,7 +1227,7 @@ static void usb_host_realize(USBDevice *udev, Error **errp)
         !s->match.vendor_id &&
         !s->match.product_id &&
         !s->match.port) {
-        s->needs_autoscan = false;
+        s->needs_autoscan = true;
         ldev = usb_host_find_ref(s->match.bus_num,
                                  s->match.addr);
         if (!ldev) {
@@ -1244,6 +1244,9 @@ static void usb_host_realize(USBDevice *udev, Error **errp)
         }
     } else {
         s->needs_autoscan = true;
+    }
+
+    if (s->needs_autoscan) {
         QTAILQ_INSERT_TAIL(&hostdevs, s, next);
         usb_host_auto_check(NULL);
     }
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-04-17 14:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-16 16:19 [PATCH] usb-host: enable autoscan for bus+addr to survive host suspend/resume Yuri Nesterov
2025-04-16 17:07 ` Daniel P. Berrangé
2025-04-16 19:27   ` Yuri Nesterov
2025-04-17  9:41     ` Daniel P. Berrangé
2025-04-17 14:12       ` Yuri Nesterov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.