Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USB device attach failed #5997

Closed
chris-freedom opened this issue Aug 13, 2020 · 13 comments
Closed

USB device attach failed #5997

chris-freedom opened this issue Aug 13, 2020 · 13 comments
Labels
affects-4.1 This issue affects Qubes OS 4.1. C: kernel C: usb proxy eol-4.1 Closed because Qubes 4.1 has reached end-of-life (EOL) P: default Priority: default. Default priority for new issues, to be replaced given sufficient information. T: bug Type: bug report. A problem or defect resulting in unintended behavior in something that exists.

Comments

@chris-freedom
Copy link

Qubes OS version
R4.0

Affected component(s) or functionality
Sys-usb attaching

Brief summary
When i try to attach my wi-fi usb adapter to any vm, i get an error

To Reproduce

  1. qvm-usb attach myvm sys-usb:1-2
  2. wait for 15-20 seconds
  3. error

Expected behavior
Attaching should finished successfully

Actual behavior
Got an error:
Device attach failed: Attach timeout, check kernel log for details. VM: "myvm" File: "/usr/lib/qubes/usb-import" Version Control: https://github.com/QubesOS/qubes-app-linux-usb-proxy/blob/master/src/usb-import

Additional context
More than one year all works fine with the same usb adapter. An error occurred in last one or two weeks. Usb adapter model TP-Link TL-WN722N V1.0

Relevant documentation you've consulted
https://www.qubes-os.org/doc/usb-devices/

Related, non-duplicate issues
none

@chris-freedom chris-freedom added P: default Priority: default. Default priority for new issues, to be replaced given sufficient information. T: bug Type: bug report. A problem or defect resulting in unintended behavior in something that exists. labels Aug 13, 2020
@neowutran
Copy link

What kernel do you use for sys-usb ? If you use >= 5.7, try to use <=5.6 instead
(I think maybe linked to this one: #5905)

@chris-freedom
Copy link
Author

What kernel do you use for sys-usb ? If you use >= 5.7, try to use <=5.6 instead
(I think maybe linked to this one: #5905)

[user@sys-usb ~]$ uname -r
4.19.132-1.pvops.qubes.x86_64

@chris-freedom
Copy link
Author

I ran sys-usb under kernel 4.19.107-1.pvops.qubes.x86_64 and everything works fine, so the problem is with the kernel 4.19.132-1.pvops.qubes.x86_64

@andrewdavidwong andrewdavidwong added C: usb proxy needs diagnosis Requires technical diagnosis from developer. Replace with "diagnosed" or remove if otherwise closed. labels Aug 15, 2020
@andrewdavidwong andrewdavidwong added this to the Release 4.0 updates milestone Aug 15, 2020
@chris-freedom
Copy link
Author

Problem fixed with kernel 4.19.147

@andrewdavidwong andrewdavidwong removed the needs diagnosis Requires technical diagnosis from developer. Replace with "diagnosed" or remove if otherwise closed. label Oct 18, 2020
@adrelanos
Copy link
Member

Got the same issue.

Dom0:

qvm-usb a vm-name sys-usb:3-3

Device attach failed: /usr/lib/qubes/usb-import: 50: /usr/lib/qubes/usb-import: cannot open /sys/devices/platform/vhci_hcd/status: No such fileNo unused port found! VM: "vm-name" File: "/usr/lib/qubes/usb-import" Version Control: https://github.com/QubesOS/qubes-app-linux-usb-proxy/blob/master/src/usb-import/usr/lib/qubes/usb-import: 81: /usr/lib/qubes/usb-import: cannot create /sys/devices/platform/vhci_hcd/attach: Directory nonexistent

Please re-open.

Inside VM journal:

Jul 25 14:53:24 vm-name qubes.USBAttach-dom0[1973]: /usr/lib/qubes/usb-import: 50: /usr/lib/qubes/usb-import: cannot open /sys/devices/platform/vhci_hcd/status: No such file
Jul 25 14:53:24 vm-name qubes.USBAttach-dom0[1973]: No unused port found!
Jul 25 14:53:24 vm-name qubes.USBAttach-dom0[1973]: VM: "vm-name" File: "/usr/lib/qubes/usb-import"
Jul 25 14:53:24 vm-name qubes.USBAttach-dom0[1973]: Version Control:
Jul 25 14:53:24 vm-name qubes.USBAttach-dom0[1973]: https://github.com/QubesOS/qubes-app-linux-usb-proxy/blob/master/src/usb-import
Jul 25 14:53:24 vm-name qubes.USBAttach-dom0[1973]: /usr/lib/qubes/usb-import: 81: /usr/lib/qubes/usb-import: cannot create /sys/devices/platform/vhci_hcd/attach: Directory nonexistent

@adrelanos
Copy link
Member

For debugging inside VM edited /usr/lib/qubes/usb-import, enabled xtrace, i.e. changed first line from #!/bin/sh to #!/bin/sh -x.

Jul 25 14:58:46 vm-name qubes.USBAttach-dom0[2891]: + read untrusted_devid untrusted_speed untrusted_extra
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: + [ -z 196613 -a -z 12 ]
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: + speed=2
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: + [ 196613 -ge 0 -a 196613 -lt 4294967296 ]
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: + devid=196613
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: + [ 2 -ge 5 ]
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: + hub_type=hs
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: + find_port hs
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: + requested_hub=hs
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: + old_header=
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: /usr/lib/qubes/usb-import: 50: /usr/lib/qubes/usb-import: cannot open /sys/devices/platform/vhci_hcd/status: No such file
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: + ERROR No unused port found!
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: + echo No unused port found!
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: No unused port found!
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: + hostname
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: + echo VM: "vm-name" File: "/usr/lib/qubes/usb-import"
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: VM: "vm-name" File: "/usr/lib/qubes/usb-import"
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: + echo Version Control:
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: Version Control:
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: + echo -n https://github.com/QubesOS/qubes-app-linux-usb-proxy
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: https://github.com/QubesOS/qubes-app-linux-usb-proxy+ echo /blob/master/src/usb-import
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: /blob/master/src/usb-import
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: + exit 1
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: + port=
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: + kill -USR1 2892
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: + attach  196613 2
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: + local port=
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: + local remote_devid=196613
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: + local speed=2
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: /usr/lib/qubes/usb-import: 81: /usr/lib/qubes/usb-import: cannot create /sys/devices/platform/vhci_hcd/attach: Directory nonexistent
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: + printf %s %u %u %u  0 196613 2
Jul 25 14:58:47 vm-name qubes.USBAttach-dom0[2891]: + exit 1
ls -la /sys/devices/platform/vhci_hcd

ls: cannot access '/sys/devices/platform/vhci_hcd': No such file or directory

ls -la /sys/devices/platform/
total 0
drwxr-xr-x 10 root root    0 Jul 25 14:55  .
drwxr-xr-x 18 root root    0 Jul 25 14:52  ..
drwxr-xr-x  4 root root    0 Jul 25 15:03 'Fixed MDIO bus.0'
drwxr-xr-x  3 root root    0 Jul 25 15:03  intel_rapl_msr.0
drwxr-xr-x  3 root root    0 Jul 25 15:03  kgdboc
drwxr-xr-x  4 root root    0 Jul 25 14:55  pcspkr
drwxr-xr-x  3 root root    0 Jul 25 15:03  platform-framebuffer.0
drwxr-xr-x  2 root root    0 Jul 25 15:03  power
drwxr-xr-x  4 root root    0 Jul 25 15:03  reg-dummy
drwxr-xr-x  4 root root    0 Jul 25 14:52  serial8250
-rw-r--r--  1 root root 4096 Jul 25 14:55  uevent
sudo mkdir /sys/devices/platform/vhci_hcd

mkdir: cannot create directory ‘/sys/devices/platform/vhci_hcd’: Operation not permitted

https://github.com/QubesOS/qubes-app-linux-usb-proxy/blob/master/src/usb-import

@andrewdavidwong andrewdavidwong added the needs diagnosis Requires technical diagnosis from developer. Replace with "diagnosed" or remove if otherwise closed. label Jul 25, 2021
@marmarek
Copy link
Member

The very first line of this script tries to load the vhci-hcd kernel module - did it succeeded, do you have this module loaded?

@adrelanos
Copy link
Member

Now I cannot even get the device being show with qvm-usb in dom0 anymore. Not sure if I should create a different ticket for thta.

In sys-usb strangely vhci-hdc isn't load and cannot be load.

user@sys-usb:~$ lsmod  | grep vhci-hcd
user@sys-usb:~$ sudo insmod vhci-hcd

insmod: ERROR: could not load module vhci-hcd: No such file or directory

user@sys-usb:~$ sudo modprobe vhci-hcd
user@sys-usb:~$ lsmod  | grep vhci-hcd

This issues started happening after upgrades. Debian buster based sys-usb.

Jul 30 12:24:22 sys-usb kernel: usb 3-3: new full-speed USB device number 21 using xhci_hcd
Jul 30 12:24:23 sys-usb kernel: usb 3-3: device descriptor read/64, error -71
Jul 30 12:24:23 sys-usb kernel: usb 3-3: device descriptor read/64, error -71
Jul 30 12:24:23 sys-usb kernel: usb 3-3: new full-speed USB device number 22 using xhci_hcd
Jul 30 12:24:23 sys-usb kernel: usb 3-3: device descriptor read/64, error -71
Jul 30 12:24:23 sys-usb kernel: usb 3-3: device descriptor read/64, error -71
Jul 30 12:24:23 sys-usb kernel: usb usb3-port3: attempt power cycle
Jul 30 12:24:24 sys-usb kernel: usb 3-3: new full-speed USB device number 23 using xhci_hcd
Jul 30 12:24:24 sys-usb kernel: usb 3-3: Device not responding to setup address.
Jul 30 12:24:24 sys-usb kernel: usb 3-3: Device not responding to setup address.
Jul 30 12:24:24 sys-usb kernel: usb 3-3: device not accepting address 23, error -71
Jul 30 12:24:24 sys-usb kernel: usb 3-3: new full-speed USB device number 24 using xhci_hcd
Jul 30 12:24:24 sys-usb kernel: usb 3-3: Device not responding to setup address.
Jul 30 12:24:25 sys-usb kernel: usb 3-3: Device not responding to setup address.
Jul 30 12:24:25 sys-usb kernel: usb 3-3: device not accepting address 24, error -71
Jul 30 12:24:25 sys-usb kernel: usb usb3-port3: unable to enumerate USB device

The issue doesn't happen in another computer with plain Debian, same device, same cable.


[ -f "/usr/sbin/modprobe" ] && (modprobe vhci-hcd || exit 1)

Would a pull request be accepted adding more debug output here?

  1. If modprobe doesn't exist, mention that and continue.
  2. If modprobe vhci-hcd fails, mention that and exit 1.

(That's implemented now. Just the debug output would be new.)

@marmarek
Copy link
Member

user@sys-usb:~$ lsmod | grep vhci-hcd

lsmod (and kernel generally) shows - as _ in module names

@marmarek
Copy link
Member

This issues started happening after upgrades. Debian buster based sys-usb.

What is the kernel version in sys-usb? Which one worked before?

@adrelanos
Copy link
Member

Ok, actually is load. (Error despite.)

lsmod | grep vhci
vhci_hcd               57344  0
usbip_core             36864  1 vhci_hcd

What is the kernel version in sys-usb?

Linux version 5.4.125-1.fc25.qubes.x86_64 (mockbuild@) (gcc version 6.4.1 20170727 (Red Hat 6.4.1-1) (GCC)) #1 SMP Wed Jun 16 05:52:00 CEST 2021

Which one worked before?

Not sure.

@jamke
Copy link

jamke commented Dec 11, 2022

I have similar issue when I'm trying to connect bluetooth USB device from a sys-usb (fedora-36 template, autocreated usb-qube) to a standalone fedora-based VM:

Device attach failed: /usr/lib/qubes/usb-import: line 46: /sys/devices/platform/vhci_hcd/status: No such file or directoryNo unused port found! VM: "vm-name" File: "/usr/lib/qubes/usb-import" Version Control: https://github.com/QubesOS/qubes-app-linux-usb-proxy/blob/master/src/usb-import/usr/lib/qubes/usb-import: line 81: /sys/devices/platform/vhci_hcd/attach: No such file or directory/etc/qubes-rpc/qubes.USBAttach: line 14: 1723 Aborted (core dumped) qrexec-client-vm "$domain" "qubes.USB+$busid" /usr/lib/qubes/usb-import "$statefile" < /dev/null > /dev/null 2> /dev/null

Is it the same issue?

@andrewdavidwong andrewdavidwong added the affects-4.1 This issue affects Qubes OS 4.1. label Aug 8, 2023
@andrewdavidwong andrewdavidwong removed this from the Release 4.1 updates milestone Aug 13, 2023
@andrewdavidwong andrewdavidwong added eol-4.1 Closed because Qubes 4.1 has reached end-of-life (EOL) and removed needs diagnosis Requires technical diagnosis from developer. Replace with "diagnosed" or remove if otherwise closed. labels Dec 7, 2024
Copy link

github-actions bot commented Dec 7, 2024

This issue is being closed because:

If anyone believes that this issue should be reopened, please leave a comment saying so.
(For example, if a bug still affects Qubes OS 4.2, then the comment "Affects 4.2" will suffice.)

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-4.1 This issue affects Qubes OS 4.1. C: kernel C: usb proxy eol-4.1 Closed because Qubes 4.1 has reached end-of-life (EOL) P: default Priority: default. Default priority for new issues, to be replaced given sufficient information. T: bug Type: bug report. A problem or defect resulting in unintended behavior in something that exists.
Projects
None yet
Development

No branches or pull requests

6 participants