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 2121627 - define vm with invalid pcie-root-target chassis -1 should failed
Summary: define vm with invalid pcie-root-target chassis -1 should failed
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: libvirt
Version: unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Peter Krempa
QA Contact: Meina Li
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-08-26 03:49 UTC by zhentang
Modified: 2023-05-09 08:08 UTC (History)
7 users (show)

Fixed In Version: libvirt-8.8.0-1.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-05-09 07:27:05 UTC
Type: Bug
Target Upstream Version: 8.8.0
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-132403 0 None None None 2022-08-26 03:51:49 UTC
Red Hat Product Errata RHBA-2023:2171 0 None None None 2023-05-09 07:27:29 UTC

Description zhentang 2022-08-26 03:49:59 UTC
Description of problem:
define vm with invalid pcie-root-target chassis -1  should failed

Version-Release number of selected component (if applicable):
libvirt-8.5.0-5.el9

How reproducible:
100%

Steps to Reproduce:
1. prepare guest xml
...
<controller type='pci' index='1' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='-1' port='0x10'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x00' function='0x0' multifunction='on'/>
    </controller>
...
2. devine vm
# virsh define pcitest.xml
Domain 'rhel9.0-2' defined from pcitest.xml

# virsh dumpxml rhel9.0-2
...
 <controller type='pci' index='1' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='1' port='0x10'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x6'/>
    </controller>
...

Actual results:
VM define successful which is unexpected


Expected results:
VM define should fail with error message
error: XML error: PCI controller chassis '-1' out of range - must be 0-255



Additional info:
when define with chassis='-2', it would be failed with error message as expected
...
<controller type='pci' index='1' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='-2' port='0x10'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x00' function='0x0' multifunction='on'/>
    </controller>
...

# virsh define pcitest.xml
error: Failed to define domain from pcitest.xml
error: unsupported configuration: PCI controller chassis '-2' out of range - must be 0-255

Comment 1 Peter Krempa 2022-08-26 08:36:13 UTC
The root cause is that the '-1' value is internally used to signify that the 'chassis' (and 'chassisnNr') field was not specified by the user and a default should be filled in.

The validator is unable to distinguish those cases so we'll probably ned to handle negative values in the parser.

Comment 2 Peter Krempa 2022-09-01 11:25:08 UTC
Fixed upstream:

commit 03c908bf9cd34a7ef8c46db0d29cf1750b682d4a
Author: Peter Krempa <pkrempa>
Date:   Fri Aug 26 14:02:52 2022 +0200

    virDomainControllerDefParseXML: Reject '-1' for PCI controller target properties
    
    All of the properties use '-1' as default and the code omits formatting
    them when the property is '-1'. Additionally subsequent validation code
    rejects all other negative values anyways.
    
    Since we've never formatted '-1' into an XML formatted by libvirt we can
    make the parser more strict, as we will never fail to parse existing
    on-disk libvirt-owned XMLs.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2121627
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Ján Tomko <jtomko>

v8.7.0-37-g03c908bf9c

Comment 3 Meina Li 2022-10-10 09:41:27 UTC
Test Version:
libvirt-8.8.0-1.el9.x86_64

Test Step:
1. Edit a guest with chassis='-1':
......
   <controller type='pci' index='1' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='-1' port='0x10'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0' multifunction='on'/>
    </controller>
......

2. Save and get an expected error:
# virsh edit rhel
error: XML document failed to validate against schema: Unable to validate doc against /usr/share/libvirt/schemas/domain.rng
Extra element devices in interleave
Element domain failed to validate content
avocado-vt-vm1
Failed. Try again? [y,n,i,f,?]: 
error: XML error: Invalid value for attribute 'chassis' in element 'target': '-1'. Expected non-negative value

Comment 7 Meina Li 2022-11-09 03:14:22 UTC
Test Version:
libvirt-8.9.0-2.el9.x86_64
qemu-kvm-7.1.0-4.el9.x86_64

Test Steps:
1. Prepare pcie-root-port, pcie-expander-bus, pcie-to-pci-bridge and pci-bridge controller.
2. Define the guest with invalid value.
# virsh define test.xml 
error: Failed to define domain from test.xml
error: XML error: Invalid value for attribute 'chassis' in element 'target': '-1'. Expected non-negative value

# virsh define test.xml 
error: Failed to define domain from test.xml
error: XML error: Invalid value for attribute 'port' in element 'target': '-1'. Expected non-negative value

# virsh define test.xml 
error: Failed to define domain from test.xml
error: XML error: Invalid value for attribute 'busNr' in element 'target': '-1'. Expected non-negative value

# virsh define test.xml 
error: Failed to define domain from test.xml
error: XML error: Invalid value for attribute 'chassisNr' in element 'target': '-1'. Expected non-negative value

Comment 9 errata-xmlrpc 2023-05-09 07:27:05 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 (libvirt 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-2023:2171


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