I would like to have following line translated from qemu optiones into libvirt xml.
-qemu-system-x86_64
-...
-usb -device usb-host,bus=usb-bus.0,hostbus=<bus>,hostport=<port>
This adds a physical usb plug to a virtual machine. Most examples are shown and well documented for usb-bus/deviceID, not for this solution.
Edit:
The tool virsh domxml-from-native qemu-argv MyArgV.sh
has the following solution:
<qemu:commandline>
<qemu:arg value='-device'/>
<qemu:arg value='usb-host,bus=usb-bus.0,hostbus=1,hostport=10'/>
</qemu:commandline>
But this is not really what I wanted, because it is bypassing the libvirt system. So if the native tool can't find any solution, is there a general libvirt solution for passing USB-Ports?
I've also tried the virt-manager GUI for adding a USB-Port, but I was not able to find any possebilety to do so.
Is there maybe a possebilety to make a snapshot of a running qemu machine and replicate it with libvirt on the fly?
I found this webpage. But this one is describing how to assemble the usb-port hierarchy in the VM, not forwarding a host port to vm.
Unfortunately it isn't documented, but you can assign a USB device based on bus + device number with this syntax:
<hostdev mode='subsystem' type='usb' managed='no'>
<source>
<address bus='1' device='NNN'/>
</source>
</hostdev>
unfortunately the device number here is the /dev/usb/bus/NNN number which changes every time you plug it in. There's not yet any support for picking the device based on hostport which is stable.