<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=us-ascii" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
On 05/27/2009 10:23 AM, Cole Robinson wrote:
<blockquote cite="mid:4A1D4CC6.1010102@redhat.com" type="cite">
<pre wrap="">Robert L Cochran wrote:
</pre>
<blockquote type="cite">
<pre wrap="">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
</pre>
</blockquote>
<pre wrap=""><!---->
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
</pre>
</blockquote>
Cole,<br>
<br>
Thanks for your response. I modified the file
/etc/libvirt/qemu/Ubuntu9.xml so that it looks like this:<br>
<br>
<domain type='kvm'><br>
<name>Ubuntu9</name><br>
<uuid>cb8c3d15-fe92-1bf2-5676-03370743e815</uuid><br>
<memory>1572864</memory><br>
<currentMemory>1572864</currentMemory><br>
<vcpu>1</vcpu><br>
<os><br>
<type arch='x86_64' machine='pc'>hvm</type><br>
<boot dev='hd'/><br>
</os><br>
<features><br>
<acpi/><br>
<apic/><br>
<pae/><br>
</features><br>
<clock offset='utc'/><br>
<on_poweroff>destroy</on_poweroff><br>
<on_reboot>restart</on_reboot><br>
<on_crash>restart</on_crash><br>
<devices><br>
<emulator>/usr/bin/qemu-kvm</emulator><br>
<disk type='file' device='cdrom'><br>
<target dev='hdc' bus='ide'/><br>
<readonly/><br>
</disk><br>
<disk type='file' device='disk'><br>
<source file='/var/lib/libvirt/images/Ubuntu9.img'/><br>
<target dev='vda' bus='virtio'/><br>
</disk><br>
<interface type='network'><br>
<mac address='54:52:00:74:32:2f'/><br>
<source network='default'/><br>
<model type='virtio'/><br>
</interface><br>
<serial type='pty'><br>
<target port='0'/><br>
</serial><br>
<console type='pty'><br>
<target port='0'/><br>
</console><br>
<hostdev mode='subsystem' type='usb'><br>
<source><br>
<vendor id='0x0403'/><br>
<product id='0x6001'/><br>
</source><br>
</hostdev><br>
<input type='mouse' bus='ps2'/><br>
<graphics type='vnc' port='-1' autoport='yes'/><br>
<sound model='es1370'/><br>
</devices><br>
</domain><br>
<br>
<br>
<br>
My interest is getting the Ubuntu machine to recognize the FTDI device
indicated in the <hostdev> entry you see above. I did not start
the virtual machine or actually plug the USB device of interest into an
available port at this point. Instead I ran 'virsh' as you suggested
above. Here is the output:<br>
<br>
[root@deafeng3 qemu]# virsh dumpxml Ubuntu9<br>
<domain type='kvm'><br>
<name>Ubuntu9</name><br>
<uuid>cb8c3d15-fe92-1bf2-5676-03370743e815</uuid><br>
<memory>1572864</memory><br>
<currentMemory>1572864</currentMemory><br>
<vcpu>1</vcpu><br>
<os><br>
<type arch='x86_64' machine='pc'>hvm</type><br>
<boot dev='hd'/><br>
</os><br>
<features><br>
<acpi/><br>
<apic/><br>
<pae/><br>
</features><br>
<clock offset='utc'/><br>
<on_poweroff>destroy</on_poweroff><br>
<on_reboot>restart</on_reboot><br>
<on_crash>restart</on_crash><br>
<devices><br>
<emulator>/usr/bin/qemu-kvm</emulator><br>
<disk type='file' device='cdrom'><br>
<target dev='hdc' bus='ide'/><br>
<readonly/><br>
</disk><br>
<disk type='file' device='disk'><br>
<source file='/var/lib/libvirt/images/Ubuntu9.img'/><br>
<target dev='vda' bus='virtio'/><br>
</disk><br>
<interface type='network'><br>
<mac address='54:52:00:74:32:2f'/><br>
<source network='default'/><br>
<model type='virtio'/><br>
</interface><br>
<serial type='pty'><br>
<target port='0'/><br>
</serial><br>
<console type='pty'><br>
<target port='0'/><br>
</console><br>
<input type='mouse' bus='ps2'/><br>
<graphics type='vnc' port='-1' autoport='yes'/><br>
<sound model='es1370'/><br>
<hostdev mode='subsystem' type='usb' managed='no'><br>
<source><br>
<vendor id='0x0103'/><br>
<product id='0x1771'/><br>
</source><br>
</hostdev><br>
</devices><br>
</domain><br>
<br>
At this point, I plugged in the USB device I am interested in and again
ran 'virsh', repeating the command above. Here is the output:<br>
<br>
[root@deafeng3 qemu]# virsh dumpxml Ubuntu9<br>
<domain type='kvm'><br>
<name>Ubuntu9</name><br>
<uuid>cb8c3d15-fe92-1bf2-5676-03370743e815</uuid><br>
<memory>1572864</memory><br>
<currentMemory>1572864</currentMemory><br>
<vcpu>1</vcpu><br>
<os><br>
<type arch='x86_64' machine='pc'>hvm</type><br>
<boot dev='hd'/><br>
</os><br>
<features><br>
<acpi/><br>
<apic/><br>
<pae/><br>
</features><br>
<clock offset='utc'/><br>
<on_poweroff>destroy</on_poweroff><br>
<on_reboot>restart</on_reboot><br>
<on_crash>restart</on_crash><br>
<devices><br>
<emulator>/usr/bin/qemu-kvm</emulator><br>
<disk type='file' device='cdrom'><br>
<target dev='hdc' bus='ide'/><br>
<readonly/><br>
</disk><br>
<disk type='file' device='disk'><br>
<source file='/var/lib/libvirt/images/Ubuntu9.img'/><br>
<target dev='vda' bus='virtio'/><br>
</disk><br>
<interface type='network'><br>
<mac address='54:52:00:74:32:2f'/><br>
<source network='default'/><br>
<model type='virtio'/><br>
</interface><br>
<serial type='pty'><br>
<target port='0'/><br>
</serial><br>
<console type='pty'><br>
<target port='0'/><br>
</console><br>
<input type='mouse' bus='ps2'/><br>
<graphics type='vnc' port='-1' autoport='yes'/><br>
<sound model='es1370'/><br>
<hostdev mode='subsystem' type='usb' managed='no'><br>
<source><br>
<vendor id='0x0103'/><br>
<product id='0x1771'/><br>
</source><br>
</hostdev><br>
</devices><br>
</domain><br>
<br>
I'm not sure what device 0103:1771 is. Here is the output of lsusb.
Notice the device on bus 007 device 003. This is what I want the Ubuntu
machine to see and manage.<br>
<br>
[root@deafeng3 qemu]# lsusb<br>
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub<br>
Bus 007 Device 002: ID 0403:6001 Future Technology Devices
International, Ltd FT232 USB-Serial (UART) IC<br>
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub<br>
Bus 001 Device 006: ID 0c45:63f8 Microdia <br>
Bus 001 Device 011: ID 045e:0084 Microsoft Corp. Basic Optical Mouse<br>
Bus 001 Device 010: ID 046d:c315 Logitech, Inc. Classic New Touch
Keyboard<br>
Bus 001 Device 009: ID 051d:0002 American Power Conversion
Uninterruptible Power Supply<br>
Bus 001 Device 012: ID 413c:8153 Dell Computer Corp. <br>
Bus 001 Device 013: ID 413c:8154 Dell Computer Corp. <br>
Bus 001 Device 003: ID 413c:2513 Dell Computer Corp. <br>
Bus 001 Device 008: ID 0a5c:4500 Broadcom Corp. <br>
Bus 001 Device 007: ID 413c:8149 Dell Computer Corp. <br>
Bus 001 Device 004: ID 413c:2513 Dell Computer Corp. <br>
Bus 001 Device 002: ID 0424:2512 Standard Microsystems Corp. <br>
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub<br>
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub<br>
Bus 005 Device 002: ID 0a5c:5800 Broadcom Corp. <br>
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub<br>
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub<br>
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub<br>
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub<br>
<br>
Lastly, you wondered what command line qemu is using. I checked
/var/log/libvirt/qemu and at the very start of the file I see this:<br>
<br>
<br>
LC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin /usr/bin/qemu-kvm -S -M pc
-m 1536 -smp 1 -name Ubuntu9 -uuid cb8c3d15-fe92-1bf2-5676-03370743e815
-monitor pty -pidfile /var/run/libvirt/qemu//Ubuntu9.pid -no-reboot
-boot d -drive
file=/home/rlc/Download/ubuntu-9.04-desktop-i386.iso,if=ide,media=cdrom,index=2
-drive file=/var/lib/libvirt/images/Ubuntu9.img,if=virtio,index=0 -net
nic,macaddr=54:52:00:74:32:2f,vlan=0,model=virtio -net
tap,fd=18,script=,vlan=0,ifname=vnet0 -serial pty -parallel none -usb
-vnc 127.0.0.1:0 <br>
char device redirected to /dev/pts/1<br>
char device redirected to /dev/pts/2<br>
info cpus<br>
* CPU #0: pc=0x00000000000ffff0 thread_id=3476
<br>
cont<br>
balloon 1536<br>
info balloon<br>
balloon: actual=1536
<br>
info balloon<br>
balloon: actual=1536
<br>
info balloon<br>
balloon: actual=1536
<br>
info balloon<br>
balloon: actual=1536
<br>
info balloon<br>
balloon: actual=1536<br>
[above two lines repeat for a few thousand lines]<br>
<br>
Advice appreciated. How can I get the USB device to work? By the way, I
thought I have an installed virtual machine on my hard drive, so I'm a
little puzzled that the reference <br>
<br>
-drive file=/home/rlc/Download/ubuntu-9.04-desktop-i386.iso<br>
<br>
still exists in the qemu-kvm command line. Am I still starting up from
the iso image? I'm confused.<br>
<br>
Bob<br>
<br>
</body>
</html>