Bug 698096

Summary: USB device still exist after hot-unplug usb device and shutdown VM from virt-manager
Product: Red Hat Enterprise Linux 6 Reporter: mliu
Component: virt-managerAssignee: Cole Robinson <crobinso>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: low    
Version: 6.1CC: ajia, dyuan, mliu, mzhan
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: virt-manager was incorrectly comparing a running guest's USB devices to the USB devices of its offline config Consequence: A hotunplugged USB device would reappear when the guest was rebooted. Fix: Make sure device comparisons work for an online and offline guest. Result: Hotunplug correctly removes the USB device for all subsequent guest starts
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-12-06 16:07:55 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description mliu 2011-04-20 07:59:14 UTC
Description of problem:
When hot-plug an usb device , and then remove it from the running guest successfully. But when I shutdown the guest, the usb device is displayed on Hardware detail list again.

Version-Release number of selected component (if applicable):


How reproducible:
virt-manager-0.8.6-4.el6.noarch
libvirt-0.8.7-18.el6.x86_64
qemu-kvm-0.12.1.2-2.158.el6.x86_64
kernel-2.6.32-131.0.1.el6.x86_64

Steps to Reproduce:
1. Start a VM using virt-manager.
2. Check device using lspci, here we will hotplug network from host to guest:
# lsusb
...
Bus 002 Device 002: ID 0781:5151 SanDisk Corp. Cruzer Micro Flash Drive
...
3. Open a Virtual Machine->show details->"Add Hardware"->select 'USB Host Device' in hardware type list->select 002:002 in device list to assign the usb device to a vm.
4. The usb device is added successfully.
5. Make sure the guest is in running status
6. Open the guest virtual details page and click this usb device, then click Remove button
7. The usb device is removed successfully
8. Shutdown the VM
9. Open a Virtual Machine->show details, check that usb device
  
Actual results:
the usb device is displayed again.

Expected results:
the usb device should not be displayed, because it has been removed.

Additional info:
After usb device is removed, I edit the guest xml, the usb device info still exist in it. But dumpxml cannot find the usb device info.
#virsh edit rhel5.6
...
    <hostdev mode='subsystem' type='usb' managed='yes'>
      <source>
        <vendor id='0x0bda'/>
        <product id='0x0119'/>
      </source>
    </hostdev>
...

Comment 2 Cole Robinson 2011-07-28 15:29:17 UTC
Fixed in virt-manager-0.9.0-2.el6

Comment 4 Min Zhan 2011-08-03 05:51:40 UTC
Verified PASS in below environment:
# uname -r
2.6.32-165.el6.x86_64
qemu-kvm-0.12.1.2-2.175.el6.x86_64
libvirt-0.9.4-0rc1.2.el6.x86_64
virt-manager-0.9.0-5.el6.x86_64

Steps:
1. For a health guest, hotplug and hotunplug the usb device for the guest successfully.
2. Shutdown/Reboot the guest, from virt-manager check the USB device does not exist in guest any more.
# virsh dumpxml qcow2|grep hostdev
no output

# virsh edit qcow2
no hostdev element found.

---
I can reproduce this bug with virt-manager-0.8.6-4.el6.noarch.

Comment 5 Cole Robinson 2011-11-07 22:30:56 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Cause:
virt-manager was incorrectly comparing a running guest's USB devices to the USB devices of its offline config

Consequence:
A hotunplugged USB device would reappear when the guest was rebooted.


Fix:
Make sure device comparisons work for an online and offline guest.


Result:
Hotunplug correctly removes the USB device for all subsequent guest starts

Comment 6 errata-xmlrpc 2011-12-06 16:07:55 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2011-1642.html