RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2095758 - Regression in 'startupPolicy' behaviour for disks backed by a block device
Summary: Regression in 'startupPolicy' behaviour for disks backed by a block device
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: libvirt
Version: 8.6
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: rc
: ---
Assignee: Peter Krempa
QA Contact: Han Han
URL:
Whiteboard:
Depends On:
Blocks: 2109571
TreeView+ depends on / blocked
 
Reported: 2022-06-10 13:26 UTC by Juan Orti
Modified: 2023-01-12 08:32 UTC (History)
13 users (show)

Fixed In Version: libvirt-8.0.0-8.module+el8.7.0+15648+3854f89a
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 2109571 (view as bug list)
Environment:
Last Closed: 2022-11-08 09:20:10 UTC
Type: Bug
Target Upstream Version: 8.5.0
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker LIBVIRTAT-13375 0 None None None 2022-08-17 03:52:48 UTC
Red Hat Issue Tracker RHELPLAN-124985 0 None None None 2022-06-10 13:53:24 UTC
Red Hat Knowledge Base (Solution) 6962793 0 None None None 2022-06-10 13:52:34 UTC
Red Hat Product Errata RHSA-2022:7472 0 None None None 2022-11-08 09:21:14 UTC

Description Juan Orti 2022-06-10 13:26:50 UTC
Description of problem:
In RHEL 7, using the option startupPolicy='optional' in hard disks backed by a block device worked as expected. However, after upgrading to RHEL 8, this option is rejected.

Version-Release number of selected component (if applicable):
libvirt-8.0.0-5.module+el8.6.0+14480+c0a3aa0f.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Have a RHEL 8.6 hypervisor, libvirt-8.0.0-5.module+el8.6.0+14480+c0a3aa0f.x86_64
2. Start up a VM
3. Try to attach an existing block device like /dev/sdb with startupPolicy='optional':

    # cat /tmp/disk.xml
    <disk type='block' device='disk'>
      <driver name='qemu' type='raw' cache='none'/>
      <source dev='/dev/sdb' startupPolicy='optional'/>
      <target dev='vdb' bus='virtio'/>
    </disk>

Actual results:
The attachment fails:

    # virsh attach-device guest /tmp/disk.xml --live
    error: Failed to attach device from /tmp/disk.xml
    error: XML error: 'startupPolicy' is only valid for 'file' type volume

Expected results:
- Device attachment not rejected as in RHEL 7.
- Be able to start up the VM if startupPolicy='optional' and the block device /dev/sdb doesn't exist.

Additional info:

Comment 1 Peter Krempa 2022-06-14 15:01:13 UTC
Fixed upstream by:

commit ed8984306e1cd44c424fda3ed412a4177dd7b84d
Author: Peter Krempa <pkrempa>
Date:   Tue Jun 14 14:21:33 2022 +0200

    virDomainDiskTranslateSourcePool: Fix check of 'startupPolicy' definition
    
    The check was historically done only for _TYPE_VOLUME disks, but
    refactors to allow _TYPE_VOLUME disks in the backing chain caused a
    regression where we'd reject startupPolicy also for _TYPE_BLOCK disks
    which historically worked well.
    
    Fix it by using the 'virDomainDiskDefValidateStartupPolicy' helper and
    use it only when the top level image is a _TYPE_VOLUME as in other cases
    it was already validated. This also allows _TYPE_BLOCK volumes to use
    startup policy.
    
    Fixes: 37f01262eed9f37dd5eb7de8b83edd2fea741054
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2095758
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Ján Tomko <jtomko>

commit b90d0f0a1e4ee52c828fb683c14c14e241e6fcbb
Author: Peter Krempa <pkrempa>
Date:   Tue Jun 14 14:07:47 2022 +0200

    virDomainDiskDefValidateStartupPolicy: Validate disk type better
    
    Our startup policy checkers work only for local paths, so disk sources
    such as NVMe, or vhost-user can't be used with startup policy.
    
    Unfortunately the validation did not catch these cases. Fix it.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Ján Tomko <jtomko>

commit 3603a18bcec18842cedecbd8329723062b87795c
Author: Peter Krempa <pkrempa>
Date:   Tue Jun 14 13:23:29 2022 +0200

    domain_validate: Split out validation of disk startup policy
    
    Move the code into 'virDomainDiskDefValidateStartupPolicy' which will be
    later reused in the qemu driver.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Ján Tomko <jtomko>

commit 9a480737c8adf92c332aa850c5269191ceb04eb9
Author: Peter Krempa <pkrempa>
Date:   Tue Jun 14 13:13:48 2022 +0200

    virDomainDiskDefValidate: Improve error messages for 'startupPolicy' checks
    
    Remove linebreak and mention the attribute name. Also prepare the error
    messages for future by substituting the type of offending access.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Ján Tomko <jtomko>

Comment 5 Han Han 2022-06-16 09:35:46 UTC
Tested on libvirt-8.0.0-8.module+el8.7.0+15648+3854f89a.x86_64 qemu-kvm-6.2.0-14.module+el8.7.0+15289+26b4351e.x86_64:
1. Create a domain from the XML with: file,block,volume type; startupPolicy="optional"; non-exist disks
➜  ~ xmllint --format rh85.xml|xmllint --xpath //disk -
<disk type="file" device="disk">
      <driver name="qemu" type="qcow2"/>
      <source file="/var/lib/libvirt/images/RHEL-8.5-x86_64-latest.qcow2" startupPolicy="optional"/>
      <target dev="vda" bus="virtio"/>
    </disk><disk type="block" device="disk">
      <driver name="qemu" type="raw"/>
      <source dev="/dev/sda" startupPolicy="optional"/>
      <target dev="vdb" bus="virtio"/>
    </disk><disk type="volume" device="disk">
      <driver name="qemu" type="raw"/>
      <source pool="images" volume="test" startupPolicy="optional"/>
      <target dev="vdc" bus="virtio"/>
    </disk><disk type="file" device="disk">
      <driver name="qemu" type="qcow2"/>
      <source file="/var/lib/libvirt/images/NODISK" startupPolicy="optional"/>
      <target dev="vdd" bus="virtio"/>
    </disk><disk type="block" device="disk">
      <driver name="qemu" type="raw"/>
      <source dev="/dev/NODISK" startupPolicy="optional"/>
      <target dev="vde" bus="virtio"/>
    </disk><disk type="volume" device="disk">
      <driver name="qemu" type="raw"/>
      <source pool="images" volume="NODISK" startupPolicy="optional"/>
      <target dev="vdg" bus="virtio"/>
    </disk>

➜  ~ virsh create rh85.xml
Domain 'rh85' created from rh85.xml

2. Check the live domain XML:
➜  ~ virsh dumpxml rh85|xmllint --xpath //disk -       
<disk type="file" device="disk">
      <driver name="qemu" type="qcow2"/>
      <source file="/var/lib/libvirt/images/RHEL-8.5-x86_64-latest.qcow2" startupPolicy="optional" index="5"/>
      <backingStore/>
      <target dev="vda" bus="virtio"/>
      <alias name="virtio-disk0"/>
      <address type="pci" domain="0x0000" bus="0x04" slot="0x00" function="0x0"/>
    </disk><disk type="block" device="disk">
      <driver name="qemu" type="raw"/>
      <source dev="/dev/sda" startupPolicy="optional" index="4"/>
      <backingStore/>
      <target dev="vdb" bus="virtio"/>
      <alias name="virtio-disk1"/>
      <address type="pci" domain="0x0000" bus="0x07" slot="0x00" function="0x0"/>
    </disk><disk type="volume" device="disk">
      <driver name="qemu" type="raw"/>
      <source pool="images" volume="test" startupPolicy="optional" index="3"/>
      <backingStore/>
      <target dev="vdc" bus="virtio"/>
      <alias name="virtio-disk2"/>
      <address type="pci" domain="0x0000" bus="0x08" slot="0x00" function="0x0"/>
    </disk>

VM started and the domain XML is expected.

Comment 11 Han Han 2022-06-30 08:41:23 UTC
Verified on libvirt-8.0.0-8.module+el8.7.0+15648+3854f89a.x86_64 qemu-kvm-6.2.0-16.module+el8.7.0+15743+c774064d.x86_64

Start VM with startupPolicy attribute for file/block/volume type disks.
<disk type="file" device="disk">
      <driver name="qemu" type="qcow2"/>
      <source file="/var/lib/libvirt/images/RHEL-8.5-x86_64-latest.qcow2" startupPolicy="optional"/>
      <target dev="vda" bus="virtio"/>
      <address type="pci" domain="0x0000" bus="0x04" slot="0x00" function="0x0"/>
    </disk><disk type="volume" device="disk">
      <driver name="qemu" type="raw"/>
      <source pool="netfs-gluster" volume="vol1" startupPolicy="optional"/>
      <target dev="vdb" bus="virtio"/>
      <address type="pci" domain="0x0000" bus="0x07" slot="0x00" function="0x0"/>
    </disk><disk type="block" device="disk">
      <driver name="qemu" type="raw"/>
      <source dev="/dev/sda" startupPolicy="optional"/>
      <target dev="vdc" bus="virtio"/>
      <address type="pci" domain="0x0000" bus="0x08" slot="0x00" function="0x0"/>
    </disk><disk type="volume" device="disk">
      <driver name="qemu" type="raw"/>
      <source pool="mapth" volume="dm-0" startupPolicy="optional"/>
      <target dev="vdd" bus="virtio"/>
      <address type="pci" domain="0x0000" bus="0x09" slot="0x00" function="0x0"/>
    </disk><disk type="volume" device="disk">
      <driver name="qemu" type="raw"/>
      <source pool="iscsi" volume="unit:0:0:0" startupPolicy="optional"/>
      <target dev="vde" bus="virtio"/>
      <address type="pci" domain="0x0000" bus="0x0a" slot="0x00" function="0x0"/>
    </disk>

VM started
PASS

Comment 17 errata-xmlrpc 2022-11-08 09:20:10 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 (Low: virt:rhel and virt-devel:rhel security, 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/RHSA-2022:7472


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