Question
Is it possible to attach a USB device to a VM?
Environment
Any OnApp with KVM HVs
Answer
This is unfortunately outside the scope of Support, and it is a project that will be undertaken at one's own discretion.
Given that statement, here is some advice for making this happen:
You might want to take a look at this first and see if it works for you:
http://rolandtapken.de/blog/2011-04/how-auto-hotplug-usb-devices-libvirt-vms-update-1
The 'virsh attach-device' would hopefully allow you to at least hotplug the device once the VM is up and running, and the XML file should only need to be created on the HV once the device is plugged in.
usb.xml file example:
<hostdev mode ‘subsystem’ type=’usb’>
<source>
<vendor id='0x0D7A'/>
<product id='0x0001'/>
</source>
</hostdev>
Then, run the command (with the proper VM ID):
virsh attach-device vmserverID /path/to/usb.xml
It's also advised to disable auto updates and not to restart the VM.
For getting the HV to create the file and run the command automatically during the boot, you can do something like the following:
For cloudboot HVs, you could add the file to ./rw/ so it would be available after each HV boot and could be referenced directly from there. For static HVs, it should hang around as long as you don't put it in /onapp/config.
Regarding hotplugging automatically, probably the best we could suggest would be a cron job or similar that checks every 5 mins if the VM is running and, if so, checks if the USB disk is attached, and if not, runs the 'virsh attach-device' command. It may work for you.
If none of these work for you, you can contact our Professional Services team at ps@onapp.com for a quote for a different solution.