Bug 1788793 - Device type is not checked when updating device by “attach-device”
Summary: Device type is not checked when updating device by “attach-device”
Keywords:
Status: CLOSED DEFERRED
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: libvirt
Version: 8.2
Hardware: x86_64
OS: Linux
low
medium
Target Milestone: rc
: 8.0
Assignee: Virtualization Maintenance
QA Contact: gaojianan
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-01-08 06:08 UTC by gaojianan
Modified: 2020-03-10 14:43 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-03-10 14:43:23 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description gaojianan 2020-01-08 06:08:35 UTC
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:

Comment 1 Han Han 2020-01-15 07:11:06 UTC
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 :)

Comment 2 Daniel Berrangé 2020-01-15 09:51:21 UTC
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.

Comment 3 Jaroslav Suchanek 2020-03-10 14:43:23 UTC
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.


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