Bug 524035

Summary: libvirt should support USB device detach
Product: [Fedora] Fedora Reporter: Vladimir Benes <vbenes>
Component: libvirtAssignee: Daniel Veillard <veillard>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: 12CC: berrange, clalance, crobinso, itamar, markmc, veillard, virt-maint
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-03-16 11:22:42 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On:    
Bug Blocks: 514891    

Description Vladimir Benes 2009-09-17 12:34:53 EDT
Description of problem:
when I plug in USB flash and attach it I cannot detach it in virt-manager any more 

Version-Release number of selected component (if applicable):
libvirt-0.7.1-4.fc12.x86_64
virt-viewer-0.2.0-1.fc12.x86_64
libvirt-client-0.7.1-4.fc12.x86_64
virt-manager-0.8.0-3.fc12.noarch
virt-top-1.0.3-5.fc12.x86_64
python-virtinst-0.500.0-2.fc12.noarch
libvirt-python-0.7.1-4.fc12.x86_64
virt-mem-0.3.1-9.fc12.x86_64

gpxe-roms-qemu-0.9.7-5.fc12.noarch
qemu-kvm-0.10.92-4.fc12.x86_64
qemu-common-0.10.92-4.fc12.x86_64
qemu-system-x86-0.10.92-4.fc12.x86_64
qemu-kvm-tools-0.10.92-4.fc12.x86_64
qemu-img-0.10.92-4.fc12.x86_64

kernel-2.6.31-14.fc12.x86_64

How reproducible:


Steps to Reproduce:
1.plug in USB device 
2.via virt-manager add usb device as a storage
3.try to detach it via virt-manager
  
Actual results:

have to reboot

Expected results:
guest still running

Additional info:
Comment 1 Mark McLoughlin 2009-09-17 13:17:19 EDT
Yeah, seems like libvirt doesn't support USB detach for some reason

I assume the error message is:

  only SCSI or virtio disk device can be detached dynamically

Looks like this is perfectly possible to implement, adding to F13VirtTarget
Comment 2 Daniel Berrange 2009-09-21 07:02:01 EDT
The reason its not implemented is that QEMU's  usb_del monitor command is more or less useless


First consider what you do to attach a USB device, eg either on command line use '-usb mouse' or via monitor use 'usb_add mouse' 

The monitor 'usb_del' command though requires the USB bus+device address of the device to be attached.  The trouble is that this address is not assigned at time of usb attachment - its assigned only when the guest OS activates the USB device.

eg, consider this example

$ ./i386-softmmu/qemu -usb -usbdevice mouse -usbdevice tablet -monitor stdio
QEMU 0.11.50 monitor - type 'help' for more information
(qemu) info usb
  Device 0.0, Speed 12 Mb/s, Product QEMU USB Mouse
  Device 0.0, Speed 12 Mb/s, Product QEMU USB Hub
  Device 0.0, Speed 12 Mb/s, Product QEMU USB Tablet

You can do 'usb_del 0.0' but which device is it going to detach - its anybody's guess :-(   Even if addresses were present, its impossible to distinguish two devices of the same type in 'info usb'.

So to do this we need qdev 'id' flag support I think. libvirt could assign a unique identifier 'usbmouse0', and then be allowed todo 'usb_del usbmouse0'
Comment 3 Mark McLoughlin 2009-09-21 10:53:41 EDT
(In reply to comment #2)
> The trouble is that this address is not assigned at
> time of usb attachment - its assigned only when the guest OS activates the USB
> device.

Ah, okay - interesting.
 
> So to do this we need qdev 'id' flag support I think. libvirt could assign a
> unique identifier 'usbmouse0', and then be allowed todo 'usb_del usbmouse0'  

Yep
Comment 4 Bug Zapper 2009-11-16 07:34:15 EST
This bug appears to have been reported against 'rawhide' during the Fedora 12 development cycle.
Changing version to '12'.

More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 5 Cole Robinson 2010-03-16 11:22:42 EDT
Pretty sure this is fixed in latest libvirt. Since this is part of -device support which is hugely invasive, it will only be in rawhide/F14 unless we rebase older Fedora. Closing as RAWHIDE.