Bug 842358

Summary: remote-viewer: USB redirection: Flash drive disconnects after a while
Product: Red Hat Enterprise Linux 7 Reporter: Milan Barta <mbarta>
Component: usbredirAssignee: Hans de Goede <hdegoede>
Status: CLOSED DUPLICATE QA Contact:
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.0CC: herrold, pvine, tpelka
Target Milestone: rc   
Target Release: 7.0   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-12-14 10:56:17 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:
Attachments:
Description Flags
qemu log with usbredir debug enabled none

Description Milan Barta 2012-07-23 14:46:28 UTC
Description of problem:
When a USB flash drive is connected to a Fedora/RHEL7 (x86_64) guest (using remote-viewer on RHEL 6.3 client and host) after a while the drive gets disconnected.
With Windows 7 guest the usb redirection works as expected.

remote-viewer error message:
(remote-viewer:14892): GSpice-CRITICAL **: usbredirhost error: resetting device: -5
libusb:error [__open_sysfs_attr] open /sys/bus/usb/devices/1-1.2/descriptors failed ret=-1 errno=2

dmesg of the guest system:
...
[ 1205.633463] usb 1-6: new high-speed USB device number 6 using ehci_hcd
[ 1205.871426] usb 1-6: New USB device found, idVendor=0951, idProduct=162d
[ 1205.871434] usb 1-6: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1205.871440] usb 1-6: Product: DataTraveler 102
[ 1205.871444] usb 1-6: Manufacturer: Kingston
[ 1205.871447] usb 1-6: SerialNumber: 0013728A7896BB318519007A
[ 1206.067049] scsi5 : usb-storage 1-6:1.0
[ 1207.150198] scsi 5:0:0:0: Direct-Access     Kingston DataTraveler 102 PMAP PQ: 0 ANSI: 0 CCS
[ 1207.862410] sd 5:0:0:0: [sda] 30695424 512-byte logical blocks: (15.7 GB/14.6 GiB)
[ 1207.870759] sd 5:0:0:0: [sda] Write Protect is off
[ 1207.870768] sd 5:0:0:0: [sda] Mode Sense: 03 41 00 00
[ 1207.879930] sd 5:0:0:0: [sda] No Caching mode page present
[ 1207.879937] sd 5:0:0:0: [sda] Assuming drive cache: write through
[ 1207.937741] sd 5:0:0:0: [sda] No Caching mode page present
[ 1207.937751] sd 5:0:0:0: [sda] Assuming drive cache: write through
[ 1207.980080]  sda: sda1
[ 1208.031289] sd 5:0:0:0: [sda] No Caching mode page present
[ 1208.031298] sd 5:0:0:0: [sda] Assuming drive cache: write through
[ 1208.031318] sd 5:0:0:0: [sda] Attached SCSI removable disk
[ 1209.588308] SELinux: initialized (dev sda1, type vfat), uses genfs_contexts
[ 1251.285391] usb 1-6: reset high-speed USB device number 6 using ehci_hcd
[ 1251.732480] usb 1-6: reset high-speed USB device number 6 using ehci_hcd

... (repeated several times)

[ 1256.546442] sd 5:0:0:0: [sda] Unhandled error code
[ 1256.546447] sd 5:0:0:0: [sda]  Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK
[ 1256.546459] sd 5:0:0:0: [sda] CDB: Write(10): 2a 00 00 00 08 01 00 00 01 00
[ 1256.546468] end_request: I/O error, dev sda, sector 2049
[ 1256.546475] Buffer I/O error on device sda1, logical block 1
[ 1256.546477] lost page write due to I/O error on sda1
[ 1256.660592] usb 1-6: reset high-speed USB device number 6 using ehci_hcd

...

[ 1272.338414] usb 1-6: reset high-speed USB device number 6 using ehci_hcd
[ 1272.663375] sda: detected capacity change from 15716057088 to 0
[ 1272.778586] usb 1-6: reset high-speed USB device number 6 using ehci_hcd

...


Version-Release number of selected component (if applicable):
RHEL 6.3 (both client and host)


How reproducible:
Running a Fedora/RHEL guest.

Steps to Reproduce:

Since virt-manager in RHEL 6.3 doesn't support the usb redirection setup, the domain XML config file needs to be edited:

    sudo virsh edit  $GUEST_NAME" on host machine.
    enter above the "</devices>" line following:

  <controller type='usb' index='0' model='ich9-ehci1'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x7'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <master startport='0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0' multifunction='on'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci2'>
      <master startport='2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x1'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci3'>
      <master startport='4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x2'/>
    </controller>
    <redirdev bus='usb' type='spicevmc'>  
      <address type='usb' bus='0' port='3'/>
    </redirdev>
    <redirdev bus='usb' type='spicevmc'>
      <address type='usb' bus='0' port='4'/>
    </redirdev>
    <redirdev bus='usb' type='spicevmc'>
      <address type='usb' bus='0' port='5'/>
    </redirdev>
    <redirdev bus='usb' type='spicevmc'>
      <address type='usb' bus='0' port='6'/>
    </redirdev>

The guest system is run using the virt-manager:
/usr/libexec/qemu-kvm -S -M rhel6.3.0 -cpu Westmere,+rdtscp,+pdcm,+xtpr,+tm2,+est,+smx,+vmx,+ds_cpl,+monitor,+dtes64,+pclmuldq,+pbe,+tm,+ht,+ss,+acpi,+ds,+vme -enable-kvm -m 1024 -smp 2,sockets=2,cores=1,threads=1 -name Fedora -uuid fe2949cc-aff9-71e7-d120-9d4a1810376a -nodefconfig -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/Fedora.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -device ich9-usb-ehci1,id=usb,bus=pci.0,addr=0x9.0x7 -device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x9 -device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x9.0x1 -device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x9.0x2 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x7 -drive file=/dev/root_vg/fedora17,if=none,id=drive-virtio-disk0,format=raw,cache=none,aio=native -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -netdev tap,fd=25,id=hostnet0,vhost=on,vhostfd=28 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:2b:52:b8,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -chardev spicevmc,id=charchannel0,name=vdagent -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=com.redhat.spice.0 -device usb-tablet,id=input0 -spice port=5902,addr=127.0.0.1,disable-ticketing,image-compression=quic,streaming-video=filter -vga qxl -global qxl-vga.vram_size=67108864 -device qxl,id=video1,vram_size=67108864,bus=pci.0,addr=0x8 -device intel-hda,id=sound0,bus=pci.0,addr=0x4 -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 -chardev spicevmc,id=charredir0,name=usbredir -device usb-redir,chardev=charredir0,id=redir0,bus=usb.0,port=3 -chardev spicevmc,id=charredir1,name=usbredir -device usb-redir,chardev=charredir1,id=redir1,bus=usb.0,port=4 -chardev spicevmc,id=charredir2,name=usbredir -device usb-redir,chardev=charredir2,id=redir2,bus=usb.0,port=5 -chardev spicevmc,id=charredir3,name=usbredir -device usb-redir,chardev=charredir3,id=redir3,bus=usb.0,port=6 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6

1. run remote-viewer spice://$HOST?port=$PORT
2. connect a flash drive
3. mount the flash drive in guest system
4. wait ...
  
Actual results:
The flash drive gets mounted. After a while it disconnects.

Expected results:
The flash drive stays mounted until unmounted.

Additional info:

Versions of software installed on client/host:
spice-client.x86_64                 0.8.2-15.el6
spice-glib.x86_64                   0.11-11.el6
spice-gtk.x86_64                    0.11-11.el6
spice-gtk-python.x86_64             0.11-11.el6
spice-server.x86_64                 0.10.1-10.el6
spice-usb-share.x86_64              4.9-9.el6
spice-vdagent.x86_64                0.8.1-3.el6
spice-xpi.x86_64                    2.7-20.el6
kmod-kspiceusb-rhel60.x86_64        4.9-12.el6
usbredir.x86_64                     0.4.3-1.el6
qemu-kvm.x86_64                     2:0.12.1.2-2.295.el6
virt-viewer.x86_64                  0.5.2-9.el6
libvirt.x86_64                      0.9.10-21.el6
libvirt-client.x86_64               0.9.10-21.el6
libvirt-python.x86_64               0.9.10-21.el6

Comment 1 Hans de Goede 2012-07-23 14:56:31 UTC
2 questions:
1) Are you perhaps using the device in a USB-3 port of the client ?  If so can you try using it in a USB-2 port
2) Can you reproduce the problem and attach dmesg from the client machine please?

Comment 3 Milan Barta 2012-07-23 17:26:17 UTC
1) my workstation only has USB2 ports, no USB3.
2) client dmesg:

usb 2-1.2: new high speed USB device number 18 using ehci_hcd
usb 2-1.2: New USB device found, idVendor=13fe, idProduct=3100
usb 2-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 2-1.2: Product: Patriot Memory
usb 2-1.2: Manufacturer:         
usb 2-1.2: SerialNumber: 0797060899352CF1
usb 2-1.2: configuration #1 chosen from 1 choice
scsi33 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 18
usb-storage: waiting for device to settle before scanning
usb-storage: device scan complete
scsi 33:0:0:0: Direct-Access              Patriot Memory   PMAP PQ: 0 ANSI: 0 CCS
sd 33:0:0:0: Attached scsi generic sg2 type 0
sd 33:0:0:0: [sdb] 15654912 512-byte logical blocks: (8.01 GB/7.46 GiB)
sd 33:0:0:0: [sdb] Write Protect is off
sd 33:0:0:0: [sdb] Mode Sense: 23 00 00 00
sd 33:0:0:0: [sdb] Assuming drive cache: write through
sd 33:0:0:0: [sdb] Assuming drive cache: write through
 sdb: sdb1
sd 33:0:0:0: [sdb] Assuming drive cache: write through
sd 33:0:0:0: [sdb] Attached SCSI removable disk
SELinux: initialized (dev sdb1, type vfat), uses genfs_contexts
usb 2-1.2: reset high speed USB device number 18 using ehci_hcd
usb 2-1.2: reset high speed USB device number 18 using ehci_hcd
... (hundrets of lines like this ...)
...
usb 2-1.2: reset high speed USB device number 18 using ehci_hcd
usb 2-1.2: device not accepting address 18, error -71
usb 2-1.2: USB disconnect, device number 18

Comment 4 Paul Vine 2012-07-25 18:55:44 UTC
Moving to 7.0 as 6.3 combinations are fine so it is likely the bug is with 7.0.

Comment 5 Hans de Goede 2012-07-28 15:30:24 UTC
So looking at the dmesg inside both the client and the guest what is happening is:
1) device gets redirected
2) the guest issues a ton of device resets due to some errors while talking to the device
3) after devie reset 1001 and the device goes into some error state and no longer wants to talk to the problem

There is little we can do to fix 3, if you keep hitting the device with resets eventually you may do so at a bad time and the firmware may lockup. So the problem to fix here is 2. To fix 2) I will need some more information, can you please try running the RHEL-7 guest with usbredir debugging enabled?

To do this you (unfortunately) will need to start qemu manually, since libvirt does not support the debug parameter of the usb-redir device (I'll file a bug for this).

Here is an example commandline for running RHEL under qemu-kvm directly from the cmdline:

/usr/bin/qemu-kvm -enable-kvm \
 -m 1024 -name RHEL-7 \
 -drive file=/home/images/rhel7.img,media=disk,index=0 \
 -net nic,macaddr=52:54:00:7a:b4:7e,vlan=0,model=virtio,name=virtio.0 -net user,vlan0 \
 -vga qxl -spice port=5955,disable-ticketing \
 -device virtio-serial -chardev spicevmc,id=vdagent,debug=1,name=vdagent -device virtserialport,chardev=vdagent,name=com.redhat.spice.0 \
 -readconfig /home/hans/projects/qemu/docs/ich9-ehci-uhci.cfg \
 -chardev spicevmc,name=usbredir,id=usbredirchardev1 \
 -device usb-redir,chardev=usbredirchardev1,id=usbredirdev1,debug=4 \
 -chardev spicevmc,name=usbredir,id=usbredirchardev2 \
 -device usb-redir,chardev=usbredirchardev2,id=usbredirdev2,debug=4 \
 -chardev spicevmc,name=usbredir,id=usbredirchardev3 \
 -device usb-redir,chardev=usbredirchardev3,id=usbredirdev3,debug=4 \
 -monitor stdio -device intel-hda -device hda-duplex 2> qemu.log

Notice you will need to drop ich9-ehci-uhi.cfg somewhere and adjust the -readconfig to point there. You can find the .cfg file here: http://cgit.freedesktop.org/spice/qemu/plain/docs/ich9-ehci-uhci.cfg

Then connect to lthe vm with remote-viewer, redirect the troublesome USB-stick, let it run for a while and attach qemu.log here.

Comment 6 Hans de Goede 2012-07-28 15:42:49 UTC
I've filed bug 844073 for adding support for the debug parameter to libvirt's xml format

Comment 7 Milan Barta 2012-07-30 08:40:25 UTC
Created attachment 601145 [details]
qemu log with usbredir debug enabled

Comment 8 Hans de Goede 2012-07-30 10:20:52 UTC
Thanks for generating the log, this looks like it may be an issue fixed by a  recent  upstream fix, can you try with a Fedora-17 client with this version of usbredir installed:   ?
http://koji.fedoraproject.org/koji/buildinfo?buildID=344919

Comment 9 Milan Barta 2012-07-30 14:00:35 UTC
Tried running Fedora 17 client and the problem doesn't seem to occur anymore.

Comment 10 Hans de Goede 2012-07-30 14:51:16 UTC
(In reply to comment #9)
> Tried running Fedora 17 client and the problem doesn't seem to occur anymore.

That is good news, thanks for the info.

Comment 12 Hans de Goede 2012-12-14 10:56:17 UTC
(In reply to comment #9)
> Tried running Fedora 17 client and the problem doesn't seem to occur anymore.

Ok, that would make this a duplicate of bug 834560 .

*** This bug has been marked as a duplicate of bug 834560 ***