[PATCH v6 2/4] misc: define the MAX_VUART_NUM_PER_VM by offline tool


chenli.wei
 

The current code define MAX_VUART_NUM_PER_VM for all VM and it's a hard
code which can't match our vUART logic which need dynamic setting.

This patch move the define of MAX_VUART_NUM_PER_VM to offline tool and
calculate it automatically.

v5-->v6:
1.collect the number of vUART controllers of each VMs and calculate
the MAX to define MAX_VUART_NUM_PER_VM

Signed-off-by: Chenli Wei <chenli.wei@...>
---
misc/config_tools/xforms/vm_configurations.h.xsl | 16 ++++++++++++++++
1 file changed, 16 insertions(+)

diff --git a/misc/config_tools/xforms/vm_configurations.h.xsl b/misc/config_tools/xforms/vm_configurations.h.xsl
index b596ef692..0758ff42f 100644
--- a/misc/config_tools/xforms/vm_configurations.h.xsl
+++ b/misc/config_tools/xforms/vm_configurations.h.xsl
@@ -9,6 +9,7 @@
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dyn="http://exslt.org/dynamic"
xmlns:math="http://exslt.org/math"
+ xmlns:str="http://exslt.org/strings"
xmlns:acrn="http://projectacrn.org">
<xsl:include href="lib.xsl" />
<xsl:output method="text" />
@@ -32,6 +33,21 @@
<xsl:template match="config-data/acrn-config">
<xsl:call-template name="vm_count" />
<xsl:call-template name="sos_vm_bootarges" />
+ <xsl:call-template name="vm_vuart_num" />
+ </xsl:template>
+
+ <xsl:template name ="vm_vuart_num">
+ <xsl:variable name="vuart_nums">
+ <xsl:for-each select = "//config-data//vm">
+ <xsl:variable name = "vm_name" select = "./name/text()" />
+ <xsl:variable name = "vuart_num" select = "count(//endpoint[vm_name = $vm_name]) + 1" />
+ <xsl:value-of select = "$vuart_num" />
+ <xsl:if test = "position() != last()">
+ <xsl:value-of select = "concat(',', ' ')" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+ <xsl:value-of select = "acrn:define('MAX_VUART_NUM_PER_VM', math:max(str:split($vuart_nums, ',')), 'U')" />
</xsl:template>

<xsl:template name ="vm_count">
--
2.17.1


Junjie Mao
 

Chenli Wei <chenli.wei@...> writes:

The current code define MAX_VUART_NUM_PER_VM for all VM and it's a hard
code which can't match our vUART logic which need dynamic setting.

This patch move the define of MAX_VUART_NUM_PER_VM to offline tool and
calculate it automatically.

v5-->v6:
1.collect the number of vUART controllers of each VMs and calculate
the MAX to define MAX_VUART_NUM_PER_VM

Signed-off-by: Chenli Wei <chenli.wei@...>
Reviewed-by: Junjie Mao <junjie.mao@...>

One minor comment below.

---
misc/config_tools/xforms/vm_configurations.h.xsl | 16 ++++++++++++++++
1 file changed, 16 insertions(+)

diff --git a/misc/config_tools/xforms/vm_configurations.h.xsl b/misc/config_tools/xforms/vm_configurations.h.xsl
index b596ef692..0758ff42f 100644
--- a/misc/config_tools/xforms/vm_configurations.h.xsl
+++ b/misc/config_tools/xforms/vm_configurations.h.xsl
@@ -9,6 +9,7 @@
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dyn="http://exslt.org/dynamic"
xmlns:math="http://exslt.org/math"
+ xmlns:str="http://exslt.org/strings"
xmlns:acrn="http://projectacrn.org">
<xsl:include href="lib.xsl" />
<xsl:output method="text" />
@@ -32,6 +33,21 @@
<xsl:template match="config-data/acrn-config">
<xsl:call-template name="vm_count" />
<xsl:call-template name="sos_vm_bootarges" />
+ <xsl:call-template name="vm_vuart_num" />
+ </xsl:template>
+
+ <xsl:template name ="vm_vuart_num">
+ <xsl:variable name="vuart_nums">
+ <xsl:for-each select = "//config-data//vm">
+ <xsl:variable name = "vm_name" select = "./name/text()" />
+ <xsl:variable name = "vuart_num" select = "count(//endpoint[vm_name = $vm_name]) + 1" />
+ <xsl:value-of select = "$vuart_num" />
+ <xsl:if test = "position() != last()">
+ <xsl:value-of select = "concat(',', ' ')" />
Why do you need `concat` here? A single ',' should do the trick.

--
Best Regards
Junjie Mao

+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+ <xsl:value-of select = "acrn:define('MAX_VUART_NUM_PER_VM', math:max(str:split($vuart_nums, ',')), 'U')" />
</xsl:template>

<xsl:template name ="vm_count">


chenli.wei
 

On 5/12/2022 4:51 PM, Junjie Mao wrote:
Chenli Wei <chenli.wei@...> writes:

The current code define MAX_VUART_NUM_PER_VM for all VM and it's a hard
code which can't match our vUART logic which need dynamic setting.

This patch move the define of MAX_VUART_NUM_PER_VM to offline tool and
calculate it automatically.

v5-->v6:
1.collect the number of vUART controllers of each VMs and calculate
the MAX to define MAX_VUART_NUM_PER_VM

Signed-off-by: Chenli Wei <chenli.wei@...>
Reviewed-by: Junjie Mao <junjie.mao@...>

One minor comment below.

---
misc/config_tools/xforms/vm_configurations.h.xsl | 16 ++++++++++++++++
1 file changed, 16 insertions(+)

diff --git a/misc/config_tools/xforms/vm_configurations.h.xsl b/misc/config_tools/xforms/vm_configurations.h.xsl
index b596ef692..0758ff42f 100644
--- a/misc/config_tools/xforms/vm_configurations.h.xsl
+++ b/misc/config_tools/xforms/vm_configurations.h.xsl
@@ -9,6 +9,7 @@
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dyn="http://exslt.org/dynamic"
xmlns:math="http://exslt.org/math"
+ xmlns:str="http://exslt.org/strings"
xmlns:acrn="http://projectacrn.org">
<xsl:include href="lib.xsl" />
<xsl:output method="text" />
@@ -32,6 +33,21 @@
<xsl:template match="config-data/acrn-config">
<xsl:call-template name="vm_count" />
<xsl:call-template name="sos_vm_bootarges" />
+ <xsl:call-template name="vm_vuart_num" />
+ </xsl:template>
+
+ <xsl:template name ="vm_vuart_num">
+ <xsl:variable name="vuart_nums">
+ <xsl:for-each select = "//config-data//vm">
+ <xsl:variable name = "vm_name" select = "./name/text()" />
+ <xsl:variable name = "vuart_num" select = "count(//endpoint[vm_name = $vm_name]) + 1" />
+ <xsl:value-of select = "$vuart_num" />
+ <xsl:if test = "position() != last()">
+ <xsl:value-of select = "concat(',', ' ')" />
Why do you need `concat` here? A single ',' should do the trick.
OK, I will change it.