Identical USB dongles

This is for discussing general topics about how to use VirtualBox.
Post Reply
dsjstc
Posts: 20
Joined: 13. Sep 2010, 21:11
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: windows

Identical USB dongles

Post by dsjstc »

I'd like to run two instances of dongle-encumbered Windows software in separate VMs. The dongles, unfortunately, are indistinguishable. Same vendor, same product, no serial number. This seems to make VirtualBox very unhappy.

Is there any way for me to specify which dongle is associated with which VM by port, bus, or device number?
dsjstc
Posts: 20
Joined: 13. Sep 2010, 21:11
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: windows

Re: Identical USB dongles

Post by dsjstc »

Update: I have had success using a scripted combination of usbdetach and usbattach by UUID. Unfortunately, UUID appears to change unpredictably, so you have to look that up each time, based on the Product: field. I've had good luck with the following script:

Code: Select all

#!/bin/bash
DEVSTR=$1
DONGLE=$2
VM=$3
IFS=$'\n'

if [ "$DEVSTR" == "-h" ]; then
	echo $0 DEVICESTR [ DEVICE# ] [VM#]
	echo "   with no VM, just shows UID"
	exit
fi
LIST=$(VBoxManage list usbhost | sed -e '/./{H;$!d;}' -e "x;/$DEVSTR/!d;" | grep UUID | cut -c21-)
DESCS=$(VBoxManage list usbhost | sed -e '/./{H;$!d;}' -e "x;/$DEVSTR/!d;" | grep Product: | cut -c21-)

if [ "$VM" == "" ]; then
	echo "$LIST"
	exit
fi
if [ "$DONGLE" == "" ]; then
	DONGLE=1
fi

UUID=$(echo "$LIST" | sed -n ${DONGLE}p)
echo $UUID

if [ "$VM" != "" ]; then
	for x in 1 2 3 4; do
		echo VBoxManage controlvm Shared$x usbdetach $UUID 2> /dev/null	
		VBoxManage controlvm Shared$x usbdetach $UUID > /dev/null 2> /dev/null	
	done
	echo VBoxManage controlvm Shared$VM usbattach $UUID 
	VBoxManage controlvm Shared$VM usbattach $UUID > /dev/null 2> /dev/null	
fi
Post Reply