Bug 1135488 - virt-manager: default of 4 usb redir devs fills up available VM usb ports
Summary: virt-manager: default of 4 usb redir devs fills up available VM usb ports
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: virt-manager (Show other bugs)
(Show other bugs)
Version: 20
Hardware: Unspecified Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Cole Robinson
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-08-29 12:51 UTC by Tom Horsley
Modified: 2015-01-19 08:50 UTC (History)
19 users (show)

Fixed In Version: virt-manager-1.0.1-5.fc20
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-11-09 15:46:41 UTC
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
XML definition of the windows7 virtual machine (4.96 KB, text/plain)
2014-08-29 16:30 UTC, Tom Horsley
no flags Details

Description Tom Horsley 2014-08-29 12:51:48 UTC
Description of problem:

On my system, lsusb shows:

Bus 003 Device 022: ID 046d:0825 Logitech, Inc. Webcam C270

The first oddity is that the "Add Hardware" dialog box that pops up with the list of USB devices has the description of some USB devices, but not all, including the bus 3 device 22 entry which just has a blank area where I'd expect it to say Logitech Webcam.

If I then select bus 3 device 22 and add it to the virtual machine, nothing shows up inside the 64bit Windows 7 machine, not even a indication that there is a broken device. It acts the same if I add the hardware first then boot the machine or if I add the hardware on a running machine.

I have added other USB hardware as a test (like a USB printer), and it worked, but everything I ever had work showed the description in the dialog box, so it is almost like the lack of description is supposed to be some kind of clue that the device won't work, but it isn't much of a clue because it doesn't give me any idea why it won't work.

I don't know if maybe udev rules are setting permissions for a webcam so that qemu can't get to it or what (and I don't know how to make it stop if they are).


Version-Release number of selected component (if applicable):
libvirt-1.1.3.5-2.fc20.x86_64
systemd-208-21.fc20.x86_64


How reproducible:
100%

Steps to Reproduce:
1.see above
2.
3.

Actual results:
No device passed through to Windows 7 virtual machine

Expected results:
Webcam shows up as new device in Windows 7 virtual machine.

Additional info:

See this virt mailing list thread:

https://lists.fedoraproject.org/pipermail/virt/2014-August/004131.html

Here's the gibberish from the /var/log/libvirt/qemu/windows7.log from the last time I tried to boot the virtual machine with the webcam already added at boot time (it was bus 3 device 29 at the time I tried this):

2014-08-29 01:14:59.768+0000: starting up
LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin QEMU_AUDIO_DRV=spice /usr/bin/qemu-kvm -name windows7 -S -machine pc-i440fx-1.6,accel=kvm,usb=off -cpu Westmere -m 8192 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid d99da15d-91d9-44a5-a289-2766f744c468 -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/windows7.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime,driftfix=slew -global kvm-pit.lost_tick_policy=discard -no-hpet -no-shutdown -global PIIX4_PM.disable_s3=1 -global PIIX4_PM.disable_s4=1 -boot menu=off -device ich9-usb-ehci1,id=usb,bus=pci.0,addr=0x5.0x7 -device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x5 -device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x5.0x1 -device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x5.0x2 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x6 -drive file=/zooty/images/windows7.img,if=none,id=drive-virtio-disk0,format=qcow2,cache=writeback -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x7,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -drive file=/zooty/images/swap-windows7.img,if=none,id=drive-virtio-disk1,format=raw,cache=writeback -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x9,drive=drive-virtio-disk1,id=virtio-disk1 -drive if=none,id=drive-ide0-0-0,readonly=on,format=raw -device ide-cd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -netdev tap,fd=23,id=hostnet0,vhost=on,vhostfd=24 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:5f:50:07,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=5900,addr=127.0.0.1,disable-ticketing,seamless-migration=on -device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,bus=pci.0,addr=0x2 -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 -chardev spicevmc,id=charredir1,name=usbredir -device usb-redir,chardev=charredir1,id=redir1 -chardev spicevmc,id=charredir2,name=usbredir -device usb-redir,chardev=charredir2,id=redir2 -chardev spicevmc,id=charredir3,name=usbredir -device usb-redir,chardev=charredir3,id=redir3 -device usb-host,hostbus=3,hostaddr=29,id=hostdev0 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x8
char device redirected to /dev/pts/1 (label charserial0)
main_channel_link: add main channel client
main_channel_handle_parsed: net test: latency 0.280000 ms, bitrate 27675675675 bps (26393.581080 Mbps)
red_dispatcher_set_cursor_peer: 
inputs_connect: inputs channel client create
qemu-system-x86_64: Warning: speed mismatch trying to attach usb device "host:3.29" (high speed) to bus "usb.0", port "6.1" (full speed)
qemu-system-x86_64: Warning: speed mismatch trying to attach usb device "host:3.29" (high speed) to bus "usb.0", port "6.1" (full speed)
main_channel_handle_parsed: agent start
main_channel_handle_parsed: agent start
qemu: terminating on signal 15 from pid 814
red_channel_client_disconnect_dummy: rcc=0x7f4f7fc22050 (channel=0x7f4f7f9fdec0 type=5 id=0)
snd_channel_put: SndChannel=0x7f4f7faaed40 freed
red_channel_client_disconnect_dummy: rcc=0x7f4f7fc1de10 (channel=0x7f4f7fa81bf0 type=6 id=0)
snd_channel_put: SndChannel=0x7f4f7fc0c4d0 freed
red_channel_client_disconnect: rcc=0x7f4d4c244a70 (channel=0x7f4d4c21f360 type=2 id=0)
red_channel_client_disconnect: rcc=0x7f4d4c2b1ad0 (channel=0x7f4d4c21f930 type=4 id=0)
2014-08-29 01:16:38.604+0000: shutting down

I see warnings in there about speed mismatch, but I when I look at the usb setting in virt-manager, it says USB 2, so I'm not sure what else I can do to try and make it use a USB2 pass through.

Comment 1 Tom Horsley 2014-08-29 16:30:57 UTC
Created attachment 932744 [details]
XML definition of the windows7 virtual machine

In case it is useful, here is the xml that defines the windows7 virtual machine (The webcam was not attached when this dump was taken). I can't say I actually understand any of this stuff, but it does appear to defined an ehci high speed USB controller you'd think it could use to plug a high speed device.

Comment 2 Tom Horsley 2014-08-30 01:23:53 UTC
And to be really annoying, the webcam works fine when I attach it to a 32 bit Windows XP virtual machine on the same host. Here's the qemu log with the device as bus 3 device 32:

2014-08-30 01:13:26.390+0000: starting up
LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin QEMU_AUDIO_DRV=spice /usr/bin/qemu-kvm -name winxppro -S -machine pc-0.14,accel=kvm,usb=off -m 8096 -realtime mlock=off -smp 2,sockets=2,cores=1,threads=1 -uuid 6d626c31-643c-ca9a-d36d-3c1612e39bbd -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/winxppro.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime -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=0x8 -drive file=/zooty/images/winxppro.img,if=none,id=drive-virtio-disk0,format=qcow2,cache=writeback -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -drive file=/zooty/images/swap-winxppro.img,if=none,id=drive-virtio-disk1,format=raw,cache=writeback -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x7,drive=drive-virtio-disk1,id=virtio-disk1 -drive if=none,id=drive-ide0-1-0,readonly=on,format=raw -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -netdev tap,fd=23,id=hostnet0,vhost=on,vhostfd=24 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=54:52:00:62:7b:5c,bus=pci.0,addr=0x5 -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=5900,addr=127.0.0.1,disable-ticketing,seamless-migration=on -device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,bus=pci.0,addr=0x2 -device AC97,id=sound0,bus=pci.0,addr=0x3 -device usb-host,hostbus=3,hostaddr=32,id=hostdev0 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6
char device redirected to /dev/pts/0 (label charserial0)
main_channel_link: add main channel client
main_channel_handle_parsed: net test: latency 0.123000 ms, bitrate 24380952380 bps (23251.488094 Mbps)
inputs_connect: inputs channel client create
red_dispatcher_set_cursor_peer: 
main_channel_handle_parsed: agent start
ehci warning: guest updated active QH
qemu: terminating on signal 15 from pid 9827
red_channel_client_disconnect_dummy: rcc=0x7f8eb7e50240 (channel=0x7f8eb7e0fc70 type=5 id=0)
snd_channel_put: SndChannel=0x7f8eb7e468d0 freed
red_channel_client_disconnect_dummy: rcc=0x7f8eb7fa6910 (channel=0x7f8eb7e34860 type=6 id=0)
snd_channel_put: SndChannel=0x7f8eb7f960d0 freed
2014-08-30 01:15:17.808+0000: shutting down

Inside that virtual machine I was able to use Windows movie maker to record video from the webcam, and the device showed up in device manager as "legacy video capture" (or something like that). I didn't even have to install anything from logitech.

This may be the same as a problem thought to be only in virt-preview:

https://lists.fedoraproject.org/pipermail/virt/2014-August/004127.html

Comment 3 Tom Horsley 2014-08-30 02:04:32 UTC
I've been looking at the Windows 7 system in more detail, and I actually do detect one thing when I plug in the webcam: For some reason, a "NEC USB Hub" appears in the usb controllers section of the device manager, but there is definitely no webcam device showing up anywhere.

Comment 4 Cole Robinson 2014-09-05 21:25:27 UTC
(In reply to Tom Horsley from comment #0)
> Description of problem:
> 
> On my system, lsusb shows:
> 
> Bus 003 Device 022: ID 046d:0825 Logitech, Inc. Webcam C270
> 
> The first oddity is that the "Add Hardware" dialog box that pops up with the
> list of USB devices has the description of some USB devices, but not all,
> including the bus 3 device 22 entry which just has a blank area where I'd
> expect it to say Logitech Webcam.
> 

Libvirt/virt-manager gets that info from udev, so if you can see the correct vendor/product in udev output then either libvirt or virt-manager is messing up:

  udevadm info /dev/bus/usb/$bus/$addr

Regardless I'm guessing that's not related to the device not working, but I could be wrong

> I see warnings in there about speed mismatch, but I when I look at the usb
> setting in virt-manager, it says USB 2, so I'm not sure what else I can do
> to try and make it use a USB2 pass through.

Whatever is causing those warnings is probably responsible. Gerd, please see Tom's output in Comment #1, any thoughts?

Comment 5 Tom Horsley 2014-09-05 23:19:15 UTC
I tried plugging it in again, and I see this in lsusb:

Bus 003 Device 014: ID 046d:0825 Logitech, Inc. Webcam C270

And this from  udevadm info /dev/bus/usb/003/014
P: /devices/pci0000:00/0000:00:14.0/usb3/3-12/3-12.2
N: bus/usb/003/014
E: BUSNUM=003
E: DEVNAME=/dev/bus/usb/003/014
E: DEVNUM=014
E: DEVPATH=/devices/pci0000:00/0000:00:14.0/usb3/3-12/3-12.2
E: DEVTYPE=usb_device
E: DRIVER=usb
E: ID_BUS=usb
E: ID_MODEL=0825
E: ID_MODEL_ENC=0825
E: ID_MODEL_FROM_DATABASE=Webcam C270
E: ID_MODEL_ID=0825
E: ID_REVISION=0012
E: ID_SERIAL=046d_0825_E4A49F80
E: ID_SERIAL_SHORT=E4A49F80
E: ID_USB_INTERFACES=:0e0100:0e0200:010100:010200:
E: ID_VENDOR=046d
E: ID_VENDOR_ENC=046d
E: ID_VENDOR_FROM_DATABASE=Logitech, Inc.
E: ID_VENDOR_ID=046d
E: MAJOR=189
E: MINOR=269
E: PRODUCT=46d/825/12
E: SUBSYSTEM=usb
E: TYPE=239/2/1
E: UPOWER_VENDOR=Logitech, Inc.
E: USEC_INITIALIZED=4424686435

I certainly see logitech and webcam in there, so I don't know why virt-manager doesn't say it.

Comment 6 Cole Robinson 2014-09-05 23:26:41 UTC
Tom, can you open a separate bug against libvirt to track that? Provide that above udevadm output, and the virsh nodedev XML. To find the latter, you'll probably need to do

for i in `sudo virsh nodedev-list --cap usb_device | xargs`; do sudo virsh nodedev-dumpxml $i; done

and inspect the output for the matching device (maybe search for vendor hex string) and post it into the new bug. Thanks

Comment 7 Gerd Hoffmann 2014-09-08 06:58:41 UTC
(In reply to Tom Horsley from comment #3)
> I've been looking at the Windows 7 system in more detail, and I actually do
> detect one thing when I plug in the webcam: For some reason, a "NEC USB Hub"
> appears in the usb controllers section of the device manager, but there is
> definitely no webcam device showing up anywhere.

There are too many usb devices.  Four spice usb redirection slots.  One usb tablet.  Leaving only one usb port free, where qemu automagically plugs in a usb hub to avoid running out of usb ports.  This is where the "nec usb hub" comes from.  And as the emulated usb hub supports usb 1.1 only the webcam ends up on a slow port.  This is where the speed mismatch comes from, which is root cause why the webcam doesn't show up in the guest.

So, you have those four spice redirection ports, you can use virt-viewer (not fully sure virt-manager supports this too), then attach the webcam using spice usb redirection.  You find this via "File -> USB device selection" menu in virt-viewer.

Alternatively you can remove (some of) the spice redirection ports from the vm configuration to free up usb2 ports.  Then your webcam will get a usb2 port (when added via "add usb host device") and will work properly.

Comment 8 Tom Horsley 2014-09-08 10:15:09 UTC
I certainly didn't configure the machine this way, I just let virt-manager set things up. Was it maybe a bad idea for virt-manager to allocate all the ports the way it did?

Comment 9 Cole Robinson 2014-09-08 11:25:35 UTC
FWIW virt-manager does support the spice USB direction, similar to virt-viewer

(In reply to Tom Horsley from comment #8)
> I certainly didn't configure the machine this way, I just let virt-manager
> set things up. Was it maybe a bad idea for virt-manager to allocate all the
> ports the way it did?

Yeah this is virt-manager's fault... I didn't think the USB redirection devices had any downside, so I added 4 by default which is what gnome-boxes does. Figuring that boxes can't do typical USB device assignment since it requires a privileged libvirtd, all USB assignment for them needs to go over USB redirection, so they can afford to fill up more ports. Let's repurpose this bug to track virt-manager changing the default to 1 or 2 redirection devices.

Gerd, just curious, is the 6 port limit a function of the emulated usb2 hardware? Is there a limit for the usb1 and usb3 configurations?

Comment 10 Gerd Hoffmann 2014-09-08 12:13:13 UTC
  Hi,

> Gerd, just curious, is the 6 port limit a function of the emulated usb2
> hardware? Is there a limit for the usb1 and usb3 configurations?

uhci has two ports, fixed.
ehci has six ports, fixed.

ehci-with-companions has one ehci + three uhci controllers grouped.

xhci has four ports, by default, but I don't think libvirt has support for changing the number of ports.

The usb hub is used to increase the number of ports.  Which is pretty much transparent for uhci / usb1 devices.  But with ehci/xhci the devices connected via hub are second-class citizens as the hub supports usb1 only.

It is also possible to simply add a second ehci+companion controller group, so you get 12 instead of 6 ports.  Making that work nicely requires a bit more work in virt-manager though as you have explicitly assign usb devices to one of the two usb busses you have then.  libvirt supports <address type=usb/>, but it doesn't add those itself if not present (unlike it does with pci), so some work might be needed on the libvirt front too.

Comment 11 Tom Horsley 2014-09-09 00:48:48 UTC
By golly, I deleted a couple of the USB redirector devices, and I could use add hardware to add the webcam and it actually worked.

Comment 12 Cole Robinson 2014-09-21 00:18:02 UTC
Fixed upstream

commit 3933ff101b880898c9e7a502efd641db9c4bf8a5
Author: Cole Robinson <crobinso@redhat.com>
Date:   Sat Sep 20 20:16:31 2014 -0400

    guest: Limit number of default usb redirdevs to 2 (bug 1135488)

Comment 13 Fedora Update System 2014-10-29 18:16:23 UTC
virt-manager-1.0.1-5.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/virt-manager-1.0.1-5.fc20

Comment 14 Fedora Update System 2014-11-01 01:31:16 UTC
Package virt-manager-1.0.1-5.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing virt-manager-1.0.1-5.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-14000/virt-manager-1.0.1-5.fc20
then log in and leave karma (feedback).

Comment 15 Fedora Update System 2014-11-09 15:46:41 UTC
virt-manager-1.0.1-5.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.