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.
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.
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