Page 1 of 1
Identical USB dongles
Posted: 21. Oct 2010, 00:02
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?
Re: Identical USB dongles
Posted: 12. Mar 2011, 01:37
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