A set of command line tools and a service to make setting up passthrough USB devices easier:
add-custom-usb-policies
- script to store and apply custom USB policies required for specific devicesattach-usb-devices
- script and service to automatically connect USB devices to VMS when XCP-ng boots upplug-usb
- attach a physical USB device to a VM in one commandunplug-usb
- remove a physical USB device from a VM in one command
To set up, copy the files onto your server and run install.sh
to copy everything and set up the service.
You can add any plug-usb
commands you want to run on boot by modifying /usr/bin/attach-usb-devices
.
You can add any custom USB policies you need applied on install or after updates by modifying add-custom-usb-policies
before running install.sh
.
You can also use plug-usb
directly if you want to attach a new device on demand:
# You can use xe vusb-list and xe vm-list to figure out the IDs you need
plug-usb <vusb-uuid> <vm-uuid>
If you want to unplug a device later, you can use unplug-usb
:
unplug-usb <vusb-uuid>
You can list all physical USB devices available and get their UUIDs with xe pusb-list
.
If you customise add-custom-usb-policies
, you can run it again after upgrades to ensure your custom policies are applied again.
Thank you gpoole for this, appreciated!
@stoneobscurity I had the same problem, this is my proposal, a new file called add-custom-usb-policies with the following contents:
Kept my two devices in there just for illustration, make sure to read through and edit to your needs.
Then, in attach-usb-devices, just add add-custom-usb-policies before the plug-usb calls.
And make sure to add the add-custom-usb-policies file to install.sh