Description of problem: Before attach new device there is no check of disk type between "cdrom" and "floppy" Version-Release number of selected component (if applicable): libvirt-5.10.0-1.module+el8.2.0+5135+ed3b2489.x86_64 qemu-kvm-4.2.0-4.module+el8.2.0+5220+e82621dc.x86_64 How reproducible: 100% Steps to Reproduce: 1.Prepare a guest with floppy device: ... <disk type='file' device='floppy'> <driver name='qemu' type='raw'/> <source file='/var/lib/libvirt/images/fd.img'/> <backingStore/> <target dev='fda' bus='fdc'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> </disk> ... 2.Prepare another xml file with cdrom type device for "attach" # cat cdrom.img <disk type='file' device='cdrom'> <driver name='qemu' type='raw'/> <source file='/var/lib/libvirt/images/a.iso'/> <target dev='fda' bus='sata'/> <readonly/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> </disk> 3.Attach the new device to the guest # virsh attach-device demo cdrom.img Device updated successfully Then the xml will like: <disk type='file' device='floppy'> ----device type is still floppy <driver name='qemu' type='raw' cache='none'/> <source file='/var/lib/libvirt/images/a.iso' index='13'/> <backingStore/> <target dev='fda' bus='fdc'/> <readonly/> <alias name='fdc0-0-0'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> </disk> But when we use update-device we will get error: # virsh update-device demo cdrom.img error:Operation not supported: cannot modify field 'device' of the disk Actual results: As step 3 Expected results: Attach-device should fail when the device type is different from before and get error "Operation not supported: cannot modify field 'device' of the disk" Additional info:
virDomainAttachDeviceFlags is added in v0.7.7 and it supports media update. Then virDomainUpdateDeviceFlags has been introduced since v0.8.0, which is intended to to do media update. For compatibilities we do not drop media update in virDomainAttachDevice*. Time flies. It is time to remove that support now :)
Putting the original bug title back. We do not simply delete API features in this way because that violates the key stable API promise in libvirt.
This bug was closed deferred as a result of bug triage. Please reopen if you disagree and provide justification why this bug should get enough priority. Most important would be information about impact on customer or layered product. Please indicate requested target release.