config_tools: move RDT-related checks to a separate file

Assertions in XML schema are placed under schema/checks as the central
place, in order to make it easier to enhance the error reporting
specifically on assertion failures in the near future.

This patch moves the RDT related assertions in the schema to a dedicate
file uner schema/checks.

Tracked-On: #6690
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
Junjie Mao 2022-02-11 23:12:39 +08:00 committed by acrnsi-robot
parent 6750d5a277
commit 74071d1bd4
2 changed files with 86 additions and 80 deletions

View File

@ -0,0 +1,86 @@
<?xml version="1.0"?>
<xs:schema xml:id="root"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:acrn="https://projectacrn.org">
<xs:assert test="if (//VCAT_ENABLED = 'y')
then (//CDP_ENABLED = 'n' and //RDT_ENABLED = 'y')
else true()">
<xs:annotation>
<xs:documentation>vCAT can be enabled only when RDT_ENABLED is 'y' and CDP_ENABLED is 'n'</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="if (count(//virtual_cat_support[text() = 'y']) > 0)
then //RDT_ENABLED = 'y' and //VCAT_ENABLED = 'y'
else true()">
<xs:annotation>
<xs:documentation>Per VM virtual_cat_support can be set only when RDT_ENABLED is 'y' and VCAT_ENABLED is 'y'.</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="every $vm in vm satisfies
(
if (//RDT_ENABLED = 'y' and //VCAT_ENABLED = 'y' and $vm/virtual_cat_support[text() = 'y'])
then count($vm/clos/vcpu_clos) > 1
else true()
)
">
<xs:annotation>
<xs:documentation>For a vCAT VM, number of clos/vcpu_clos elements must be greater than 1!</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="if (//RDT_ENABLED = 'y' and //VCAT_ENABLED = 'y')
then count(vm[virtual_cat_support[text() = 'y'] and count(clos/vcpu_clos[. = 0])]) = 0
else true()">
<xs:annotation>
<xs:documentation>For a vCAT VM, vcpu_clos cannot be set to CLOSID 0, CLOSID 0 is reserved to be used by hypervisor</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="every $vm in vm satisfies
(
if (//RDT_ENABLED = 'y' and //VCAT_ENABLED = 'y' and $vm/virtual_cat_support[text() = 'y'])
then count($vm[clos/vcpu_clos[. &gt;= count($vm/..//CLOS_MASK)]]) = 0
else true()
)
">
<xs:annotation>
<xs:documentation>For a vCAT VM, each clos/vcpu_clos must be less than L2/L3 COS_MAX!</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="every $vm in vm satisfies
(
if (//RDT_ENABLED = 'y' and //VCAT_ENABLED = 'y' and $vm/virtual_cat_support[text() = 'y'])
then count($vm/clos/vcpu_clos) = count(distinct-values($vm/clos/vcpu_clos))
else true()
)
">
<xs:annotation>
<xs:documentation>For a vCAT VM, its clos/vcpu_clos elements cannot contain duplicate values</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="every $vm1 in vm, $vm2 in $vm1/following-sibling::vm satisfies
(
if (//RDT_ENABLED = 'y' and //VCAT_ENABLED = 'y' and ($vm1/virtual_cat_support[text() = 'y'] or $vm2/virtual_cat_support[text() = 'y']))
then count($vm1/clos/vcpu_clos[. = $vm2/clos/vcpu_clos]) = 0
else true()
)
">
<xs:annotation>
<xs:documentation>if RDT_ENABLED is 'y', there should not be any CLOS IDs overlap between a vCAT VM and any other VMs</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="every $vm in //vm satisfies $vm//load_order != 'SERVICE_VM' or count($vm//lapic_passthrough[text() = 'y']) = 0 or count(//nested_virtualization_support[text() = 'y']) > 0">
<xs:annotation>
<xs:documentation>Service VM cannot use LAPIC passthrough unless GUEST_FLAG_NVMX_ENABLED is set.</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="not (//hv//RDT/RDT_ENABLED = 'y' and //hv//SSRAM/SSRAM_ENABLED = 'y')"/>
</xs:schema>

View File

@ -153,7 +153,6 @@ Machine Check Error on Page Size Change.</xs:documentation>
</xs:annotation> </xs:annotation>
</xs:element> </xs:element>
</xs:all> </xs:all>
<xs:assert test="not (RDT/RDT_ENABLED = 'y' and SSRAM/SSRAM_ENABLED = 'y')"/>
</xs:complexType> </xs:complexType>
<xs:complexType name="MemoryOptionsType"> <xs:complexType name="MemoryOptionsType">
@ -440,12 +439,6 @@ its ``id`` attribute.</xs:documentation>
</xs:element> </xs:element>
</xs:all> </xs:all>
<xs:attribute name="id" type="xs:integer" /> <xs:attribute name="id" type="xs:integer" />
<xs:assert test="load_order != 'SERVICE_VM' or count(//lapic_passthrough[text() = 'y']) = 0 or count(//nested_virtualization_support[text() = 'y']) > 0">
<xs:annotation>
<xs:documentation>Service VM cannot use LAPIC passthrough unless nested_virtualization_support is set.</xs:documentation>
</xs:annotation>
</xs:assert>
</xs:complexType> </xs:complexType>
<xs:complexType name="ACRNConfigType"> <xs:complexType name="ACRNConfigType">
@ -469,79 +462,6 @@ to launch post-launched User VMs.</xs:documentation>
</xs:all> </xs:all>
<xs:attribute name="board" type="xs:string" use="required" /> <xs:attribute name="board" type="xs:string" use="required" />
<xs:attribute name="scenario" type="xs:string" use="required" /> <xs:attribute name="scenario" type="xs:string" use="required" />
<xs:assert test="if (//VCAT_ENABLED = 'y')
then (//CDP_ENABLED = 'n' and //RDT_ENABLED = 'y')
else true()">
<xs:annotation>
<xs:documentation>vCAT can be enabled only when RDT_ENABLED is 'y' and CDP_ENABLED is 'n'</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="if (count(//virtual_cat_support[text() = 'y']) > 0)
then //RDT_ENABLED = 'y' and //VCAT_ENABLED = 'y'
else true()">
<xs:annotation>
<xs:documentation>Per VM virtual_cat_support can be set only when RDT_ENABLED is 'y' and VCAT_ENABLED is 'y'.</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="every $vm in vm satisfies
(
if (//RDT_ENABLED = 'y' and //VCAT_ENABLED = 'y' and $vm/virtual_cat_support[text() = 'y'])
then count($vm/clos/vcpu_clos) > 1
else true()
)
">
<xs:annotation>
<xs:documentation>For a vCAT VM, number of clos/vcpu_clos elements must be greater than 1!</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="if (//RDT_ENABLED = 'y' and //VCAT_ENABLED = 'y')
then count(vm[virtual_cat_support[text() = 'y'] and count(clos/vcpu_clos[. = 0])]) = 0
else true()">
<xs:annotation>
<xs:documentation>For a vCAT VM, vcpu_clos cannot be set to CLOSID 0, CLOSID 0 is reserved to be used by hypervisor</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="every $vm in vm satisfies
(
if (//RDT_ENABLED = 'y' and //VCAT_ENABLED = 'y' and $vm/virtual_cat_support[text() = 'y'])
then count($vm[clos/vcpu_clos[. &gt;= count($vm/..//CLOS_MASK)]]) = 0
else true()
)
">
<xs:annotation>
<xs:documentation>For a vCAT VM, each clos/vcpu_clos must be less than L2/L3 COS_MAX!</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="every $vm in vm satisfies
(
if (//RDT_ENABLED = 'y' and //VCAT_ENABLED = 'y' and $vm/virtual_cat_support[text() = 'y'])
then count($vm/clos/vcpu_clos) = count(distinct-values($vm/clos/vcpu_clos))
else true()
)
">
<xs:annotation>
<xs:documentation>For a vCAT VM, its clos/vcpu_clos elements cannot contain duplicate values</xs:documentation>
</xs:annotation>
</xs:assert>
<xs:assert test="every $vm1 in vm, $vm2 in $vm1/following-sibling::vm satisfies
(
if (//RDT_ENABLED = 'y' and //VCAT_ENABLED = 'y' and ($vm1/virtual_cat_support[text() = 'y'] or $vm2/virtual_cat_support[text() = 'y']))
then count($vm1/clos/vcpu_clos[. = $vm2/clos/vcpu_clos]) = 0
else true()
)
">
<xs:annotation>
<xs:documentation>if RDT_ENABLED is 'y', there should not be any CLOS IDs overlap between a vCAT VM and any other VMs</xs:documentation>
</xs:annotation>
</xs:assert>
</xs:complexType> </xs:complexType>
<xs:element name="acrn-config" type="ACRNConfigType"> <xs:element name="acrn-config" type="ACRNConfigType">