Skip to content

Instantly share code, notes, and snippets.

@matheusd
Created June 23, 2017 18:28
Show Gist options
  • Save matheusd/be108e5c07f934a0d69fc084a27f21ba to your computer and use it in GitHub Desktop.
Save matheusd/be108e5c07f934a0d69fc084a27f21ba to your computer and use it in GitHub Desktop.
#!/bin/bash
DEVICE=$1
TARGETVM=$2
USB_DEVICE=`qvm-usb |grep $DEVICE |cut -f1`
# Is it already attached
qvm-usb |grep $USB_DEVICE | grep "(attached to "
if [ $? -eq 0 ]; then
echo "detatching $DEVICE"
qvm-usb -d $USB_DEVICE
sleep 1
fi
echo "attaching $DEVICE to $TARGETVM"
qvm-usb -a $TARGETVM $USB_DEVICE
@matheusd
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment