Bug 1257844 - Libvirt should fail to attach-device if disk bus is virtio with not matching address type
Summary: Libvirt should fail to attach-device if disk bus is virtio with not matching ...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libvirt
Version: unspecified
Hardware: x86_64
OS: Unspecified
medium
medium
Target Milestone: ---
Assignee: Libvirt Maintainers
QA Contact: lijuan men
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-08-28 08:37 UTC by Pei Zhang
Modified: 2018-05-30 10:15 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-05-30 10:09:17 UTC
Embargoed:


Attachments (Terms of Use)

Description Pei Zhang 2015-08-28 08:37:16 UTC
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 14:19:16 UTC
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.

Comment 3 Ján Tomko 2018-05-30 10:15:00 UTC
Actually, this works with current upstream libvirt (4.4.0-rc1)
Possibly fixed by:
https://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=311f4069f936ecb48c1e82964d1c537035451513
commit 311f4069f936ecb48c1e82964d1c537035451513
Author:     Ján Tomko <jtomko>
AuthorDate: 2017-10-18 15:39:33 +0200
Commit:     Ján Tomko <jtomko>
CommitDate: 2017-10-19 14:45:15 +0200

    qemu: remove pointless address validation on hot unplug


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