failure when detaching a usb device

Bug #1219435 reported by Nils Naumann
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
libvirt (Fedora)
Fix Released
Medium
libvirt (Ubuntu)
Fix Released
Medium
Unassigned
Raring
Won't Fix
Medium
Unassigned

Bug Description

===================================
SRU Justification:
1. Impact: usb device autoremoval is broken
2. Development fix: fix a typo in a matching function
3. Stable fix: backport of stable fix
4. Test case: virsh detach-device (see below)
5. Regression potential: this is a trivial cherrypick of upstream patch, so there should be little risk of regression
===================================

Ubuntu 13.04

libvirt0: 1.0.2-0ubuntu11.13.04.2

The automatic unplugging of usb devices (in this case a Lego NXT) doesn't work any more. The following udev rule is used;

ACTION=="remove", \
    SUBSYSTEMS=="usb", \
    ATTRS{idVendor}=="0694", \
    ATTRS{idProduct}=="0002", \
    RUN+="/usr/bin/virsh detach-device WinXP-clone /var/lib/libvirt/images/hostdev-0694:0002.xml"
ACTION=="add", \
    SUBSYSTEMS=="usb", \
    ATTRS{idVendor}=="0694", \
    ATTRS{idProduct}=="0002", \
    RUN+="/usr/bin/virsh attach-device WinXP-clone /var/lib/libvirt/images/hostdev-0694:0002.xml"

the reason is apparently a bug in 'virsh detach-device':

$ /usr/bin/virsh attach-device WinXP-clone /var/lib/libvirt/images/hostdev-0694:0002.xml
Device attached successfully

$ /usr/bin/virsh detach-device WinXP-clone /var/lib/libvirt/images/hostdev-0694:0002.xml
Fehler: Fehler beim Lösen des Geräts von /var/lib/libvirt/images/hostdev-0694:0002.xml
Fehler: operation failed: host usb device vendor=0x0694 product=0x0002 not found

$ cat /var/lib/libvirt/images/hostdev-0694:0002.xml
<!--NXT -->
<hostdev mode='subsystem' type='usb' managed='yes'>
  <source>
    <vendor id='0x0694'/>
    <product id='0x0002'/>
  </source>
</hostdev>

A fix might be described in RH bug# 916837:
---
 src/conf/domain_conf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 4cae0d3..2b2f35c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8541,7 +8541,7 @@ static int
 virDomainHostdevMatchSubsysUSB(virDomainHostdevDefPtr a,
                                virDomainHostdevDefPtr b)
 {
- if (b->source.subsys.u.usb.bus && b->source.subsys.u.usb.device) {
+ if (a->source.subsys.u.usb.bus && a->source.subsys.u.usb.device) {
         /* specified by bus location on host */
         if (a->source.subsys.u.usb.bus == b->source.subsys.u.usb.bus &&
             a->source.subsys.u.usb.device == b->source.subsys.u.usb.device)
--
1.7.11.2

Revision history for this message
In , zhe (zhe-redhat-bugs) wrote :

Description:
detach-device can't remove usb device when using xml file

Versions
libvirt-1.0.2-1.el7.x86_64

How reproducible:
100%

Steps:
1:
#cat usb.xml
<hostdev mode='subsystem' type='usb' managed='yes'>
   <source>
     <vendor id='0x0951'/>
     <product id='0x1625'/>
   </source>
 </hostdev>

2: attach usb dev to guest
#virsh attach-device $guest usb.xml
Device attached successfully

3: detach usb dev from guest
#virsh detach-device $guest usb.xml
error: Failed to detach device from usb2.xml
error: operation failed: host usb device vendor=0x0951 product=0x1625 not found

Expect result
Device detached successfully

Additional info:
this worked on rhel6.4.
If add <address bus='1' device='2'/> in usb.xml , can detach usb successful.

Revision history for this message
In , Gunannan (gunannan-redhat-bugs) wrote :
Revision history for this message
In , Gunannan (gunannan-redhat-bugs) wrote :

commit a950f03e16dd958f821027aa5d396166163c3200
Author: Guannan Ren <email address hidden>
Date: Tue Mar 26 22:17:43 2013 +0800

    conf: fix a failure when detaching a usb device

     #virsh detach-device $guest usb.xml
     error: Failed to detach device from usb2.xml
     error: operation failed: host usb device vendor=0x0951 \
     product=0x1625 not found

    This regresstion is due to a typo in matching function. The first
    argument is always the usb device that we are checking for. If the
    usb xml file provided by user contains bus and device info, we try
    to search it by them, otherwise, we use vendor and product info.

    The bug occurred only when detaching a usb device with no bus and
    device info provided in the usb xml file.

Revision history for this message
In , weizhang (weizhang-redhat-bugs) wrote :

verify pass on
qemu-kvm-1.4.0-2.el7.x86_64
kernel-3.8.0-0.43.el7.x86_64
libvirt-1.0.4-1.el7.x86_64

usb device can be removed successfully

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

Thanks for reporting this bug. Marking confirmed for raring based on the rh bug. Marking fix released for saucy as that patch is included in 1.1.0.

Changed in libvirt (Ubuntu):
status: New → Confirmed
importance: Undecided → Medium
Changed in libvirt (Ubuntu Raring):
importance: Undecided → Medium
status: New → Confirmed
Changed in libvirt (Ubuntu):
status: Confirmed → Fix Released
description: updated
Revision history for this message
Brian Murray (brian-murray) wrote : Please test proposed package

Hello Nils, or anyone else affected,

Accepted libvirt into raring-proposed. The package will build now and be available at http://launchpad.net/ubuntu/+source/libvirt/1.0.2-0ubuntu11.13.04.5 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 Raring):
status: Confirmed → Fix Committed
tags: added: verification-needed
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote : [libvirt/raring] verification still needed

The fix for this bug has been awaiting testing feedback in the -proposed repository for raring for more than 90 days. Please test this fix and update the bug appropriately with the results. In the event that the fix for this bug is still not verified 15 days from now, the package will be removed from the -proposed repository.

tags: added: removal-candidate
Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

As raring is ending in 17 days I think dropping this sru is the best path, thanks.

Revision history for this message
In , Ludek (ludek-redhat-bugs) wrote :

This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.

Revision history for this message
Rolf Leggewie (r0lf) wrote :

raring has seen the end of its life and is no longer receiving any updates. Marking the raring task for this ticket as "Won't Fix".

Changed in libvirt (Ubuntu Raring):
status: Fix Committed → Won't Fix
Changed in libvirt (Fedora):
importance: Unknown → Medium
status: Unknown → Fix Released
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.