Bug 1257844 - Libvirt should fail to attach-device if disk bus is virtio with not matching address type
Libvirt should fail to attach-device if disk bus is virtio with not matching ...
Status: ASSIGNED
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt (Show other bugs)
7.2
x86_64 Unspecified
medium Severity medium
: rc
: ---
Assigned To: Jiri Denemark
lijuan men
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-08-28 04:37 EDT by Pei Zhang
Modified: 2017-11-20 09:19 EST (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Pei Zhang 2015-08-28 04:37:16 EDT
Description of problem:
Using attach-device to attach a disk which bus is virtio with not matching address type, it will attach successfully without error, but then, it fail to detach.

Version-Release number of selected component (if applicable):
libvirt-1.2.17-6.el7.x86_64
qemu-kvm-rhev-2.3.0-18.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.prepare a disk xml like following

# cat disk.xml
<disk type='block' device='disk'>
<driver name='qemu' type='raw'/>
<source dev='/dev/sdc'/>
<target dev='vde' bus='virtio'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>

2. attach the disk to a healthy guest

# virsh attach-device r708 disk.xml
Device attached successfully

2.1 attach successfully , check domain xml.
# virsh dumpxml r708|grep disk -A 8
......
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/sdc'/>
      <backingStore/>
      <target dev='vde' bus='virtio'/>
      <alias name='virtio0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
......

3. Try to detach this disk.

# virsh detach-device r708 disk.xml
error: Failed to detach device from disk.xml
error: operation failed: device cannot be detached without a valid PCI address

# virsh detach-disk r708 vde
error: Failed to detach disk
error: operation failed: device cannot be detached without a valid PCI address

4. Try to attach with options

# virsh attach-device r708 disk.xml --config
error: Failed to attach device from disk.xml
error: unsupported configuration: virtio disk cannot have an address of type 'drive'

# virsh attach-device r708 disk.xml --persistent
error: Failed to attach device from disk.xml
error: unsupported configuration: virtio disk cannot have an address of type 'drive'


Actual results:
As step 2 and step 3; attach-device successfully with the error configuration , then fail to detach.

Expected results:
In step2 , should give clear error message as step4 when I attach-device with error configuration. 

Additional info:
These error configuration also will fail when define / create / edit as expected , it will give clear error message.
Comment 2 Jiri Denemark 2017-11-20 09:19:16 EST
Unfortunately, while this sounds trivial, libvirt's device-attach code is so bad fixing this will require nontrivial work. Currently device addresses are checked in several places each doing only some checks which are needed at that place. Thus, there is no single place where we would verify the device address is configured properly. And this will need to be changed.

Note You need to log in before you can comment on or make changes to this bug.