attach-device of usb falsely declares device in use by other domain
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:/
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/
error: Failed to attach device from /var/lib/
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:/
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 |
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.