Bug 2037146

Summary: Better to report error when setting acpi index='0' in device
Product: Red Hat Enterprise Linux 9 Reporter: yafu <yafu>
Component: libvirtAssignee: Peter Krempa <pkrempa>
libvirt sub component: General QA Contact: yalzhang <yalzhang>
Status: CLOSED ERRATA Docs Contact:
Severity: unspecified    
Priority: unspecified CC: jdenemar, jtomko, pkrempa, virt-maint, xuzhang, yalzhang, yanqzhan
Version: 9.0Keywords: AutomationTriaged, Triaged
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-8.1.0-1.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-11-15 10:03:03 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version: 8.1.0
Embargoed:

Description yafu 2022-01-05 04:14:05 UTC
Description of problem:
Better to report error when setting acpi index='0' in device rather than ignore it.

Version-Release number of selected component (if applicable):
libvirt-7.10.0-1.el9.x86_64

How reproducible:
100%

Steps to Reproduce:
1.Edit acpi index='0' for interface device and save xml:
#virsh edit vm1
...
<interface type='network'>
      <mac address='52:54:00:11:3e:f2'/>
      <source network='default'/>
      <model type='virtio'/>
      ***<acpi index='0'/>***
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
...

2.Check guest xml and no acpi index setting:
#virsh dumpxml vm1 | grep -A8 interface
<interface type='network'>
      <mac address='52:54:00:11:3e:f2'/>
      <source network='default'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>


3.

Actual results:
Can set acpi index='0' in device successfully but will ignore it actually.

Expected results:
It's better to report error when setting acpi index='0' in device, such as:
Invalid value for attribute 'index' in element 'acpi': '0'

Additional info:

Comment 1 Peter Krempa 2022-01-18 14:52:17 UTC
The fix is simple enough so we can fix this cosmetic issue.

Comment 2 Peter Krempa 2022-01-19 15:58:43 UTC
Fixed upstream:

commit 6622e3cc33712450cc8bfdfb9a5a0b66e186e18d
Author: Peter Krempa <pkrempa>
Date:   Tue Jan 18 15:43:42 2022 +0100

    virDomainDeviceInfoParseXML: Reject '0' value for ACPI index
    
    Value of '0' is treated equivalently to when it's not provided by the
    user. Reject an explicit '0' provided by the user as it would get
    ignored.
    
    In this rare case we can make the XML parser more strict, as libvirt
    would never format the '<acpi/>' element if the index is '0' thus there
    are no libvirt-generated XMLs we'd not load back, as of such this is
    identical to rejecting it in the validation phase.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2037146
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Michal Privoznik <mprivozn>

v8.0.0-104-g6622e3cc33

Comment 3 yalzhang@redhat.com 2022-03-08 03:58:29 UTC
Test on libvirt-8.1.0-1.el9.x86_64, the result is as expected.
# virsh edit rhel
error: XML error: Invalid value for attribute 'index' in element 'acpi': Zero is not permitted
Failed. Try again? [y,n,i,f,?]:

Comment 6 yalzhang@redhat.com 2022-04-14 09:07:26 UTC
Test on libvirt-8.2.0-1.el9.x86_64:
# virsh edit rhel
<interface type='network'>
      <mac address='52:54:00:f5:aa:d5'/>
      <source network='default'/>
      <model type='e1000e'/>
      <acpi index='0'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </interface>

error: XML error: Invalid value for attribute 'index' in element 'acpi': Zero is not permitted
Failed. Try again? [y,n,i,f,?]: 

The result is as expected.

Comment 8 errata-xmlrpc 2022-11-15 10:03:03 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: libvirt 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:8003