[libvirt-users] USB passthrough of all USB-slots to guest

Alex Jia ajia at redhat.com
Fri May 18 02:55:06 UTC 2012

On 05/18/2012 06:04 AM, eGerlach wrote:
> Hi,
> how can I define passthrough of all USB-slots to a guest with libvirt?
> With qemu it's very easy:
> # kvm -usb -usbdevice host:0.* -usbdevice host:1.*  -usbdevice host:2.* -usbdevice host:3.*  ...
> This configuration of the VM gets *all* 4 USB-Slots. Every time somewhat USB-device
> is plugged in the VM gets it.
> virt-install manpage offers:
> --host-device 001.003
>      USB by bus, device (via lsusb).
> I installed a VM with option --host-device 001.001 according to output of lsusb.
> The XML-file generated:
>      <hostdev mode='subsystem' type='usb' managed='yes'>
>        <source>
>          <vendor id='0x1d6b'/>
>          <product id='0x0002'/>
>        </source>
>      </hostdev>
You also may use bus + device to define the above XML, and just need to 
replace <vendor..../>
and <product.../> lines with <address bus='XX' device='XX'/> line.
> But no USB device is passed through automatically. I always need
>    virsh attach-device virtualM myusb.xml
If you only wirte a myusb.xml rather than running above operation, you 
can't expect a usb device is assigned to guest, the above method belongs 
to hot-plugging, the guest must be running status. if
your guest is inactive, you can use 'virsh edit' to append the above 
<hostdev...>...</hostdev> into
guest XML configuration then 'virsh start' the guest, the usb device 
will be assigned to the guest, it
belongs to cold-plugging.
> with exact vendor and product ID. I want to plug in somewhat USB-Stick or other USB stuff
> without exploring vendor and product id before.
I haven't exactly know your mean, as usual, you need to use 'lsusb' or 
'virsh nodedev-list --tree' and 'virsh nodedev-dumpxml XXX' to get usb's 
bus+device or vendor+product information.
> Who can help?
> tia
> Ekkard
> _______________________________________________
> libvirt-users mailing list
> libvirt-users at redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-users

More information about the libvirt-users mailing list