USB passthrough for change-sensitive devices

Discussions related to using VirtualBox on Linux hosts.
Post Reply
mathew7
Posts: 3
Joined: 14. Oct 2019, 12:22

USB passthrough for change-sensitive devices

Post by mathew7 »

Hello,

I've seen that some devices are sensitive to HOST/VM switching and reset their available functions.
Examples could be flashing modes and, my personal case: Sony USB tethering (tested also with Samsung, which behaves as desired; but I have 3 generations of Sonys that behave like this).
When I want to tether my VM, phone tether activation always triggers a USB change (thus tethering will always start at the host), but VM-ing the tethered mode (whether manually or with automatic rule) will "reset" the USB connection and phone will get back to default non-tethered mode. I assume 2nd guest init resets the device.
Steps that happen:
1. phone connected - default config
(optional) 2. VM connection - phone remains in default config
3. tether activated - phone changes USB settings and host sees a disconnection/connection event
4. VM connecting - usb switch is detected (usb ?sw reset?) by phone and switches to default configuration -> back to 1.

As I recall (long time ago), in VMWare, with Windows 7 host, I could force the usb passthough driver on this device (especially tethered). Could something like this be done in Linux? As in no USB init on the host side?

I'm not scared of udev rules damage and know how to recover. No need (ever) for the device on host OS.

Thank you!
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: USB passthrough for change-sensitive devices

Post by mpack »

I'm not sure that this is what you are referring to, but no USB device is designed to cope with being moved from one PC to another while maintaining an ongoing conversation. When you transfer ownership of a USB device between a VM and the host PC then the equivalent in the physical world is of unplugging and then replugging the device into another PC. There is simply do way to do this in the physical world (the world the device is designed to operate in) without interrupting the current connection. The devices themselves simply don't support it.
Martin
Volunteer
Posts: 2562
Joined: 30. May 2007, 18:05
Primary OS: Fedora other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: XP, Win7, Win10, Linux, OS/2

Re: USB passthrough for change-sensitive devices

Post by Martin »

If an USB device switches class / id during initialization you need to create an USB filter for both ids to autmatically reconnect the device after the switch.
Or easier if there is no other device from the same vendor just create a filter with only the vendor id filled in.
mathew7
Posts: 3
Joined: 14. Oct 2019, 12:22

Re: USB passthrough for change-sensitive devices

Post by mathew7 »

mpack wrote:When you transfer ownership of a USB device between a VM and the host PC then the equivalent in the physical world is of unplugging and then replugging the device into another PC.
I agree, each driver will reinitialize the device (the "USB SW reset" I was talking about). My question is if there is a way for the host drivers to "ignore" the device and let it being initialized only at VM level (i.e.: host driver to not do anything by itself, just pass on any initialization done by VM).
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: USB passthrough for change-sensitive devices

Post by socratis »

mathew7 wrote:if there is a way for the host drivers to "ignore" the device and let it being initialized only at VM level
Yes. Create a USB filter that grabs the device. Unplug the device, start the VM and login. Then and only then you plug the USB device on the host. Because of the filter the USB device will be grabbed by VirtualBox and redirected to the VM and the VM only.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
mathew7
Posts: 3
Joined: 14. Oct 2019, 12:22

Re: USB passthrough for change-sensitive devices

Post by mathew7 »

Except that linux host still initializes the device before the VM filter acts. I tried even blacklisting rndis_host, but host->VM transition is still detected. I get the feeling that xhci_hcd does something before any drivers are involved.
Last edited by socratis on 17. Oct 2019, 12:43, edited 1 time in total.
Reason: Removed unnecessary verbatim quote of the whole previous message.
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: USB passthrough for change-sensitive devices

Post by socratis »

mathew7 wrote:Except that linux host still initializes the device before the VM filter acts.
That's a bummer... :?
I don't know how you could prevent that, in theory it shouldn't happen, haven't seen it.

Can you try with a blank USB filter, no values filled in? Maybe there's a chance that the device changes PID/VID (most probably the PID part) and the filter doesn't grab it from the get-go?
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Post Reply