Home QEMU/KVM: failed to attach usb-host device
Reply: 0

QEMU/KVM: failed to attach usb-host device

win-t
1#
win-t Published in 2018-02-14 10:10:20Z

I have this device that will be disconnect and reconnect again when libusb_reset_device, how can I forward it to VM. I've look at source code, and it call libusb_reset_device.

this is log trace when I attach that device:

1720@1518601481.571033:usb_host_open_started dev 2:3
1720@1518601481.571164:usb_host_detach_kernel dev 2:3, if 0
1720@1518601481.578244:usb_host_parse_config dev 2:3, value 1, active 1
1720@1518601481.578276:usb_host_parse_interface dev 2:3, num 0, alt 0, active 1
1720@1518601481.578287:usb_host_parse_endpoint dev 2:3, ep 1, in, bulk, active 1
. . .
1720@1518601481.579041:usb_host_open_success dev 2:3
1720@1518601481.694268:usb_host_reset dev 2:3
1720@1518601482.072884:usb_host_reset dev 2:3
1720@1518601482.072954:usb_host_close dev 2:3
1720@1518601482.073045:usb_host_auto_scan_enabled 

this is dmesg log of the host (not the VM)


Feb 14 16:43:25 win-pc kernel: usb 2-1: new high-speed USB device number 3 using xhci_hcd
Feb 14 16:43:25 win-pc kernel: usb 2-1: New USB device found, idVendor=1782, idProduct=5d24
Feb 14 16:43:25 win-pc kernel: usb 2-1: New USB device strings: Mfr=2, Product=3, SerialNumber=4
Feb 14 16:43:25 win-pc kernel: usb 2-1: Product: Spreadtrum
Feb 14 16:43:25 win-pc kernel: usb 2-1: Manufacturer: Spreadtrum
Feb 14 16:43:25 win-pc kernel: usb 2-1: SerialNumber: 20161122200747
Feb 14 16:43:26 win-pc kernel: usb-storage 2-1:1.0: USB Mass Storage device detected
Feb 14 16:43:26 win-pc kernel: scsi host4: usb-storage 2-1:1.0
Feb 14 16:43:26 win-pc kernel: usbcore: registered new interface driver usb-storage
Feb 14 16:43:26 win-pc kernel: usbcore: registered new interface driver uas
Feb 14 16:43:27 win-pc kernel: scsi 4:0:0:0: Direct-Access     Linux    File-CD Gadget   0310 PQ: 0 ANSI: 2
Feb 14 16:43:27 win-pc kernel: sd 4:0:0:0: Power-on or device reset occurred
Feb 14 16:43:27 win-pc kernel: sd 4:0:0:0: [sdb] Attached SCSI removable disk
Feb 14 16:44:41 win-pc kernel: usb 2-1: reset high-speed USB device number 3 using xhci_hcd
Feb 14 16:44:41 win-pc kernel: usb 2-1: USB disconnect, device number 3
Feb 14 16:44:42 win-pc kernel: usb 2-1: new high-speed USB device number 4 using xhci_hcd
Feb 14 16:44:42 win-pc kernel: usb 2-1: New USB device found, idVendor=1782, idProduct=5d24
Feb 14 16:44:42 win-pc kernel: usb 2-1: New USB device strings: Mfr=2, Product=3, SerialNumber=4
Feb 14 16:44:42 win-pc kernel: usb 2-1: Product: Spreadtrum
Feb 14 16:44:42 win-pc kernel: usb 2-1: Manufacturer: Spreadtrum
Feb 14 16:44:42 win-pc kernel: usb 2-1: SerialNumber: 20161122200747
Feb 14 16:44:42 win-pc kernel: usb-storage 2-1:1.0: USB Mass Storage device detected
Feb 14 16:44:42 win-pc kernel: scsi host4: usb-storage 2-1:1.0
Feb 14 16:44:43 win-pc kernel: scsi 4:0:0:0: Direct-Access     Linux    File-CD Gadget   0310 PQ: 0 ANSI: 2
. . .

as you can see, the device will disconnect itself and reconnect again after that

How can I forward this kind of device to VM

EDIT 1:

If you wonder what device is it, it is an android phone. I want to pass it to VM so I can use adb on the VM

EDIT 2:

my timezone is UTC+7. you can see the correlation between qemu trace log and dmesg log based on the timestamp

EDIT 3:

I've tried using device_add usb-host,vendorid=1782,productid=5d24 instead of using hostbus and hostaddr, this lead to infinite loop of:

  • qemu try to claim the device
  • device disconnect itself and reconnect again
  • qemu try to claim the device again
  • device disconnect itself and reconnect again
  • and so on ...
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.297466 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO