@ha_steve: I was going to update the guide to include this part as soon as I’ve done it in practice. But I’ll throw in the notes I have for now (so no guarantees, I haven’t done this myself yet).
Guide taken mostly from here.
(Of course, adjust the ID’s and paths as needed for your system.)
Find the idVendor
and idProduct
of the USB device you want to attach.
lsusb -v
A few examples from my system, an Aeotec Z-wave:
idVendor 0x0658 Sigma Designs, Inc.
idProduct 0x0200 Aeotec Z-Stick Gen5 (ZW090) - UZB
And a ConBeeII stick:
idVendor 0x1cf1 Dresden Elektronik
idProduct 0x0030
[NOTE] Can also be attached using device address on host, though that might change if they are unplugged or host is rebooted.
EDIT I think you need one file per USB device. Below I have used the ConBeeII stick as an example.
With the above, create an xml file:
sudo nano /var/lib/libvirt/images/hassos-vm/conbeeii.xml
And insert
<hostdev mode='subsystem' type='usb' managed='yes'>
<source>
<vendor id='0x1cf1'/>
<product id='0x0030'/>
</source>
</hostdev>
[NOTE] - the “managed=‘yes’” makes it behave as if “nodedev-detach” and “nodedev-reattach” had been called at correct times, so you shouldn’t need to do anything else.
Then you can attach USB devices using virsh
virsh attach-device hassos --file /var/lib/libvirt/images/hassos-vm/conbeeii.xml --persistent
[Note] use “virsh detach-device [DOMAIN] [FILE]” to detach, where it will reattach again upon next boot. Add “–persistent” to this, to make the detach persistent.