misc: modify the generate logic of vcat config

The current code generate vcat info by count the CLOS MASK and the
scenario xml should set multiple times.

It is not an ideal solution, so we add an "virtual_cat_number" element
to set the virtual CLOS number and get the MAX pcbm directly.

Signed-off-by: Chenli Wei <chenli.wei@intel.com>
This commit is contained in:
Chenli Wei 2022-05-06 18:30:49 +08:00 committed by acrnsi-robot
parent a1b266f807
commit d5c0a40665
2 changed files with 21 additions and 10 deletions

View File

@ -336,6 +336,11 @@ Refer to :ref:`vuart_config` for detailed vUART settings.</xs:documentation>
<xs:documentation>Enable nested virtualization for KVM.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="virtual_cat_number" type="xs:integer" default="0" minOccurs="0">
<xs:annotation acrn:title="Maximum virtual CLOS" acrn:applicable-vms="pre-launched, post-launched" acrn:views="advanced">
<xs:documentation>Max number of virtual CLOS MASK</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="virtual_cat_support" type="Boolean" default="n" minOccurs="0">
<xs:annotation acrn:title="VM Virtual Cache Allocation Tech" acrn:applicable-vms="pre-launched, post-launched" acrn:views="advanced">
<xs:documentation>Enable virtualization of the Cache Allocation Technology (CAT) feature in RDT. CAT enables you to allocate cache to VMs, providing isolation to avoid performance interference from other VMs.</xs:documentation>

View File

@ -181,18 +181,24 @@
<xsl:value-of select="acrn:initializer('pclosids', concat('vm', ../@id, '_vcpu_clos'))" />
<xsl:variable name="vm_id" select="../@id" />
<xsl:value-of select="acrn:initializer('num_pclosids', concat(count(//allocation-data/acrn-config/vm[@id=$vm_id]/clos/vcpu_clos), 'U'))" />
<xsl:if test="acrn:is-vcat-enabled() and ../virtual_cat_support[text() = 'y']">
<xsl:variable name="rdt_res_str" select="acrn:get-normalized-closinfo-rdt-res-str()" />
<xsl:variable name="vm_name" select="../name/text()" />
<xsl:choose>
<xsl:when test="acrn:is-vcat-enabled() and ../virtual_cat_support[text() = 'y']">
<xsl:value-of select="acrn:initializer('num_pclosids', concat(count(//vm[@id=$vm_id]/virtual_cat_number), 'U'))" />
<xsl:variable name="rdt_res_str" select="acrn:get-normalized-closinfo-rdt-res-str()" />
<xsl:if test="contains($rdt_res_str, 'L2')">
<xsl:value-of select="acrn:initializer('max_l2_pcbm', concat(math:max(//allocation-data/acrn-config/vm[@id=$vm_id]/clos/vcpu_clos), 'U'))" />
</xsl:if>
<xsl:if test="contains($rdt_res_str, 'L2')">
<xsl:value-of select="acrn:initializer('max_l2_pcbm', //CACHE_ALLOCATION[CACHE_LEVEL='2']/POLICY[VM=$vm_name]/CLOS_MASK)" />
</xsl:if>
<xsl:if test="contains($rdt_res_str, 'L3')">
<xsl:value-of select="acrn:initializer('max_l3_pcbm', concat(math:max(//allocation-data/acrn-config/vm[@id=$vm_id]/clos/vcpu_clos), 'U'))" />
</xsl:if>
</xsl:if>
<xsl:if test="contains($rdt_res_str, 'L3')">
<xsl:value-of select="acrn:initializer('max_l3_pcbm', //CACHE_ALLOCATION[CACHE_LEVEL='3']/POLICY[VM=$vm_name]/CLOS_MASK)" />
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="acrn:initializer('num_pclosids', concat(count(//allocation-data/acrn-config/vm[@id=$vm_id]/clos/vcpu_clos), 'U'))" />
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="$endif" />
</xsl:template>