Bug 2003644 - Cannot change CD disk on block storage when previous one has startupPolicy
Summary: Cannot change CD disk on block storage when previous one has startupPolicy
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: libvirt
Version: 8.6
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: 8.5
Assignee: Peter Krempa
QA Contact: Han Han
URL:
Whiteboard:
Depends On:
Blocks: 1990268
TreeView+ depends on / blocked
 
Reported: 2021-09-13 11:23 UTC by Vojtech Juranek
Modified: 2022-02-15 07:51 UTC (History)
7 users (show)

Fixed In Version: libvirt-7.6.0-4.module+el8.5.0+12786+c4633d9a
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-11-16 07:55:27 UTC
Type: Bug
Target Upstream Version: 7.8.0
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-96987 0 None None None 2021-09-13 11:24:34 UTC
Red Hat Product Errata RHBA-2021:4684 0 None None None 2021-11-16 07:57:17 UTC

Description Vojtech Juranek 2021-09-13 11:23:12 UTC
Description of problem:
When current CD has defined startupPolicy attribute and one tries to change CD to a disk which is on block storage, it fails with

    libvirt.libvirtError: XML error: 'startupPolicy' is only valid for 'file' type volume


Example XML of empty CD:

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

Example of XML of CD to be changed, which is on block based storage:

<?xml version='1.0' encoding='utf-8'?>
<disk device="cdrom" type="block">
    <source dev="/rhev/data-center/mnt/blockSD/cdac2a0c-b110-456d-a988-7d588626c871/images/638247d7-b4b1-4d98-87fa-c90235fcf4b1/145e7cd2-f92d-4eec-a8fb-6835b4b652e1" />
    <target bus="sata" dev="sdc" />
</disk>

Actual result:
libvirt.libvirtError: XML error: 'startupPolicy' is only valid for 'file' type volume

Expected result:
CD is changed

Comment 1 Peter Krempa 2021-09-13 11:33:01 UTC
Fixed upstream:

commit 7e23272e35ff06335d1674348e5d74d199cae06f
Author: Peter Krempa <pkrempa>
Date:   Fri Sep 10 15:33:17 2021 +0200

    qemuDomainChangeDiskLive: Modify 'startupPolicy' before changing source
    
    We don't support all startup policies with all source types so to
    correctly allow switching from a 'file' based cdrom with 'optional'
    startup policy to a 'block' based one which doesn't support optional we
    must update the startup policy field first. Obviously we need to have
    fallback if the update fails.
    
    Reported-by: Vojtech Juranek <vjuranek>
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Michal Privoznik <mprivozn>

Comment 12 Han Han 2021-09-30 07:25:58 UTC
Reproduced on libvirt-7.6.0-4.module+el8.5.0+12786+c4633d9a.x86_64 qemu-kvm-6.0.0-30.module+el8.5.0+12586+476da3e1.x86_64

1. Prepare a running VM with startupPolicy in empty cdrom:
VM xml:
...
<disk type="file" device="cdrom">
      <driver name="qemu" type="raw"/>
      <source startupPolicy="optional"/>
      <target dev="sda" bus="scsi"/>
      <readonly/>
      <address type="drive" controller="0" bus="0" target="0" unit="0"/>
    </disk>
...

2. Prepare the following XML:
block-cdrom.xml:                                                                                                                    [3/35]
<disk type="block" device="cdrom">
      <driver name="qemu" type="raw"/>                                                                                                   
      <source dev="/dev/sdb"/>
      <target dev="sda" bus="scsi"/>
      <readonly/>
      <address type="drive" controller="0" bus="0" target="0" unit="0"/>
    </disk>
empty-cdrom.xml:
<disk type="file" device="cdrom">
      <driver name="qemu" type="raw"/>
      <source startupPolicy="optional"/>
      <target dev="sda" bus="scsi"/>
      <readonly/>
      <address type="drive" controller="0" bus="0" target="0" unit="0"/>
    </disk>
file-cdrom.xml:
<disk type="file" device="cdrom">
      <driver name="qemu" type="raw"/>
      <source file="/var/lib/libvirt/images/boot.iso"/>
      <target dev="sda" bus="scsi"/>
      <readonly/>
      <address type="drive" controller="0" bus="0" target="0" unit="0"/>
    </disk>
https-cdrom.xml:
<disk type="network" device="cdrom">
      <driver name="qemu" type="raw"/>
      <source protocol="https" name="/fedora/releases/34/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-34-1.2.iso">
        <host name="mirrors.163.com" port="443"/>
      </source>
      <target dev="sda" bus="scsi"/>
      <readonly/>
      <address type="drive" controller="0" bus="0" target="0" unit="0"/>
    </disk>

3. Update to block-cdrom.xml and https-cdrom.xml:
➜  virsh update-device rhel ./block-cdrom.xml                                                                             
error: Failed to update device from ./block-cdrom.xml                                                                                    
error: XML error: 'startupPolicy' is only valid for 'file' type volume                                                                   
                                                                                                                                         
➜  virsh update-device rhel ./https-cdrom.xml                                                                             
error: Failed to update device from ./https-cdrom.xml                                                                                    
error: XML error: 'startupPolicy' is only valid for 'file' type volume  




Update to libvirt-7.6.0-4.module+el8.5.0+12786+c4633d9a.x86_64. It works:
➜  virsh update-device rhel ./https-cdrom.xml
Device updated successfully

➜  virsh update-device rhel ./empty-cdrom.xml
Device updated successfully

➜  virsh update-device rhel ./block-cdrom.xml
Device updated successfully

Comment 14 errata-xmlrpc 2021-11-16 07:55:27 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (virt:av bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2021:4684


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