On Friday, 10 September 2021 15:12:07 CEST Peter Krempa wrote:
On Fri, Sep 10, 2021 at 14:53:23 +0200, Vojtech Juranek wrote:
> Hi,
> when adding support for CD disk on block based storage into oVirt,
> I spotted following issue. When starting VM without CD, we add
> startupPolicy='optional' attribute into <source> element.
>
> Whole XML looks like this:
> <disk type='file' device='cdrom'>
>
> <driver name='qemu' error_policy='report'/>
> <source startupPolicy='optional'/>
> <target dev='sdc' bus='sata'/>
> <readonly/>
> <alias name='ua-d7003457-63c3-4c98-80f0-08ab5042c65e'/>
> <address type='drive' controller='0' bus='0'
target='0' unit='2'/>
>
> </disk>
>
> To change/insert CD we use libvirt.updateDeviceFlags() with XML which
> looks like this (for block based disk):
>
> <?xml version='1.0' encoding='utf-8'?>
> <disk device="cdrom" type="block">
>
> <source
> dev="/rhev/data-center/mnt/blockSD/cdac2a0c-b110-456d-a988-7d588626c8
> 71/images/638247d7-b4b1-4d98-87fa-c90235fcf4b1/145e7cd2-f92d-4eec-a8fb
> -6835b4b652e1" /> <target bus="sata" dev="sdc"
/>
>
> </disk>
>
> However, updateDeviceFlags() fails with
>
> libvirt.libvirtError: XML error: 'startupPolicy' is only valid for
> 'file' type volume>
> What is the reason for this error? We don't use `startupPolicy` attribute
> for block based disks, as shown on example above.
Hmm, the bug is that the disk source change is attempted before the
update to startup policy, thus the validator is unhappy.
is this a libvirt bug or intentional behavior and the CD change should be done
in two steps:
* remove startupPolicy from the disk
* do actual change of the disk
?
Thanks
Vojta