Bug 723760

Summary: usb-host occupys two ports
Product: Red Hat Enterprise Linux 6 Reporter: juzhang <juzhang>
Component: qemu-kvmAssignee: Gerd Hoffmann <kraxel>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2CC: michen, mkenneth, qzhou, shuang, tburke, virt-maint
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-08-12 08:42:59 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description juzhang 2011-07-21 03:38:59 UTC
Description of problem:


Version-Release number of selected component (if applicable):
qemu-kvm-0.12.1.2-2.171.el6.x86_64


How reproducible:
100%

Steps to Reproduce:
1.Boot guest with -device usb-host option and specify hostport=003
 /usr/libexec/qemu-kvm   -enable-kvm -m 1024 -smp 2,sockets=2,cores=1,threads=1 -name rhel6.1-64 -rtc base=utc -boot c -drive file=/tmp/RHEL-Server-6.1-64.raw,if=none,id=drive-virtio-disk0,format=raw,cache=none,aio=threads,boot=on -device virtio-blk-pci,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,id=virtio-disk0 -netdev tap,id=hostnet0,vhost=on -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:2f:e8:d2,bus=pci.0,addr=0x3  -device usb-tablet,id=input0 -vnc :11 -vga cirrus -device intel-hda,id=sound0,bus=pci.0,addr=0x4 -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6 -monitor stdio 
/
-usb  -device usb-ehci,id=ehci -device usb-host,bus=ehci.0,hostbus=002,hostaddr=004,hostport=003,vendorid=04e8,productid=5120
/
2.check usb-host status,please note  Bus 2, Addr 4
#info usbhost 
  Bus 1, Addr 2, Port 1, Speed 480 Mb/s
    Hub: USB device 8087:0024
  Bus 2, Addr 2, Port 1, Speed 480 Mb/s
    Hub: USB device 8087:0024
  Bus 1, Addr 3, Port 1.3, Speed 1.5 Mb/s
    Class 00: USB device 413c:2105, Dell USB Keyboard
  Bus 1, Addr 4, Port 1.4, Speed 1.5 Mb/s
    Class 00: USB device 046d:c018, USB Optical Mouse
/this device occupys two ports,port 1.7 and port 3.
  Bus 2, Addr 4, Port 1.7, Speed 480 Mb/s
    Class 00: USB device 04e8:5120, U5
  Auto filters:
    Bus 2, Addr 4, Port 003, ID 04e8:5120
/
Actual results:
in guest
#lsusb, can't find USB device 04e8:5120.this device is Samsung Electronics.
Bus 002 Device 002: ID 0627:0001 Adomax Technology Co., Ltd 
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

in guest. however,can find this device via fdisk -l
#fdisk -l
Disk /dev/sda: 1906 MB, 1906311168 bytes
202 heads, 48 sectors/track, 96 cylinders
Units = cylinders of 9696 * 2048 = 19857408 bytes
Sector size (logical/physical): 2048 bytes / 2048 bytes
I/O size (minimum/optimal): 2048 bytes / 2048 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          96     1861536    b  W95 FAT32
Partition 1 has different physical/logical beginnings (non-Linux?):
     phys=(0, 0, 48) logical=(0, 1, 1)


Expected results:
Can find usb device via lsusb and usb-host just occupy one port.

Additional info:
If I don't specify hostport.
boot guest with 
-usb  -device usb-ehci,id=ehci -device usb-host,bus=ehci.0,hostbus=002,hostaddr=004,vendorid=04e8,productid=5120 

(qemu) info usbhost
  Bus 1, Addr 2, Port 1, Speed 480 Mb/s
    Hub: USB device 8087:0024
  Bus 2, Addr 2, Port 1, Speed 480 Mb/s
    Hub: USB device 8087:0024
  Bus 1, Addr 3, Port 1.3, Speed 1.5 Mb/s
    Class 00: USB device 413c:2105, Dell USB Keyboard
  Bus 1, Addr 4, Port 1.4, Speed 1.5 Mb/s
    Class 00: USB device 046d:c018, USB Optical Mouse
  Bus 2, Addr 4, Port 1.7, Speed 480 Mb/s
    Class 00: USB device 04e8:5120, U5
  Auto filters:
    Bus 2, Addr 4, Port *, ID 04e8:5120

In guest, find Bus 001 Device 002: ID 04e8:5120 Samsung Electronics Co., Ltd  device.
#lsusb 
Bus 002 Device 002: ID 0627:0001 Adomax Technology Co., Ltd 
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 04e8:5120 Samsung Electronics Co., Ltd 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub


#can find this device via fdisk -l
#fdisk -l
Disk /dev/sda: 1906 MB, 1906311168 bytes
202 heads, 48 sectors/track, 96 cylinders
Units = cylinders of 9696 * 2048 = 19857408 bytes
Sector size (logical/physical): 2048 bytes / 2048 bytes
I/O size (minimum/optimal): 2048 bytes / 2048 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          96     1861536    b  W95 FAT32
Partition 1 has different physical/logical beginnings (non-Linux?):
     phys=(0, 0, 48) logical=(0, 1, 1)

Comment 1 Gerd Hoffmann 2011-08-12 08:42:59 UTC
#info usbhost
   [ ... ]
   Bus 2, Addr 4, Port 1.7, Speed 480 Mb/s
    Class 00: USB device 04e8:5120, U5

This is one host device list entry.

  Auto filters:
    Bus 2, Addr 4, Port 003, ID 04e8:5120

This is *not* a device list entry.  This lists what devices qemu is looking for to assign them to the guest.  You'll find there the conditions specified via -device host,...

You asked qemu to look out for for port=003, whereas the port of the device you want assign is 1.7.  Qemu doesn't assign the device because of the mismatch, thats why lspci inside the guest doesn't list the device.

You can mix the filter conditions as you like, but not all combinations are that useful.  I recomment to pick one of these two:

(1) Match by device ID, that will pass through the samsung device (phone?)
    no matter where you plug it in.
    -device usb-host,bus=ehci.0,vendorid=04e8,productid=5120

(2) Match by phyiscal port.  That will pass through any device plugged into
    the port specified.
    -device usb-host,bus=ehci.0,hostbus=2,hostport=1.7