Distinguish multiple identical USB devices

This is for discussing general topics about how to use VirtualBox.

Distinguish multiple identical USB devices

Postby scottgus1 » 4. Feb 2019, 01:21

At least as of 5.2.20 and 6.0.0, Virtualbox can tell apart "identical" USB devices and pass the desired device into the correct guest. The port number field in the USB filter is the defining data that enables this.

How to do it:
0. Get each USB device to successfully go into the guest(s) using the Virtualbox guest USB filters and Socratis' tutorial USB basics and troubleshooting.
1. Run 'vboxmanage list usbhost' with none of the devices plugged in, to get a baseline view of the host's present USB devices.
2. Insert one of the devices and let the host fully recognize it.
3. Run 'vboxmanage list usbhost' again, noting the new device and what port number it is on.
4. Repeat steps 2 and 3, insertinging another of the identical USB devices in a different USB port.
5. On each guest's USB filter, add the port number for the desired USB device. (Note that the number you enter will be leading-0-padded to display as 4 digits when you open the filter in the future: you enter 2, it will show later as 0002. In my tests this was not a problem.)
6. Eject the USB devices from the host and reinsert them. Each port-filtered identical sibling should go in its desired guest or remain on the host if no filters match.

A. The USB devices must be inserted into the same physical USB ports on the host each time to go where they are supposed to go in Virtualbox. Plug into the wrong port and the results won't be as planned.

B. 'Vboxmanage list usbhost' must show different port numbers for each identical USB device. It could be possible, due to the layout of the USB subsystem in the host (built-in or added USB root hubs?), that there may be more than one physical USB port that will show the same 'port number' in 'list usbhost'. You may have to experiment with which USB device gets plugged in where to get different port numbers in 'list usbhost' for each identical device.

Background & experiments:
USB devices have various pieces of information, such as VendorID, ProductID, Revision, etc., which appear in the Virtualbox guest's USB filter settings. What to do if two or more USB devices have identical settings in all of the filter fields? If Virtualbox has no unique setting between the devices it will not be able to tell which is which, and will very likely pass all of the attached identical devices into the guest. The port number that the USB device is attached to does not appear in the USB filter's Port box when you select a USB device to make a new filter. However, port number information is available by running 'vboxmanage list usbhost' in a command prompt (tested on a Windows host, other hosts unknown). If the port number for each identical device is different, then entering the port number into the USB filter will cause only that device to go into the guest.

This has been tested on a Windows host with two nearly identical USB thumbdrives (differing only in serial number) and two USB security dongles (completely identical filter information).

For the thumbdrive test, the guest USB filter was cleared out to show only the usual entries: Name, VendorID & ProductID. As expected, both thumbdrives went into the guest. 'Vboxmanage list usbhost' revealed that one thumbdrive's Port number was 2 and the other's was 3. I unplugged the thumbdrives and put '2' in the guest's USB filter for the Port box. When the guest was restarted and the thumdrives were reinserted, only the thumbdrive on "port 2" went into the guest. The other thumb drive appeared on the host. I removed the thumbdrives and switched them. Now the other drive went into the guest and the first remained in the host. I was also able to get two guests to reliably grab one or the other of the thumbdrives based solely on which port the thumbdrive was plugged into, by putting one port number on one guest's USB filter and the other port number on the other guest's USB filter.

I did not do much testing with the security dongles, as the host was someone else's PC and the project involving Virtualbox had to be done during work hours. But using the port number from 'list usbhost' the guest now only uses the one of the two identical dongles and leaves the other in the host, allowing for correct licensing of the special software that runs in both host and guest.
Human government is like that crazy uncle who hides a quarter in his fist behind his back, then asks you to guess which fist the quarter is in...
No matter which side you choose, Left or Right, both Sides are empty.
Posts: 4447
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Win7

Return to Using VirtualBox

Who is online

Users browsing this forum: No registered users and 13 guests