From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Yuri Nesterov <yuri.nesterov@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH] usb-host: enable autoscan for bus+addr to survive host suspend/resume
Date: Thu, 17 Apr 2025 10:41:10 +0100 [thread overview]
Message-ID: <aADMttudIP3zC85W@redhat.com> (raw)
In-Reply-To: <CAB_o470VGNmj_4LKvo3-Y6O7LiKiJ4QXczt6ZqRua_mpM1LN2A@mail.gmail.com>
On Wed, Apr 16, 2025 at 10:27:54PM +0300, Yuri Nesterov wrote:
> On Wed, Apr 16, 2025 at 8:07 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
> >
> > On Wed, Apr 16, 2025 at 07:19:29PM +0300, Yuri Nesterov wrote:
> > > 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.
> >
> > So IIUC what you're saying is that on suspend the host device
> > is removed by the kernel, and on resume, the USB device is
> > recreated. So QEMU's open file handle for the USB device is
> > invalid after resume.
> >
> > If the /dev/bus/usb/NNN/NNN file goes away and then gets
> > re-created by the kernel though, we can't assume QEMU is
> > going to be able to re-open the new /dev/bus/usb device
> > file though.
>
> I'm not sure if the file actually goes away. It looks like the internal
> state of the device changes and QEMU receives a "no device"
> response in usb_host_req_complete_data. However, the file
> remains in place. At least I don't see any changes in udevadm
> monitor or inotifywait aside from attribute modifications.
>
> After resuming from suspend, the device doesn't work on either
> host or guest. Probably the device stays with a detached kernel
> driver since QEMU can't reattach it after receiving the "no device"
> error. Adding such devices to the hotplug watchlist causes QEMU
> to reopen them the same way it does for devices specified by
> vendorid and productid or hostport.
This is a bit odd, as AFAICT from reading the code, the
usb_host_auto_check wll only trigger close + re-open of
the device, if there is a period of time in which the
/dev/bus/usb device node does not exist, but you're
saying it remains existing across suspend/resume.
>
> The reason bus+addr devices aren't currently added to that list is well
> explained in commit e058fa2dd599ccc780d334558be9c1d155222b80.
> A special case was made because the device address changes every
> time it's replugged. However, it turns out that it doesn't change after
> a suspend/resume cycle so adding them to the list allows them to
> keep working after resume.
>
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2025-04-17 9:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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é [this message]
2025-04-17 14:12 ` Yuri Nesterov
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=aADMttudIP3zC85W@redhat.com \
--to=berrange@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=yuri.nesterov@gmail.com \
/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).