[fedora-virt] Hostdev XML Not Working (Libvirt)

Cole Robinson crobinso at redhat.com
Wed May 27 14:23:02 UTC 2009

Robert L Cochran wrote:
> Why doesn't the hostdev xml shown below for a USB device work? I've 
> shown the entire <devices> block for context.
> <devices>
> <emulator>/usr/bin/qemu-kvm</emulator>
> <disk type='file' device='cdrom'>
> <target dev='hdc' bus='ide'/>
> <readonly/>
> </disk>
> <disk type='file' device='disk'>
> <source file='/var/lib/libvirt/images/Ubuntu9.img'/>
> <target dev='vda' bus='virtio'/>
> </disk>
> <interface type='network'>
> <mac address='54:52:00:74:32:2f'/>
> <source network='default'/>
> <model type='virtio'/>
> </interface>
> <serial type='pty'>
> <target port='0'/>
> </serial>
> <console type='pty'>
> <target port='0'/>
> </console>
> <hostdev mode='subsystem' type='usb'>
> <source>
> <vendor id='0403'/>
> <product id='6001'/>
> </source>
> </hostdev>
> <input type='mouse' bus='ps2'/>
> <graphics type='vnc' port='-1' autoport='yes'/>
> <sound model='es1370'/>
> </devices>
> The USB device of interest to me is an FTDI FT232RL chip. When I plug 
> the board into a USB port on the host, I want it to be passed through to 
> my Ubuntu guest so that it can be seen as /dev/ttyUSB0. The guest 
> doesn't see it. I took the product and vendor id numbers from the 
> /var/log/messages output, and these might be in hexadecimal (and I 
> should be writing e.g. <vendorid=0x0403'/>. I might also be getting the 
> physical handling of the device wrong: maybe it needs to be already 
> plugged in at the time the Ubuntu guest is started up, or maybe I should 
> start the guest first and then plug in the device?
> Advice appreciated.
> Bob Cochran

For future reference, easiest way to get device product + vendor info is
to use 'lsusb'.

I think you need to use the hex format you mention above to get this to
work correctly (<vendor id='0x0403'/> ...). Also, make sure that the
<hostdev> device is still listed in the domain xml when you use 'virsh
dumpxml <domname>': this will guarantee that libvirt is at least
recognizing the new xml.

You can also check /var/log/libvirt/qemu/<domname>.log to see what QEMU
command line libvirt is generating, which helps debugging these issues.

- Cole

More information about the Fedora-virt mailing list