Bug 982070

Summary: have no rejected warning when do usb-redir sanity testing - filter
Product: Red Hat Enterprise Linux 7 Reporter: Sibiao Luo <sluo>
Component: qemu-kvmAssignee: Hans de Goede <hdegoede>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: acathrow, chayang, hhuang, juzhang, kraxel, michen, qzhang, qzhou, rhod, shu, virt-maint, xfu
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: 2013-08-12 10:10:52 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Sibiao Luo 2013-07-08 05:01:19 UTC
Description of problem:
Boot guest with  usb-redir device, adding the filter option:...-device usb-redir,chardev=usbredirchardev1,id=usbredirdev1,bus=xhci.0,debug=2,filter='-1:0x0951:0x1642:-1:0|-1:-1:-1:-1:1', the usb device with vendor id 0x0951 and product id 0x1642 can't be redirected to guest, and the QEMU should give a prompt, like: 'qemu-kvm: usb-redir warning: Device 0951:1642 rejected by device filter, not attaching'.
Tried the EHCI controller, it have no such issue and it can give such prompt.

Version-Release number of selected component (if applicable):
host info:
3.10.0-0.rc7.64.el7.x86_64
qemu-kvm-1.5.1-2.el7.x86_64
guest info:
3.10.0-0.rc7.64.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.Boot guest with usb-redir device var xhci controller, adding the filter option.
e.g:/usr/libexec/qemu-kvm -S -M q35 -cpu SandyBridge... -device nec-usb-xhci,id=xhci,bus=bridge1,addr=0x8 -chardev spicevmc,name=usbredir,id=usbredirchardev1 -device usb-redir,chardev=usbredirchardev1,id=usbredirdev1,bus=xhci.0,debug=2,filter='-1:0x0951:0x1642:-1:0|-1:-1:-1:-1:1'
2.insert the usb2.0 stick to host var physically XHCI controller.
3.connect guest var remote-viewer, check info qtree and the device in guest.
# remote-viewer spice://$host_ip:$port
(qemu) info qtree
(qemu) info usb
(qemu) info usbhost
# fdisk -l

Actual results:
after step 3, the usb2.0 stick did not passthrough to guest successfully.
(qemu) info usb
  Device 0.0, Port 1, Speed 1.5 Mb/s, Product USB Redirection Device
(qemu) info usbhost
  Bus 3, Addr 12, Port 2, Speed 480 Mb/s
    Class 00: USB device 0951:1642, DT 101 G2
  Bus 1, Addr 4, Port 1.3.1, Speed 1.5 Mb/s
    Class 00: USB device 0557:2213, CS-1734A V4.2.414
(qemu) info qtree
bus: main-system-bus
  type System
  dev: kvm-ioapic, id ""
    gpio-in 24
    gsi_base = 0
    irq 0
    mmio 00000000fec00000/0000000000001000
  dev: q35-pcihost, id ""
    MCFG = 2952790016
    irq 0
    bus: pcie.0
      type PCIE
      dev: pci-bridge, id "bridge1"
        chassis_nr = 1
        msi = on
        addr = 03.0
        romfile = <null>
        rombar = 1
        multifunction = off
        command_serr_enable = on
        class PCI bridge, addr 00:03.0, pci id 1b36:0001 (sub 0000:0000)
        bar 0: mem at 0xfeb11000 [0xfeb110ff]
        bus: bridge1
          type PCI
          dev: nec-usb-xhci, id "xhci"
            msi = on
            msix = on
            intrs = 16
            slots = 64
            p2 = 4
            p3 = 4
            addr = 08.0
            romfile = <null>
            rombar = 1
            multifunction = off
            command_serr_enable = on
            class USB controller, addr 01:08.0, pci id 1033:0194 (sub 1af4:1100)
            bar 0: mem at 0xfea40000 [0xfea43fff]
            bus: xhci.0
              type usb-bus
              dev: usb-redir, id "usbredirdev1"
                chardev = usbredirchardev1
                debug = 2
                filter = "-1:0x0951:0x1642:-1:0|-1:-1:-1:-1:1"
                bootindex = -1
                port = <null>
                full-path = on
                addr 0.0, port 1, speed 1.5, name USB Redirection Device
...

Expected results:
QEMU should give a prompt, like: 'qemu-kvm: usb-redir warning: Device 0951:1642 rejected by device filter, not attaching', such as:

(qemu) qemu-kvm: usb-redir warning: Device 0951:1642 rejected by device filter, not attaching

(qemu) info usb
  Device 0.0, Port 1, Speed 1.5 Mb/s, Product USB Redirection Device
(qemu) info usbhost
  Bus 3, Addr 12, Port 2, Speed 480 Mb/s
    Class 00: USB device 0951:1642, DT 101 G2
  Bus 1, Addr 4, Port 1.3.1, Speed 1.5 Mb/s
    Class 00: USB device 0557:2213, CS-1734A V4.2.414

Additional info:
# /usr/libexec/qemu-kvm -S -M q35 -cpu SandyBridge -enable-kvm -m 4096 -smp 4,sockets=2,cores=2,threads=1 -no-kvm-pit-reinjection -name sluo -uuid 355a2475-4e03-4cdd-bf7b-5d6a59edaa61 -rtc base=localtime,clock=host,driftfix=slew -device pci-bridge,bus=pcie.0,id=bridge1,chassis_nr=1,addr=0x3 -device virtio-serial-pci,id=virtio-serial0,max_ports=16,vectors=0,bus=bridge1,addr=0x4 -chardev socket,id=channel1,path=/tmp/helloworld1,server,nowait -device virtserialport,chardev=channel1,name=com.redhat.rhevm.vdsm,bus=virtio-serial0.0,id=port1 -chardev socket,id=channel2,path=/tmp/helloworld2,server,nowait -device virtserialport,chardev=channel2,name=com.redhat.rhevm.vdsm,bus=virtio-serial0.0,id=port2 -drive file=/home/RHEL-7.0-20130628.0-Server-x86_64.qcow3,if=none,id=drive-system-disk,format=qcow2,cache=none,aio=native,werror=stop,rerror=stop,serial="QEMU-DISK1" -device virtio-scsi-pci,num_queues=4,id=scsi0,bus=bridge1,addr=0x5 -device scsi-hd,bus=scsi0.0,drive=drive-system-disk,id=system-disk,bootindex=1 -device virtio-balloon-pci,id=ballooning,bus=bridge1,addr=0x6 -global PIIX4_PM.disable_s3=0 -global PIIX4_PM.disable_s4=0 -netdev tap,id=hostnet0,vhost=on,queues=4,script=/etc/qemu-ifup -device virtio-net-pci,mq=on,vectors=17,netdev=hostnet0,id=virtio-net-pci0,mac=08:2e:5f:0a:0d:b1,bus=bridge1,addr=0x7,bootindex=2 -k en-us -boot menu=on -qmp tcp:0:4444,server,nowait -serial unix:/tmp/ttyS0,server,nowait -vnc :1 -spice port=5931,disable-ticketing -monitor stdio -device nec-usb-xhci,id=xhci,bus=bridge1,addr=0x8 -chardev spicevmc,name=usbredir,id=usbredirchardev1 -device usb-redir,chardev=usbredirchardev1,id=usbredirdev1,bus=xhci.0,debug=2,filter='-1:0x0951:0x1642:-1:0|-1:-1:-1:-1:1'

Comment 1 Hans de Goede 2013-08-12 10:10:52 UTC
Hi Sibiao,

When you tried with the ehci controller, did you use the same qemu version on the host as when trying with the xhci controller?

qemu in RHEL-7 will forward the filter you passed to remote-viewer, and remote-viewer then will not even
attempt to redirect the device, this is why you're not seeing the filter rejection message.

To verify this is happening, in remote-viewer go to file -> USB device selection. The USB stick should be there, but it will be greyed out.

Conclusion: qemu will not show the rejection message, because the device was never redirected at all,
since remote-viewer will not (auto)-redirect the device, as it knows about the filter.

Regards,

Hans

Comment 2 Sibiao Luo 2013-12-26 06:03:44 UTC
(In reply to Hans de Goede from comment #1)
> Hi Sibiao,
> 
> When you tried with the ehci controller, did you use the same qemu version
> on the host as when trying with the xhci controller?
> 
> qemu in RHEL-7 will forward the filter you passed to remote-viewer, and
> remote-viewer then will not even
> attempt to redirect the device, this is why you're not seeing the filter
> rejection message.
> 
> To verify this is happening, in remote-viewer go to file -> USB device
> selection. The USB stick should be there, but it will be greyed out.
> 
> Conclusion: qemu will not show the rejection message, because the device was
> never redirected at all,
> since remote-viewer will not (auto)-redirect the device, as it knows about
> the filter.
> 
Yes, we should select the USB device in remote-viewer. thanks for your kindly reminds. 
(qemu) c
usbredirparser: Peer version: spice-gtk 0.20, using 64-bits ids
(qemu) qemu-kvm: usb-redir: attaching super speed device 1516:6221 version 1.0 class 00

qemu-kvm: usb-redir warning: Device 1516:6221 rejected by device filter, not attaching

And the remote-viewer also will give a prompt "USB redirection error: CompUSA Device [1516:6221] at 4-2 rejected by host".

Best Regards,
sluo