Bug 1006894

Summary: Inconsistent behavior while autoassigning usb ports
Product: [Fedora] Fedora Reporter: Lukáš Doktor <ldoktor>
Component: qemuAssignee: Fedora Virtualization Maintainers <virt-maint>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 19CC: amit.shah, berrange, cfergeau, crobinso, dwmw2, hdegoede, itamar, kraxel, pbonzini, rjones, scottt.tw, virt-maint
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-11-04 09:06:30 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 Lukáš Doktor 2013-09-11 13:16:05 UTC
Description of problem:
Hi guys, I found another inconsistency, which confuses me. When I add usb-bus and than plug some devices into this bus without specifying port it assigns them incrementally (1, 2, 3, 4, 5, ...). Anyway when I remove the device and than try to add them again, it assigns them in the different manner. (from what I've seen it's the opposite order of the removed devices).

I'd like to ask if this is something we intend to unify or if I should just always assign port and not trust qemu to do it incrementally?

Version-Release number of selected component (if applicable):
qemu-kvm-1.4.2-7.fc19.x86_64


How reproducible:
Always


Steps to Reproduce (UHCI):
1. echo -e "device_add usb-tablet,bus=uhci.0,id=aa\ndevice_add usb-tablet,bus=uhci.0,id=bb,port=2\ndevice_del aa\ndevice_del bb\ndevice_add usb-tablet,bus=uhci.0,id=aa\ndevice_add usb-tablet,bus=uhci.0,id=bb,port=2" | qemu-kvm -nodefaults -monitor stdio     -device ich9-usb-uhci1,id=uhci
2. echo -e "device_add usb-tablet,bus=uhci.0,id=aa\ndevice_add usb-tablet,bus=uhci.0,id=bb,port=2\ndevice_del bb\ndevice_del aa\ndevice_add usb-tablet,bus=uhci.0,id=aa\ndevice_add usb-tablet,bus=uhci.0,id=bb,port=2" | qemu-kvm -nodefaults -monitor stdio     -device ich9-usb-uhci1,id=uhci


Actual results:
Step 1 passes (adds 2 devices, removes them and add them again in the same order)
Step 2 fails (adds 2 devices, removes them and while adding them again it assigns the last port first)


Steps to Reproduce (EHCI):
1. echo -e "device_add usb-tablet,bus=ehci.0,id=aa\ndevice_add usb-tablet,bus=ehci.0,id=bb\ndevice_add usb-tablet,bus=ehci.0,id=cc\ndevice_add usb-tablet,bus=ehci.0,id=dd\ndevice_add usb-tablet,bus=ehci.0,id=ee\ndevice_add usb-tablet,bus=ehci.0,id=ff,port=6\ndevice_del aa\ndevice_del bb\ndevice_del cc\ndevice_del dd\ndevice_del ee\ndevice_del ff\ndevice_add usb-tablet,bus=ehci.0,id=aa\ndevice_add usb-tablet,bus=ehci.0,id=bb\ndevice_add usb-tablet,bus=ehci.0,id=cc\ndevice_add usb-tablet,bus=ehci.0,id=dd\ndevice_add usb-tablet,bus=ehci.0,id=ee\ndevice_add usb-tablet,bus=ehci.0,id=ff,port=6" | qemu-kvm -nodefaults -monitor stdio     -device usb-ehci,id=ehci
2. echo -e "device_add usb-tablet,bus=ehci.0,id=aa\ndevice_add usb-tablet,bus=ehci.0,id=bb\ndevice_add usb-tablet,bus=ehci.0,id=cc\ndevice_add usb-tablet,bus=ehci.0,id=dd\ndevice_add usb-tablet,bus=ehci.0,id=ee\ndevice_add usb-tablet,bus=ehci.0,id=ff,port=6\ndevice_del ff\ndevice_del ee\ndevice_del dd\ndevice_del cc\ndevice_del bb\ndevice_del aa\ndevice_add usb-tablet,bus=ehci.0,id=aa\ndevice_add usb-tablet,bus=ehci.0,id=bb\ndevice_add usb-tablet,bus=ehci.0,id=cc\ndevice_add usb-tablet,bus=ehci.0,id=dd\ndevice_add usb-tablet,bus=ehci.0,id=ee\ndevice_add usb-tablet,bus=ehci.0,id=ff,port=6" | qemu-kvm -nodefaults -monitor stdio     -device usb-ehci,id=ehci


Actual results:
Step 1 passes (adds 6 devices, removes them and add them again in the same order)
Step 2 fails (adds 6 devices, removes them and while adding them again it assigns the last port first)


Expected results:
usb port should assigns the port incrementally (or am I wrong?). Why does it matter where from I remove the device?


Additional info:
The only difference between step 1 and step 2 are reversed order of device_del.

Comment 1 Cole Robinson 2013-10-31 20:53:45 UTC
Hans, Gerd, care to weigh in?(In reply to Lukas Doktor from comment #0)
> Description of problem:
> Hi guys, I found another inconsistency, which confuses me. When I add
> usb-bus and than plug some devices into this bus without specifying port it
> assigns them incrementally (1, 2, 3, 4, 5, ...). Anyway when I remove the
> device and than try to add them again, it assigns them in the different
> manner. (from what I've seen it's the opposite order of the removed devices).
> 
> I'd like to ask if this is something we intend to unify or if I should just
> always assign port and not trust qemu to do it incrementally?

Hans, Gerd, care to weigh in?

Comment 2 Gerd Hoffmann 2013-11-04 09:06:30 UTC
If you want a specific port assigning, just explicitly say so.