[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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




On 05/27/2009 10:23 AM, Cole Robinson wrote:
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


  
Cole,

Thanks for your response. I modified the file /etc/libvirt/qemu/Ubuntu9.xml so that it looks like this:

<domain type='kvm'>
  <name>Ubuntu9</name>
  <uuid>cb8c3d15-fe92-1bf2-5676-03370743e815</uuid>
  <memory>1572864</memory>
  <currentMemory>1572864</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type arch='x86_64' machine='pc'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <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='0x0403'/>
      <product id='0x6001'/>
       </source>
    </hostdev>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport='yes'/>
    <sound model='es1370'/>
  </devices>
</domain>



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:

[root deafeng3 qemu]# virsh dumpxml Ubuntu9
<domain type='kvm'>
  <name>Ubuntu9</name>
  <uuid>cb8c3d15-fe92-1bf2-5676-03370743e815</uuid>
  <memory>1572864</memory>
  <currentMemory>1572864</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type arch='x86_64' machine='pc'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <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>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport='yes'/>
    <sound model='es1370'/>
    <hostdev mode='subsystem' type='usb' managed='no'>
      <source>
        <vendor id='0x0103'/>
        <product id='0x1771'/>
      </source>
    </hostdev>
  </devices>
</domain>

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:

[root deafeng3 qemu]# virsh dumpxml Ubuntu9
<domain type='kvm'>
  <name>Ubuntu9</name>
  <uuid>cb8c3d15-fe92-1bf2-5676-03370743e815</uuid>
  <memory>1572864</memory>
  <currentMemory>1572864</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type arch='x86_64' machine='pc'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <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>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport='yes'/>
    <sound model='es1370'/>
    <hostdev mode='subsystem' type='usb' managed='no'>
      <source>
        <vendor id='0x0103'/>
        <product id='0x1771'/>
      </source>
    </hostdev>
  </devices>
</domain>

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.

[root deafeng3 qemu]# lsusb
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 002: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 006: ID 0c45:63f8 Microdia
Bus 001 Device 011: ID 045e:0084 Microsoft Corp. Basic Optical Mouse
Bus 001 Device 010: ID 046d:c315 Logitech, Inc. Classic New Touch Keyboard
Bus 001 Device 009: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
Bus 001 Device 012: ID 413c:8153 Dell Computer Corp.
Bus 001 Device 013: ID 413c:8154 Dell Computer Corp.
Bus 001 Device 003: ID 413c:2513 Dell Computer Corp.
Bus 001 Device 008: ID 0a5c:4500 Broadcom Corp.
Bus 001 Device 007: ID 413c:8149 Dell Computer Corp.
Bus 001 Device 004: ID 413c:2513 Dell Computer Corp.
Bus 001 Device 002: ID 0424:2512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 002: ID 0a5c:5800 Broadcom Corp.
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

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:


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
char device redirected to /dev/pts/1
char device redirected to /dev/pts/2
info cpus
* CPU #0: pc=0x00000000000ffff0 thread_id=3476
cont
balloon 1536
info balloon
balloon: actual=1536
info balloon
balloon: actual=1536
info balloon
balloon: actual=1536
info balloon
balloon: actual=1536
info balloon
balloon: actual=1536
[above two lines repeat for a few thousand lines]

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

-drive file=/home/rlc/Download/ubuntu-9.04-desktop-i386.iso

still exists in the qemu-kvm command line. Am I still starting up from the iso image? I'm confused.

Bob


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]