Bug 1372580

Summary: hotplug USB disk device miss drive_del on failure
Product: Red Hat Enterprise Linux 7 Reporter: Pei Zhang <pzhang>
Component: libvirtAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED ERRATA QA Contact: lijuan men <lmen>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3CC: dyuan, jdenemar, pkrempa, rbalakri, xuzhang, yanyang
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-2.5.0-1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-01 17:14:13 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Pei Zhang 2016-09-02 06:30:12 UTC
Description of problem:
hotplug USB disk device miss drive_del on failure 

Version-Release number of selected component (if applicable):
libvirt-2.0.0-6.el7.x86_64
qemu-kvm-rhev-2.6.0-22.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. define and start a guest like following :
# virsh dumpxml vm2 | grep usb 
    <controller type='usb' index='0'>
      <alias name='usb'/>
......
Prepare a usb disk xml like following with special address 
# cat usb.xml 
<disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/sdb'/>
      <target dev='sda' bus='usb'/>
<address type='usb' bus='0' port='3'/>
    </disk>

2.Try to attach the usb disk device, it should fail to attach since the ports limitation.

# virsh attach-device vm2 usb.xml 
error: Failed to attach device from usb.xml
error: internal error: unable to execute QEMU command 'device_add': usb port 3 (bus usb.0) not found (in use?)

3. delete the address, try to attach again

# cat usb.xml 
<disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/sdb'/>
      <target dev='sda' bus='usb'/>
    </disk>

# virsh attach-device vm2 usb.xml 
error: Failed to attach device from usb.xml
error: internal error: unable to execute QEMU command '__com.redhat_drive_add': Duplicate ID 'drive-usb-disk0' for drive


Actual results:
As step3, it fails to attach USB deivce after a failure.

Expected results:
It should attach successfully.


Additional info:

Comment 1 Peter Krempa 2016-09-13 08:41:43 UTC
Upstream fixes this by:

commit 190e22c06ba7e4b38e7690a7ef2ae4fc423a0b38
Author: John Ferlan <jferlan>
Date:   Wed Jun 29 16:32:58 2016 -0400

    qemu: Add attempt to call qemuMonitorDriveDel for USB failure path
    
    Partial fix for:
        https://bugzilla.redhat.com/show_bug.cgi?id=1336225
    
    Similar to the other disk types, add the qemuMonitorDriveDel in the failure
    to add/hotplug a USB.
    
    Added a couple of other formatting changes just to have a less cluttered look

Comment 3 lijuan men 2017-02-16 03:37:27 UTC
verify the bug 

version:
libvirt-3.0.0-1.el7.x86_64
qemu-kvm-rhev-2.8.0-3.el7.x86_64

steps:
1. define and start a guest like following :
# virsh dumpxml qq | grep usb 
...
    <controller type='usb' index='0'>
      <alias name='usb'/>
...
Prepare a usb disk xml like following with special address  	
# cat usb.xml 
<disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/sda'/>
      <target dev='sdc' bus='usb'/>
<address type='usb' bus='0' port='300'/>
    </disk>

2.Try to attach the usb disk device, it should fail to attach since the ports limitation.

# virsh attach-device qq usb.xml 
error: Failed to attach device from usb.xml
error: XML error: requested USB port 300 not present on USB bus 0

3. delete the address, try to attach again
# cat usb.xml 
<disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/sda'/>
      <target dev='sdc' bus='usb'/>
    </disk>

# virsh attach-device qq usb.xml 
Device attached successfully

Comment 4 errata-xmlrpc 2017-08-01 17:14:13 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.

https://access.redhat.com/errata/RHEA-2017:1846

Comment 5 errata-xmlrpc 2017-08-01 23:55:08 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.

https://access.redhat.com/errata/RHEA-2017:1846

Comment 6 errata-xmlrpc 2017-08-02 01:27:35 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.

https://access.redhat.com/errata/RHEA-2017:1846