[PATCH v2 2/2] misc: modify the generate logic of vcat config


chenli.wei
 

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@...>
---
misc/config_tools/schema/config.xsd | 5 ++++
.../xforms/vm_configurations.c.xsl | 26 ++++++++++++-------
2 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/misc/config_tools/schema/config.xsd b/misc/config_tools/schema/config.xsd
index 68cc575c6..4182586cf 100644
--- a/misc/config_tools/schema/config.xsd
+++ b/misc/config_tools/schema/config.xsd
@@ -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>
diff --git a/misc/config_tools/xforms/vm_configurations.c.xsl b/misc/config_tools/xforms/vm_configurations.c.xsl
index b16565961..b2741741d 100644
--- a/misc/config_tools/xforms/vm_configurations.c.xsl
+++ b/misc/config_tools/xforms/vm_configurations.c.xsl
@@ -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>
--
2.17.1