attach-device of usb falsely declares device in use by other domain

Bug #1190387 reported by Bill Mills
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
libvirt (Ubuntu)
Fix Released
Medium
Serge Hallyn
Precise
Fix Released
Medium
Serge Hallyn

Bug Description

=================================
SRU Justification
1. Impact: cannot attach host usb device to domain 2 after attaching it to domain 1 and shutting down domain 1.
2. Development fix: Reattach usb device to host when domain shuts down
3. Stable fix: same as development fix backport of upstream patch.
4. test case:
 To test inside a precise kvm guest,
 1. create a nested libvirt domain as per https://wiki.ubuntu.com/SergeHallyn_libvirtnest
 2. Create usb.xml file containing:
    <hostdev mode='subsystem' type='usb' managed='yes'>
      <source>
        <vendor id='0x1d6b'/>
        <product id='0x0001'/>
      </source>
    </hostdev>
        3. start cdboot, and attach the device to it
    virsh start cdboot
    virsh attach-device cdboot usb.xml
 4. stop cdboot, restart it, and try to attach the device again
    virsh destroy cdboot
    virsh start cdboot
    virsh attach-device cdboot usb.xml
 Without this fix, the second attach-device will fail.
5. Regression potential:
   This adds new code to the domain shutdown and libvirt start sequences. However they
   only affect the list of usb devices, so any regressions should be caught at usb
   device add/remove and libvirtd start/stop.

=================================

Running Ubuntu 12.04 x86_64
libvirt0 and libvirt-bin 0.9.8-2ubuntu17.8 causes a regression.
I am using QEMU/KVM virtual machines.

To reproduce:
   use virsh to create/start a vm
   use virsh to attach-device a host usb device
   use virsh to stop/destroy the vm
   use virsh to create vm again
   use virsh to attach the usb device again

I get:
virsh attach-device vm1 /var/lib/libvirt/hotplug/usb-serial.xml
error: Failed to attach device from /var/lib/libvirt/hotplug/usb-serial.xml
error: Requested operation is not valid: USB device 002:005 is in use by domain ..

Note the ".." characters. That is literal. It is printing garbage characters.
The failure is not 100% of the time but is pretty high (50% ?)

usb-serial.xml:
    <hostdev mode='subsystem' type='usb' managed='yes'>
      <source>
        <vendor id='0x067b'/>
        <product id='0x2303'/>
      </source>
    </hostdev>

backing up libvirt0 and libvirt-bin to 0.9.8-2ubuntu17.7 makes this problem go away.

While looking at this I found a Fedora bug that looks similar. The upstream patches they identified may be of interest.
https://bugzilla.redhat.com/show_bug.cgi?id=814866

Changed in libvirt (Ubuntu):
importance: Undecided → Medium
Changed in libvirt (Ubuntu):
status: New → In Progress
assignee: nobody → Serge Hallyn (serge-hallyn)
Changed in libvirt (Ubuntu Precise):
status: New → In Progress
importance: Undecided → Medium
assignee: nobody → Serge Hallyn (serge-hallyn)
Changed in libvirt (Ubuntu):
status: In Progress → Fix Released
description: updated
Revision history for this message
Serge Hallyn (serge-hallyn) wrote : debdiff with fix

The attached debdiff fixed the problem for me.

Unfortunately we need to wait for 0.9.8-2ubuntu17.10 to be promoted from precise-proposed to precise-updates (for bug 1113821) before we can push this.

The debdiff will also need to be refreshed against 0.9.8-2ubuntu17.10.

Revision history for this message
Dave Walker (davewalker) wrote : Please test proposed package

Hello Bill, or anyone else affected,

Accepted libvirt into precise-proposed. The package will build now and be available at http://launchpad.net/ubuntu/+source/libvirt/0.9.8-2ubuntu17.14 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in libvirt (Ubuntu Precise):
status: In Progress → Fix Committed
tags: added: verification-needed
Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

There was a failure to build due to a failed testcase. Sorry, investigating.

Revision history for this message
Stéphane Graber (stgraber) wrote :

Hello Bill, or anyone else affected,

Accepted libvirt into precise-proposed. The package will build now and be available at http://launchpad.net/ubuntu/+source/libvirt/0.9.8-2ubuntu17.15 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

Fix confirmed in precise-proposed.

tags: added: verification-done
removed: verification-needed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package libvirt - 0.9.8-2ubuntu17.15

---------------
libvirt (0.9.8-2ubuntu17.15) precise-proposed; urgency=low

  * update fix-for-parallel-port-passthrough-for-qemu: the xml for the new
    testcase was too modern and caused the test to fail by including new
    keywords.

libvirt (0.9.8-2ubuntu17.14) precise-proposed; urgency=low

  * qemu-delete-usb-devices-on-stop and
    qemu-build-activeusbhostdevs-on-reconnect: ensure that we can re-use
    a usb device after another domain using the device has shut
    down. (LP: #1190387) Backported from upstream git.
  * cherrypick fix-for-parallel-port-passthrough-for-qemu from upstream
    (LP: #1203620)
 -- Serge Hallyn <email address hidden> Mon, 14 Oct 2013 10:32:22 -0500

Changed in libvirt (Ubuntu Precise):
status: Fix Committed → Fix Released
Revision history for this message
Colin Watson (cjwatson) wrote : Update Released

The verification of this Stable Release Update has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regresssions.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.