Date   

Re: [PATCH] misc: add assert for vUART connection

Junjie Mao
 

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

The current UI have no live-check to check whether a VM connect to
itself.

So we add an assert to the schema and return error when user connect a
VM to itself.

Signed-off-by: Chenli Wei <chenli.wei@...>
---
.../config_tools/schema/checks/vuart_config.xsd | 17 +++++++++++++++++
misc/config_tools/schema/datachecks.xsd | 1 +
2 files changed, 18 insertions(+)
create mode 100644 misc/config_tools/schema/checks/vuart_config.xsd

diff --git a/misc/config_tools/schema/checks/vuart_config.xsd b/misc/config_tools/schema/checks/vuart_config.xsd
new file mode 100644
index 000000000..511075d92
--- /dev/null
+++ b/misc/config_tools/schema/checks/vuart_config.xsd
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<!-- Copyright (C) 2022 Intel Corporation. -->
+<!-- SPDX-License-Identifier: BSD-3-Clause -->
+
+<xs:schema xml:id="root"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:acrn="https://projectacrn.org">
+
+ <xs:assert test="every $vuart_connection in /acrn-config//vuart_connection satisfies
+ every $vm_name in $vuart_connection/endpoint/vm_name/text() satisfies
+ count($vuart_connection/endpoint[./vm_name/text()=$vm_name]) = 1">
+ <xs:annotation acrn:severity="error" acrn:report-on="$vuart_connection/name">
+ <xs:documentation>vuart_connection "{$vm_name}" can't connected to itself</xs:documentation>
`vm_name` is not the name of the vUART connection.

--
Best Regards
Junjie Mao

+ </xs:annotation>
+ </xs:assert>
+
+</xs:schema>
diff --git a/misc/config_tools/schema/datachecks.xsd b/misc/config_tools/schema/datachecks.xsd
index f8c934eda..fc9badf53 100644
--- a/misc/config_tools/schema/datachecks.xsd
+++ b/misc/config_tools/schema/datachecks.xsd
@@ -14,6 +14,7 @@
<xi:include href="checks/vbdf_assignment.xsd" xpointer="xpointer(id('root')/*)" />
<xi:include href="checks/vm_types.xsd" xpointer="xpointer(id('root')/*)" />
<xi:include href="checks/passthrough_devices.xsd" xpointer="xpointer(id('root')/*)" />
+ <xi:include href="checks/vuart_config.xsd" xpointer="xpointer(id('root')/*)" />

</xs:complexType>
</xs:element>


Re: [PATCH v3] config_tools: format vitio input in configurator

Junjie Mao
 

Kunhui-Li <kunhuix.li@...> writes:

This patch formats virtio input entry as "Device name: xxx, Device physical path: xxx".

v2-->v3:
1. remove the exception handler of enum in pyodide/loadBoard.py.
3. update the `acrn:options-sorted-by` function for virtio input.

v1-->v2:
use XPATH instead of the specific python code to parse virtio input data.

Tracked-On: #6691
Signed-off-by: Kunhui-Li <kunhuix.li@...>
Reviewed-by: Junjie Mao <junjie.mao@...>

--
Best Regards
Junjie Mao

---
misc/config_tools/schema/VMtypes.xsd | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/misc/config_tools/schema/VMtypes.xsd b/misc/config_tools/schema/VMtypes.xsd
index 302e152b6..91fd76cd6 100644
--- a/misc/config_tools/schema/VMtypes.xsd
+++ b/misc/config_tools/schema/VMtypes.xsd
@@ -395,7 +395,9 @@ device file when user config it as virtio serial port, which can be read and wri
<xs:complexType name="VirtioInputConfiguration">
<xs:sequence>
<xs:element name="backend_device_file" type="xs:string" minOccurs="0">
- <xs:annotation acrn:title="Backend device file" acrn:widget-options="'placeholder': '/dev/input/eventX'">
+ <xs:annotation acrn:title="Backend device file" acrn:widget-options="'placeholder': '/dev/input/eventX'"
+ acrn:options="for $input in //inputs/input return concat('Device name: ', $input/name/text(), ', Device physical path: ', $input/phys/text())"
+ acrn:options-sorted-by="lambda s: s">
<xs:documentation>Specifying backend device in service vm with device description.</xs:documentation>
</xs:annotation>
</xs:element>


[PATCH v3] config_tools: format vitio input in configurator

Kunhui Li
 

This patch formats virtio input entry as "Device name: xxx, Device physical path: xxx".

v2-->v3:
1. remove the exception handler of enum in pyodide/loadBoard.py.
3. update the `acrn:options-sorted-by` function for virtio input.

v1-->v2:
use XPATH instead of the specific python code to parse virtio input data.

Tracked-On: #6691
Signed-off-by: Kunhui-Li <kunhuix.li@...>
---
misc/config_tools/schema/VMtypes.xsd | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/misc/config_tools/schema/VMtypes.xsd b/misc/config_tools/schema/VMtypes.xsd
index 302e152b6..91fd76cd6 100644
--- a/misc/config_tools/schema/VMtypes.xsd
+++ b/misc/config_tools/schema/VMtypes.xsd
@@ -395,7 +395,9 @@ device file when user config it as virtio serial port, which can be read and wri
<xs:complexType name="VirtioInputConfiguration">
<xs:sequence>
<xs:element name="backend_device_file" type="xs:string" minOccurs="0">
- <xs:annotation acrn:title="Backend device file" acrn:widget-options="'placeholder': '/dev/input/eventX'">
+ <xs:annotation acrn:title="Backend device file" acrn:widget-options="'placeholder': '/dev/input/eventX'"
+ acrn:options="for $input in //inputs/input return concat('Device name: ', $input/name/text(), ', Device physical path: ', $input/phys/text())"
+ acrn:options-sorted-by="lambda s: s">
<xs:documentation>Specifying backend device in service vm with device description.</xs:documentation>
</xs:annotation>
</xs:element>
--
2.25.1


Re: [PATCH v2] config_tools: format vitio input in configurator

Kunhui Li
 

-----Original Message-----
From: Mao, Junjie <junjie.mao@...>
Sent: Monday, May 16, 2022 5:02 PM
To: Li, KunhuiX <kunhuix.li@...>
Cc: acrn-dev@...; Xie, Nanlin <nanlin.xie@...>; Sun, Victor <victor.sun@...>
Subject: Re: [PATCH v2] config_tools: format vitio input in configurator

Kunhui-Li <kunhuix.li@...> writes:

This patch formats virtio input entry as "Device name: xxx, Device physical path: xxx".

v1-->v2:
use XPATH instead of the specific python code to parse virtio input data.

Tracked-On: #6691
Signed-off-by: Kunhui-Li <kunhuix.li@...>
---
misc/config_tools/configurator/pyodide/loadBoard.py | 6 +++++-
misc/config_tools/schema/VMtypes.xsd | 4 +++-
2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/misc/config_tools/configurator/pyodide/loadBoard.py b/misc/config_tools/configurator/pyodide/loadBoard.py
index 48bb02715..dc44ad7fe 100644
--- a/misc/config_tools/configurator/pyodide/loadBoard.py
+++ b/misc/config_tools/configurator/pyodide/loadBoard.py
@@ -2,6 +2,7 @@
__package__ = 'configurator.pyodide'

import json
+import logging
from copy import deepcopy

import elementpath
@@ -42,7 +43,10 @@ def get_dynamic_scenario(board):
# get enum data
enum = function(source, selector, obj_type)
if sorted_func:
- enum = sorted(enum, key=eval(sorted_func))
+ try:
+ enum = sorted(enum, key=eval(sorted_func))
+ except IndexError as e:
+ logging.warning(e)
Recommend to get rid of this because the logging module is not
initialized in pyodide for now.
Will remove it.

return enum

def dynamic_enum_apply(obj):
diff --git a/misc/config_tools/schema/VMtypes.xsd b/misc/config_tools/schema/VMtypes.xsd
index 302e152b6..d7b1985e2 100644
--- a/misc/config_tools/schema/VMtypes.xsd
+++ b/misc/config_tools/schema/VMtypes.xsd
@@ -395,7 +395,9 @@ device file when user config it as virtio serial port, which can be read and wri
<xs:complexType name="VirtioInputConfiguration">
<xs:sequence>
<xs:element name="backend_device_file" type="xs:string" minOccurs="0">
- <xs:annotation acrn:title="Backend device file" acrn:widget-options="'placeholder': '/dev/input/eventX'">
+ <xs:annotation acrn:title="Backend device file" acrn:widget-options="'placeholder': '/dev/input/eventX'"
+ acrn:options="for $input in //inputs/input return concat('Device name: ', $input/name/text(), ', Device physical path: ',
$input/phys/text())"
+ acrn:options-sorted-by="lambda s: (s.split('Device name: ')[1].split(', Device physical path')[0], s.split('Device physical path:
')[1])">

How is this sorting function different from sorting by `s` itself?
It's same with the function "lambda s: s"...
will update.

--
Best Regards
Junjie Mao

<xs:documentation>Specifying backend device in service vm with device description.</xs:documentation>
</xs:annotation>
</xs:element>


[PATCH] misc: add assert for vUART connection

chenli.wei
 

The current UI have no live-check to check whether a VM connect to
itself.

So we add an assert to the schema and return error when user connect a
VM to itself.

Signed-off-by: Chenli Wei <chenli.wei@...>
---
.../config_tools/schema/checks/vuart_config.xsd | 17 +++++++++++++++++
misc/config_tools/schema/datachecks.xsd | 1 +
2 files changed, 18 insertions(+)
create mode 100644 misc/config_tools/schema/checks/vuart_config.xsd

diff --git a/misc/config_tools/schema/checks/vuart_config.xsd b/misc/config_tools/schema/checks/vuart_config.xsd
new file mode 100644
index 000000000..511075d92
--- /dev/null
+++ b/misc/config_tools/schema/checks/vuart_config.xsd
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<!-- Copyright (C) 2022 Intel Corporation. -->
+<!-- SPDX-License-Identifier: BSD-3-Clause -->
+
+<xs:schema xml:id="root"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:acrn="https://projectacrn.org">
+
+ <xs:assert test="every $vuart_connection in /acrn-config//vuart_connection satisfies
+ every $vm_name in $vuart_connection/endpoint/vm_name/text() satisfies
+ count($vuart_connection/endpoint[./vm_name/text()=$vm_name]) = 1">
+ <xs:annotation acrn:severity="error" acrn:report-on="$vuart_connection/name">
+ <xs:documentation>vuart_connection "{$vm_name}" can't connected to itself</xs:documentation>
+ </xs:annotation>
+ </xs:assert>
+
+</xs:schema>
diff --git a/misc/config_tools/schema/datachecks.xsd b/misc/config_tools/schema/datachecks.xsd
index f8c934eda..fc9badf53 100644
--- a/misc/config_tools/schema/datachecks.xsd
+++ b/misc/config_tools/schema/datachecks.xsd
@@ -14,6 +14,7 @@
<xi:include href="checks/vbdf_assignment.xsd" xpointer="xpointer(id('root')/*)" />
<xi:include href="checks/vm_types.xsd" xpointer="xpointer(id('root')/*)" />
<xi:include href="checks/passthrough_devices.xsd" xpointer="xpointer(id('root')/*)" />
+ <xi:include href="checks/vuart_config.xsd" xpointer="xpointer(id('root')/*)" />

</xs:complexType>
</xs:element>
--
2.17.1


Re: [PATCH v2] config_tools: format vitio input in configurator

Junjie Mao
 

Kunhui-Li <kunhuix.li@...> writes:

This patch formats virtio input entry as "Device name: xxx, Device physical path: xxx".

v1-->v2:
use XPATH instead of the specific python code to parse virtio input data.

Tracked-On: #6691
Signed-off-by: Kunhui-Li <kunhuix.li@...>
---
misc/config_tools/configurator/pyodide/loadBoard.py | 6 +++++-
misc/config_tools/schema/VMtypes.xsd | 4 +++-
2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/misc/config_tools/configurator/pyodide/loadBoard.py b/misc/config_tools/configurator/pyodide/loadBoard.py
index 48bb02715..dc44ad7fe 100644
--- a/misc/config_tools/configurator/pyodide/loadBoard.py
+++ b/misc/config_tools/configurator/pyodide/loadBoard.py
@@ -2,6 +2,7 @@
__package__ = 'configurator.pyodide'

import json
+import logging
from copy import deepcopy

import elementpath
@@ -42,7 +43,10 @@ def get_dynamic_scenario(board):
# get enum data
enum = function(source, selector, obj_type)
if sorted_func:
- enum = sorted(enum, key=eval(sorted_func))
+ try:
+ enum = sorted(enum, key=eval(sorted_func))
+ except IndexError as e:
+ logging.warning(e)
Recommend to get rid of this because the logging module is not
initialized in pyodide for now.

return enum

def dynamic_enum_apply(obj):
diff --git a/misc/config_tools/schema/VMtypes.xsd b/misc/config_tools/schema/VMtypes.xsd
index 302e152b6..d7b1985e2 100644
--- a/misc/config_tools/schema/VMtypes.xsd
+++ b/misc/config_tools/schema/VMtypes.xsd
@@ -395,7 +395,9 @@ device file when user config it as virtio serial port, which can be read and wri
<xs:complexType name="VirtioInputConfiguration">
<xs:sequence>
<xs:element name="backend_device_file" type="xs:string" minOccurs="0">
- <xs:annotation acrn:title="Backend device file" acrn:widget-options="'placeholder': '/dev/input/eventX'">
+ <xs:annotation acrn:title="Backend device file" acrn:widget-options="'placeholder': '/dev/input/eventX'"
+ acrn:options="for $input in //inputs/input return concat('Device name: ', $input/name/text(), ', Device physical path: ', $input/phys/text())"
+ acrn:options-sorted-by="lambda s: (s.split('Device name: ')[1].split(', Device physical path')[0], s.split('Device physical path: ')[1])">
How is this sorting function different from sorting by `s` itself?

--
Best Regards
Junjie Mao

<xs:documentation>Specifying backend device in service vm with device description.</xs:documentation>
</xs:annotation>
</xs:element>


[PATCH v2] config_tools: format vitio input in configurator

Kunhui Li
 

This patch formats virtio input entry as "Device name: xxx, Device physical path: xxx".

v1-->v2:
use XPATH instead of the specific python code to parse virtio input data.

Tracked-On: #6691
Signed-off-by: Kunhui-Li <kunhuix.li@...>
---
misc/config_tools/configurator/pyodide/loadBoard.py | 6 +++++-
misc/config_tools/schema/VMtypes.xsd | 4 +++-
2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/misc/config_tools/configurator/pyodide/loadBoard.py b/misc/config_tools/configurator/pyodide/loadBoard.py
index 48bb02715..dc44ad7fe 100644
--- a/misc/config_tools/configurator/pyodide/loadBoard.py
+++ b/misc/config_tools/configurator/pyodide/loadBoard.py
@@ -2,6 +2,7 @@
__package__ = 'configurator.pyodide'

import json
+import logging
from copy import deepcopy

import elementpath
@@ -42,7 +43,10 @@ def get_dynamic_scenario(board):
# get enum data
enum = function(source, selector, obj_type)
if sorted_func:
- enum = sorted(enum, key=eval(sorted_func))
+ try:
+ enum = sorted(enum, key=eval(sorted_func))
+ except IndexError as e:
+ logging.warning(e)
return enum

def dynamic_enum_apply(obj):
diff --git a/misc/config_tools/schema/VMtypes.xsd b/misc/config_tools/schema/VMtypes.xsd
index 302e152b6..d7b1985e2 100644
--- a/misc/config_tools/schema/VMtypes.xsd
+++ b/misc/config_tools/schema/VMtypes.xsd
@@ -395,7 +395,9 @@ device file when user config it as virtio serial port, which can be read and wri
<xs:complexType name="VirtioInputConfiguration">
<xs:sequence>
<xs:element name="backend_device_file" type="xs:string" minOccurs="0">
- <xs:annotation acrn:title="Backend device file" acrn:widget-options="'placeholder': '/dev/input/eventX'">
+ <xs:annotation acrn:title="Backend device file" acrn:widget-options="'placeholder': '/dev/input/eventX'"
+ acrn:options="for $input in //inputs/input return concat('Device name: ', $input/name/text(), ', Device physical path: ', $input/phys/text())"
+ acrn:options-sorted-by="lambda s: (s.split('Device name: ')[1].split(', Device physical path')[0], s.split('Device physical path: ')[1])">
<xs:documentation>Specifying backend device in service vm with device description.</xs:documentation>
</xs:annotation>
</xs:element>
--
2.25.1


Re: [PATCH 1/2] config_tools: format vitio input in configurator

Kunhui Li
 

-----Original Message-----
From: Mao, Junjie <junjie.mao@...>
Sent: Monday, May 16, 2022 1:39 PM
To: Li, KunhuiX <kunhuix.li@...>
Cc: acrn-dev@...; Xie, Nanlin <nanlin.xie@...>; Feng, WeiyiX <weiyix.feng@...>
Subject: Re: [PATCH 1/2] config_tools: format vitio input in configurator

Kunhui-Li <kunhuix.li@...> writes:

This patch formats virtio input entry as "Device name: xxx, Device physical path: xxx".

Tracked-On: #6691
Signed-off-by: Kunhui-Li <kunhuix.li@...>
---
misc/config_tools/configurator/pyodide/loadBoard.py | 12 ++++++++++--
misc/config_tools/schema/VMtypes.xsd | 3 ++-
2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/misc/config_tools/configurator/pyodide/loadBoard.py b/misc/config_tools/configurator/pyodide/loadBoard.py
index 48bb02715..035c89fa2 100644
--- a/misc/config_tools/configurator/pyodide/loadBoard.py
+++ b/misc/config_tools/configurator/pyodide/loadBoard.py
@@ -2,6 +2,7 @@
__package__ = 'configurator.pyodide'

import json
+import logging
from copy import deepcopy

import elementpath
@@ -20,7 +21,11 @@ def get_dynamic_scenario(board):
board_xml = etree.fromstring(board)

def get_enum(source, options, obj_type):
- elements = [str(x) for x in elementpath.select(source, options) if x]
+ if options == "//inputs/input":
+ inputs_etree = [x for x in elementpath.select(source, options) if x is not None]
+ elements = [f"Device name: {str(elementpath.select(i, './name/text()')[0])}, Device physical path: {str(elementpath.select(i,
'./phys/text()')[0])}" for i in inputs_etree]
+ else:
+ elements = [str(x) for x in elementpath.select(source, options) if x]
This file contains the general logic to extract enum values from
annotations and is not where item-specific logic should be placed. XPATH
2.0 already supports functions like string-join and for-expressions. You
should be able to express what you need using a single XPATH.
Will update.

elements = list(set(elements))
if not elements:
elements = ['']
@@ -42,7 +47,10 @@ def get_dynamic_scenario(board):
# get enum data
enum = function(source, selector, obj_type)
if sorted_func:
- enum = sorted(enum, key=eval(sorted_func))
+ try:
+ enum = sorted(enum, key=eval(sorted_func))
+ except IndexError as e:
+ logging.warning(e)
Why do you need catch this exception?
Because the "IndexError" will be raise if the //input/name and //input/phys data is not found in board xml file, then user will fail to import board xml.
May I can remove this because it is unnecessary if we use XPATH to parse data.

--
Best Regards
Junjie Mao

return enum

def dynamic_enum_apply(obj):
diff --git a/misc/config_tools/schema/VMtypes.xsd b/misc/config_tools/schema/VMtypes.xsd
index 302e152b6..8fe381caa 100644
--- a/misc/config_tools/schema/VMtypes.xsd
+++ b/misc/config_tools/schema/VMtypes.xsd
@@ -395,7 +395,8 @@ device file when user config it as virtio serial port, which can be read and wri
<xs:complexType name="VirtioInputConfiguration">
<xs:sequence>
<xs:element name="backend_device_file" type="xs:string" minOccurs="0">
- <xs:annotation acrn:title="Backend device file" acrn:widget-options="'placeholder': '/dev/input/eventX'">
+ <xs:annotation acrn:title="Backend device file" acrn:widget-options="'placeholder': '/dev/input/eventX'"
acrn:options="//inputs/input"
+ acrn:options-sorted-by="lambda s: (s.split('Device name: ')[1].split(', Device physical path')[0], s.split('Device physical path:
')[1])">
<xs:documentation>Specifying backend device in service vm with device description.</xs:documentation>
</xs:annotation>
</xs:element>


Canceled: 2022 ACRN Project Technical Community Meeting: @ Monthly 3rd Wednesday 4PM (China-Shanghai), Wednesday 10AM (Europe-Munich), Tuesday 1AM (US-West Coast)

Zou, Terry
 

   Cancel this month’s TCM, thanks.
WW21 ACRN Based X86 OPTEE Introduction Liu Yifan 5/18/2021
 
Special Notes: If you have Zoom connection issue by using web browser, please install & launch Zoom application, manually input the meeting ID (320664063) to join the Zoom meeting.
 
Agenda & Archives:
WW Topic Presenter Status
Chinese New Year Break
WW12 Libvirt Enhancement Introduction to Replace acrnctl Wu Xiangyang 3/16/2021
WW17 ACRN DX: New config/para Design and Application Xie Nanlin 4/20/2021
WW21 ACRN Based X86 OPTEE Introduction Liu Yifan 5/18/2021
WW25 ACRN Modularization Introduction Chen Jason 6/15/2021
WW30 ACRN DX: Dynamic Parameter Configuration Liu, Hang 7/20/2021
 
Project ACRN: A flexible, light-weight, open source reference hypervisor for IoT devices
We invite you to attend a monthly "Technical Community" meeting where we'll meet community members and talk about the ACRN project and plans.
As we explore community interest and involvement opportunities, we'll (re)schedule these meetings at a time convenient to most attendees:
  • Meets every 3rd Wednesday, 4-5:00 PM (China-Shanghai), Wednesday 10-11:00 AM (Europe-Munich), Tuesday 1-2:00 AM (US-West Coast)
  • Chairperson: Terry ZOU, terry.zou@... (Intel)
  • Online conference link: https://zoom.com.cn/j/320664063
  • Zoom Meeting ID: 320 664 063
  • Special Notes: If you have Zoom connection issue by using web browser, please launch Zoom application, manually input the meeting ID (320664063) to join the Zoom meeting.
  • Online conference phone:
  • China: +86 010 87833177  or 400 669 9381 (Toll Free)
  • Germany: +49 (0) 30 3080 6188  or +49 800 724 3138 (Toll Free)
  • US: +1 669 900 6833  or +1 646 558 8656   or +1 877 369 0926 (Toll Free) or +1 855 880 1246 (Toll Free)
  • Additional international phone numbers
  • Meeting Notes:
 
 


Re: [PATCH v2 2/2] hv: move the define of MAX_IR_ENTRIES to offline tool

chenli.wei
 

On 5/16/2022 2:23 PM, Li, Fei1 wrote:
On Mon, May 16, 2022 at 02:07:12PM +0800, Chenli Wei wrote:
There is an issue of calculate 2^n roundup of CONFIG_MAX_PT_IRQ_ENTRIES,
and the code style is very ugly when we use macro to fix it.

So this patch move MAX_IR_ENTRIES to offline tool which could do align
check and calculate it automatically.
This patch is LGTM.
One question: would it better to add ACFG_ prefix to MAX_IR_ENTRIES ?
The name "MAX_IR_ENTRIES " was rename from "CONFIG_MAX_IR_ENTRIES".

That's because the "MAX_IR_ENTRIES " was not config by user after we align it with CONFIG_MAX_PT_IRQ_ENTRIES

Now we move it too config tool, by it's not user config, so I think it's better to keep the current name.

v1-->v2:
1. remove ROUND2/4/8 MACROs of powerof2_roundup

Signed-off-by: Chenli Wei <chenli.wei@...>
---
hypervisor/include/arch/x86/asm/vtd.h | 7 -------
hypervisor/include/lib/util.h | 21 ---------------------
2 files changed, 28 deletions(-)

diff --git a/hypervisor/include/arch/x86/asm/vtd.h b/hypervisor/include/arch/x86/asm/vtd.h
index 4d3518286..284fc62db 100644
--- a/hypervisor/include/arch/x86/asm/vtd.h
+++ b/hypervisor/include/arch/x86/asm/vtd.h
@@ -42,13 +42,6 @@
#define DMAR_ICS_REG 0x9cU /* Invalidation complete status register */
#define DMAR_IRTA_REG 0xb8U /* Interrupt remapping table addr register */
-/* Make sure all PT IRQs work w/ interrupt remapping or post interrupt */
-#if (CONFIG_MAX_PT_IRQ_ENTRIES <= 256)
-#define MAX_IR_ENTRIES 256
-#else
-#define MAX_IR_ENTRIES powerof2_roundup(CONFIG_MAX_PT_IRQ_ENTRIES)
-#endif
-
/* Values for entry_type in ACPI_DMAR_DEVICE_SCOPE - device types */
enum acpi_dmar_scope_type {
ACPI_DMAR_SCOPE_TYPE_NOT_USED = 0,
diff --git a/hypervisor/include/lib/util.h b/hypervisor/include/lib/util.h
index ca3296556..d702ae253 100644
--- a/hypervisor/include/lib/util.h
+++ b/hypervisor/include/lib/util.h
@@ -25,27 +25,6 @@
/** Replaces 'x' by the string "x". */
#define STRINGIFY(x) #x
-/*
- * This algorithm get the round up 2^n
- *
- * n = input - 1; 0x1002 ----> 0x1001
- * n |= n >> 1; 0x1001 | 0x800
- * n |= n >> 2; 0x1801 | 0x600
- * n |= n >> 4; 0x1e01 | 0x1e0
- * n |= n >> 8; 0x1fe1 | 0x1f
- * n |= n >> 16; 0x1fff
- * n |= n >> 32; 0x1fff
- * n += 1; 0x2000
- */
-#define ROUND0(x) ((x)-1)
-#define ROUND1(x) (ROUND0(x) |(ROUND0(x)>>1))
-#define ROUND2(x) (ROUND1(x) |(ROUND1(x)>>2))
-#define ROUND4(x) (ROUND2(x) |(ROUND2(x)>>4))
-#define ROUND8(x) (ROUND4(x) |(ROUND4(x)>>8))
-#define ROUND16(x) (ROUND8(x) |(ROUND8(x)>>16))
-#define ROUND32(x) (ROUND16(x) |(ROUND16(x)>>32))
-#define powerof2_roundup(x) ((ROUND32(x) == (~0UL)) ? ~0UL : (ROUND32(x) +1))
-
/* Macro used to check if a value is aligned to the required boundary.
* Returns TRUE if aligned; FALSE if not aligned
* NOTE: The required alignment must be a power of 2 (2, 4, 8, 16, 32, etc)
--
2.17.1


Re: [PATCH v2 2/2] hv: move the define of MAX_IR_ENTRIES to offline tool

Li, Fei1
 

On Mon, May 16, 2022 at 02:07:12PM +0800, Chenli Wei wrote:
There is an issue of calculate 2^n roundup of CONFIG_MAX_PT_IRQ_ENTRIES,
and the code style is very ugly when we use macro to fix it.

So this patch move MAX_IR_ENTRIES to offline tool which could do align
check and calculate it automatically.
This patch is LGTM.
One question: would it better to add ACFG_ prefix to MAX_IR_ENTRIES ?

v1-->v2:
1. remove ROUND2/4/8 MACROs of powerof2_roundup

Signed-off-by: Chenli Wei <chenli.wei@...>
---
hypervisor/include/arch/x86/asm/vtd.h | 7 -------
hypervisor/include/lib/util.h | 21 ---------------------
2 files changed, 28 deletions(-)

diff --git a/hypervisor/include/arch/x86/asm/vtd.h b/hypervisor/include/arch/x86/asm/vtd.h
index 4d3518286..284fc62db 100644
--- a/hypervisor/include/arch/x86/asm/vtd.h
+++ b/hypervisor/include/arch/x86/asm/vtd.h
@@ -42,13 +42,6 @@
#define DMAR_ICS_REG 0x9cU /* Invalidation complete status register */
#define DMAR_IRTA_REG 0xb8U /* Interrupt remapping table addr register */

-/* Make sure all PT IRQs work w/ interrupt remapping or post interrupt */
-#if (CONFIG_MAX_PT_IRQ_ENTRIES <= 256)
-#define MAX_IR_ENTRIES 256
-#else
-#define MAX_IR_ENTRIES powerof2_roundup(CONFIG_MAX_PT_IRQ_ENTRIES)
-#endif
-
/* Values for entry_type in ACPI_DMAR_DEVICE_SCOPE - device types */
enum acpi_dmar_scope_type {
ACPI_DMAR_SCOPE_TYPE_NOT_USED = 0,
diff --git a/hypervisor/include/lib/util.h b/hypervisor/include/lib/util.h
index ca3296556..d702ae253 100644
--- a/hypervisor/include/lib/util.h
+++ b/hypervisor/include/lib/util.h
@@ -25,27 +25,6 @@
/** Replaces 'x' by the string "x". */
#define STRINGIFY(x) #x

-/*
- * This algorithm get the round up 2^n
- *
- * n = input - 1; 0x1002 ----> 0x1001
- * n |= n >> 1; 0x1001 | 0x800
- * n |= n >> 2; 0x1801 | 0x600
- * n |= n >> 4; 0x1e01 | 0x1e0
- * n |= n >> 8; 0x1fe1 | 0x1f
- * n |= n >> 16; 0x1fff
- * n |= n >> 32; 0x1fff
- * n += 1; 0x2000
- */
-#define ROUND0(x) ((x)-1)
-#define ROUND1(x) (ROUND0(x) |(ROUND0(x)>>1))
-#define ROUND2(x) (ROUND1(x) |(ROUND1(x)>>2))
-#define ROUND4(x) (ROUND2(x) |(ROUND2(x)>>4))
-#define ROUND8(x) (ROUND4(x) |(ROUND4(x)>>8))
-#define ROUND16(x) (ROUND8(x) |(ROUND8(x)>>16))
-#define ROUND32(x) (ROUND16(x) |(ROUND16(x)>>32))
-#define powerof2_roundup(x) ((ROUND32(x) == (~0UL)) ? ~0UL : (ROUND32(x) +1))
-
/* Macro used to check if a value is aligned to the required boundary.
* Returns TRUE if aligned; FALSE if not aligned
* NOTE: The required alignment must be a power of 2 (2, 4, 8, 16, 32, etc)
--
2.17.1


Re: [PATCH 1/2] misc: add the define of MAX_IR_ENTRIES

chenli.wei
 

On 5/16/2022 12:47 PM, Junjie Mao wrote:
"Junjie Mao" <junjie.mao@...> writes:

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

The current code align MAX_IR_ENTRIE with the CONFIG_MAX_PT_IRQ_ENTRIE
roundup to 2^n, there is an issue of the powerof2_roundup to calculate
the macro, and the code style is very ugly when we use macro to fix it.

So this patch move the calculate and define of MAX_IR_ENTRIE to offline
tool.

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

Some minor comments below.

---
.../static_allocators/board_capability.py | 17 +++++++++++++++++
.../config_tools/xforms/vm_configurations.h.xsl | 5 +++++
2 files changed, 22 insertions(+)

diff --git a/misc/config_tools/static_allocators/board_capability.py b/misc/config_tools/static_allocators/board_capability.py
index 5a98f472d..75f72afc2 100644
--- a/misc/config_tools/static_allocators/board_capability.py
+++ b/misc/config_tools/static_allocators/board_capability.py
@@ -7,6 +7,23 @@
import common
+def powerof2_roundup(value):
+ result = value
+ for i in [1, 2, 4, 8, 16]:
+ result = result | result >> i
+ return result + 1
`1 << value.bit_length()` is simpler and more straightforward.
Need take care about the boundary values:

`0 if value == 0 else (1 << (value - 1).bit_length())`
Thanks, I have send again with the V2 of HV patch


[PATCH v2 2/2] hv: move the define of MAX_IR_ENTRIES to offline tool

chenli.wei
 

There is an issue of calculate 2^n roundup of CONFIG_MAX_PT_IRQ_ENTRIES,
and the code style is very ugly when we use macro to fix it.

So this patch move MAX_IR_ENTRIES to offline tool which could do align
check and calculate it automatically.

v1-->v2:
1. remove ROUND2/4/8 MACROs of powerof2_roundup

Signed-off-by: Chenli Wei <chenli.wei@...>
---
hypervisor/include/arch/x86/asm/vtd.h | 7 -------
hypervisor/include/lib/util.h | 21 ---------------------
2 files changed, 28 deletions(-)

diff --git a/hypervisor/include/arch/x86/asm/vtd.h b/hypervisor/include/arch/x86/asm/vtd.h
index 4d3518286..284fc62db 100644
--- a/hypervisor/include/arch/x86/asm/vtd.h
+++ b/hypervisor/include/arch/x86/asm/vtd.h
@@ -42,13 +42,6 @@
#define DMAR_ICS_REG 0x9cU /* Invalidation complete status register */
#define DMAR_IRTA_REG 0xb8U /* Interrupt remapping table addr register */

-/* Make sure all PT IRQs work w/ interrupt remapping or post interrupt */
-#if (CONFIG_MAX_PT_IRQ_ENTRIES <= 256)
-#define MAX_IR_ENTRIES 256
-#else
-#define MAX_IR_ENTRIES powerof2_roundup(CONFIG_MAX_PT_IRQ_ENTRIES)
-#endif
-
/* Values for entry_type in ACPI_DMAR_DEVICE_SCOPE - device types */
enum acpi_dmar_scope_type {
ACPI_DMAR_SCOPE_TYPE_NOT_USED = 0,
diff --git a/hypervisor/include/lib/util.h b/hypervisor/include/lib/util.h
index ca3296556..d702ae253 100644
--- a/hypervisor/include/lib/util.h
+++ b/hypervisor/include/lib/util.h
@@ -25,27 +25,6 @@
/** Replaces 'x' by the string "x". */
#define STRINGIFY(x) #x

-/*
- * This algorithm get the round up 2^n
- *
- * n = input - 1; 0x1002 ----> 0x1001
- * n |= n >> 1; 0x1001 | 0x800
- * n |= n >> 2; 0x1801 | 0x600
- * n |= n >> 4; 0x1e01 | 0x1e0
- * n |= n >> 8; 0x1fe1 | 0x1f
- * n |= n >> 16; 0x1fff
- * n |= n >> 32; 0x1fff
- * n += 1; 0x2000
- */
-#define ROUND0(x) ((x)-1)
-#define ROUND1(x) (ROUND0(x) |(ROUND0(x)>>1))
-#define ROUND2(x) (ROUND1(x) |(ROUND1(x)>>2))
-#define ROUND4(x) (ROUND2(x) |(ROUND2(x)>>4))
-#define ROUND8(x) (ROUND4(x) |(ROUND4(x)>>8))
-#define ROUND16(x) (ROUND8(x) |(ROUND8(x)>>16))
-#define ROUND32(x) (ROUND16(x) |(ROUND16(x)>>32))
-#define powerof2_roundup(x) ((ROUND32(x) == (~0UL)) ? ~0UL : (ROUND32(x) +1))
-
/* Macro used to check if a value is aligned to the required boundary.
* Returns TRUE if aligned; FALSE if not aligned
* NOTE: The required alignment must be a power of 2 (2, 4, 8, 16, 32, etc)
--
2.17.1


[PATCH v2 1/2] misc: add the define of MAX_IR_ENTRIES

chenli.wei
 

The current code align MAX_IR_ENTRIES with the roundup to 2^n of the
CONFIG_MAX_PT_IRQ_ENTRIES, there is an issue of the powerof2_roundup to
calculate the macro, and the code style is very ugly when we use macro
to fix it.

So this patch move the calculate and define of MAX_IR_ENTRIES to offline
tool.

v1-->v2:
1. Simplify the powerof2_roundup and XSL
2. code format

Signed-off-by: Chenli Wei <chenli.wei@...>
Reviewed-by: Junjie Mao <junjie.mao@...>
---
.../static_allocators/board_capability.py | 14 ++++++++++++++
misc/config_tools/xforms/vm_configurations.h.xsl | 1 +
2 files changed, 15 insertions(+)

diff --git a/misc/config_tools/static_allocators/board_capability.py b/misc/config_tools/static_allocators/board_capability.py
index 5a98f472d..1d9981f43 100644
--- a/misc/config_tools/static_allocators/board_capability.py
+++ b/misc/config_tools/static_allocators/board_capability.py
@@ -7,6 +7,20 @@

import common

+def powerof2_roundup(value):
+ return 0 if value == 0 else (1 << (value - 1).bit_length())
+
+# Make sure all PT IRQs work w/ interrupt remapping or post interrupt
+def create_max_ir_entries(scenario_etree, allocation_etree):
+ pt_irq_entries = common.get_node(f"//MAX_PT_IRQ_ENTRIES/text()", scenario_etree)
+ if (pt_irq_entries is not None) and (int(pt_irq_entries) > 256):
+ ir_entries = powerof2_roundup(int(pt_irq_entries))
+ else:
+ ir_entries = 256
+
+ common.append_node("/acrn-config/hv/MAX_IR_ENTRIES", ir_entries, allocation_etree)
+
def fn(board_etree, scenario_etree, allocation_etree):
pci_bus_nums = board_etree.xpath("//bus[@type='pci']/@address")
common.append_node("/acrn-config/platform/MAX_PCI_BUS_NUM", hex(max(map(lambda x: int(x, 16), pci_bus_nums)) + 1), allocation_etree)
+ create_max_ir_entries(scenario_etree, allocation_etree)
diff --git a/misc/config_tools/xforms/vm_configurations.h.xsl b/misc/config_tools/xforms/vm_configurations.h.xsl
index f91c2720c..1ef0f3dd2 100644
--- a/misc/config_tools/xforms/vm_configurations.h.xsl
+++ b/misc/config_tools/xforms/vm_configurations.h.xsl
@@ -34,6 +34,7 @@
<xsl:call-template name="vm_count" />
<xsl:call-template name="sos_vm_bootarges" />
<xsl:call-template name="vm_vuart_num" />
+ <xsl:value-of select = "acrn:define('MAX_IR_ENTRIES', //MAX_IR_ENTRIES, 'U')" />
</xsl:template>

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


[PATCH v2 0/2] Move the define of MAX_IR_ENTRIES to offline tool

chenli.wei
 

There is an issue of calculate 2^n roundup of CONFIG_MAX_PT_IRQ_ENTRIE,
and the code style is very ugly when we use macro to fix it.

So this series move MAX_IR_ENTRIE to offline tool to fix the issue and
clear HV code.

Chenli Wei (2):
misc: add the define of MAX_IR_ENTRIES
hv: move the define of MAX_IR_ENTRIES to offline tool

hypervisor/include/arch/x86/asm/vtd.h | 7 -------
hypervisor/include/lib/util.h | 21 -------------------
.../static_allocators/board_capability.py | 14 +++++++++++++
.../xforms/vm_configurations.h.xsl | 1 +
4 files changed, 15 insertions(+), 28 deletions(-)

--
2.17.1


Re: [PATCH 1/2] config_tools: format vitio input in configurator

Junjie Mao
 

Kunhui-Li <kunhuix.li@...> writes:

This patch formats virtio input entry as "Device name: xxx, Device physical path: xxx".

Tracked-On: #6691
Signed-off-by: Kunhui-Li <kunhuix.li@...>
---
misc/config_tools/configurator/pyodide/loadBoard.py | 12 ++++++++++--
misc/config_tools/schema/VMtypes.xsd | 3 ++-
2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/misc/config_tools/configurator/pyodide/loadBoard.py b/misc/config_tools/configurator/pyodide/loadBoard.py
index 48bb02715..035c89fa2 100644
--- a/misc/config_tools/configurator/pyodide/loadBoard.py
+++ b/misc/config_tools/configurator/pyodide/loadBoard.py
@@ -2,6 +2,7 @@
__package__ = 'configurator.pyodide'

import json
+import logging
from copy import deepcopy

import elementpath
@@ -20,7 +21,11 @@ def get_dynamic_scenario(board):
board_xml = etree.fromstring(board)

def get_enum(source, options, obj_type):
- elements = [str(x) for x in elementpath.select(source, options) if x]
+ if options == "//inputs/input":
+ inputs_etree = [x for x in elementpath.select(source, options) if x is not None]
+ elements = [f"Device name: {str(elementpath.select(i, './name/text()')[0])}, Device physical path: {str(elementpath.select(i, './phys/text()')[0])}" for i in inputs_etree]
+ else:
+ elements = [str(x) for x in elementpath.select(source, options) if x]
This file contains the general logic to extract enum values from
annotations and is not where item-specific logic should be placed. XPATH
2.0 already supports functions like string-join and for-expressions. You
should be able to express what you need using a single XPATH.

elements = list(set(elements))
if not elements:
elements = ['']
@@ -42,7 +47,10 @@ def get_dynamic_scenario(board):
# get enum data
enum = function(source, selector, obj_type)
if sorted_func:
- enum = sorted(enum, key=eval(sorted_func))
+ try:
+ enum = sorted(enum, key=eval(sorted_func))
+ except IndexError as e:
+ logging.warning(e)
Why do you need catch this exception?

--
Best Regards
Junjie Mao

return enum

def dynamic_enum_apply(obj):
diff --git a/misc/config_tools/schema/VMtypes.xsd b/misc/config_tools/schema/VMtypes.xsd
index 302e152b6..8fe381caa 100644
--- a/misc/config_tools/schema/VMtypes.xsd
+++ b/misc/config_tools/schema/VMtypes.xsd
@@ -395,7 +395,8 @@ device file when user config it as virtio serial port, which can be read and wri
<xs:complexType name="VirtioInputConfiguration">
<xs:sequence>
<xs:element name="backend_device_file" type="xs:string" minOccurs="0">
- <xs:annotation acrn:title="Backend device file" acrn:widget-options="'placeholder': '/dev/input/eventX'">
+ <xs:annotation acrn:title="Backend device file" acrn:widget-options="'placeholder': '/dev/input/eventX'" acrn:options="//inputs/input"
+ acrn:options-sorted-by="lambda s: (s.split('Device name: ')[1].split(', Device physical path')[0], s.split('Device physical path: ')[1])">
<xs:documentation>Specifying backend device in service vm with device description.</xs:documentation>
</xs:annotation>
</xs:element>


Re: [PATCH 1/2] misc: add the define of MAX_IR_ENTRIES

Junjie Mao
 

"Junjie Mao" <junjie.mao@...> writes:

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

The current code align MAX_IR_ENTRIE with the CONFIG_MAX_PT_IRQ_ENTRIE
roundup to 2^n, there is an issue of the powerof2_roundup to calculate
the macro, and the code style is very ugly when we use macro to fix it.

So this patch move the calculate and define of MAX_IR_ENTRIE to offline
tool.

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

Some minor comments below.

---
.../static_allocators/board_capability.py | 17 +++++++++++++++++
.../config_tools/xforms/vm_configurations.h.xsl | 5 +++++
2 files changed, 22 insertions(+)

diff --git a/misc/config_tools/static_allocators/board_capability.py b/misc/config_tools/static_allocators/board_capability.py
index 5a98f472d..75f72afc2 100644
--- a/misc/config_tools/static_allocators/board_capability.py
+++ b/misc/config_tools/static_allocators/board_capability.py
@@ -7,6 +7,23 @@

import common

+def powerof2_roundup(value):
+ result = value
+ for i in [1, 2, 4, 8, 16]:
+ result = result | result >> i
+ return result + 1
`1 << value.bit_length()` is simpler and more straightforward.
Need take care about the boundary values:

`0 if value == 0 else (1 << (value - 1).bit_length())`

--
Best Regards
Junjie Mao

+
+# Make sure all PT IRQs work w/ interrupt remapping or post interrupt
+def create_max_ir_entries(scenario_etree, allocation_etree):
+ pt_irq_entries = common.get_node(f"//MAX_PT_IRQ_ENTRIES/text()", scenario_etree)
+ if (pt_irq_entries is not None) and (int(pt_irq_entries) > 256):
+ ir_entries = powerof2_roundup(int(pt_irq_entries) - 1)
+ else:
+ ir_entries = 256
+
+ common.append_node("/acrn-config/hv/MAX_IR_ENTRIES", ir_entries, allocation_etree)
+
def fn(board_etree, scenario_etree, allocation_etree):
pci_bus_nums = board_etree.xpath("//bus[@type='pci']/@address")
common.append_node("/acrn-config/platform/MAX_PCI_BUS_NUM", hex(max(map(lambda x: int(x, 16), pci_bus_nums)) + 1), allocation_etree)
+ create_max_ir_entries(scenario_etree, allocation_etree)
diff --git a/misc/config_tools/xforms/vm_configurations.h.xsl b/misc/config_tools/xforms/vm_configurations.h.xsl
index f91c2720c..215a17fdd 100644
--- a/misc/config_tools/xforms/vm_configurations.h.xsl
+++ b/misc/config_tools/xforms/vm_configurations.h.xsl
@@ -34,6 +34,7 @@
<xsl:call-template name="vm_count" />
<xsl:call-template name="sos_vm_bootarges" />
<xsl:call-template name="vm_vuart_num" />
+ <xsl:call-template name="ir_entries" />
You can embed the `value-of` node here. Defining a template for a
one-element template seems an overkill.


[PATCH 2/2] config_tools: add virtio devices widget

Kunhui Li
 

This patch adds virtio devices widget according to the new design.

Tracked-On: #6690
Signed-off-by: Kunhui-Li <kunhuix.li@...>
---
.../src/pages/Config/ConfigForm.vue | 17 ++
.../CustomWidget/Virtio/Console.vue | 168 ++++++++++++++++++
.../ConfigForm/CustomWidget/Virtio/Input.vue | 140 +++++++++++++++
.../CustomWidget/Virtio/Network.vue | 141 +++++++++++++++
4 files changed, 466 insertions(+)
create mode 100644 misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/Virtio/Console.vue
create mode 100644 misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/Virtio/Input.vue
create mode 100644 misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/Virtio/Network.vue

diff --git a/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm.vue b/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm.vue
index ff59d9812..4f05abc09 100644
--- a/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm.vue
+++ b/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm.vue
@@ -59,6 +59,9 @@ import localizeEn from 'ajv-i18n/localize/en';
import IVSHMEM_REGION from "./ConfigForm/CustomWidget/IVSHMEM_REGION.vue";
import cpu_affinity from "./ConfigForm/CustomWidget/cpu_affinity.vue";
import VUART from "./ConfigForm/CustomWidget/VUART.vue";
+import Network from "./ConfigForm/CustomWidget/Virtio/Network.vue";
+import Console from "./ConfigForm/CustomWidget/Virtio/Console.vue";
+import Input from "./ConfigForm/CustomWidget/Virtio/Input.vue";

i18n.useLocal(localizeEn);
export default {
@@ -80,6 +83,20 @@ export default {
"labelSuffix": ":"
},
uiSchema: {
+ "virtio_devices": {
+ "network": {
+ "ui:title": "",
+ 'ui:field': Network,
+ },
+ "console": {
+ "ui:title": "",
+ 'ui:field': Console,
+ },
+ "input": {
+ "ui:title": "",
+ 'ui:field': Input,
+ },
+ },
"cpu_affinity": {
'ui:field': cpu_affinity
},
diff --git a/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/Virtio/Console.vue b/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/Virtio/Console.vue
new file mode 100644
index 000000000..bf4943cdd
--- /dev/null
+++ b/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/Virtio/Console.vue
@@ -0,0 +1,168 @@
+<template>
+ <div class="virtio_consoles" v-if="defaultVal && defaultVal.length>0">
+ <div class="virtio_console" v-for="(console, index) in defaultVal">
+ <div class="virtio_console_demo">
+ <b style="margin-bottom: 2rem">Virtio console device</b>
+ <b-row class="align-items-center my-2 mt-4">
+ <b-col md="2">
+ <label>Use type: </label>
+ </b-col>
+ <b-col md="4">
+ <b-form-select v-model="console.use_type" :options="ConsoleUseType"/>
+ </b-col>
+ </b-row>
+
+ <b-row class="align-items-center">
+ <b-col md="2">
+ <label>Backend type: </label>
+ </b-col>
+ <b-col md="4">
+ <b-form-select v-model="console.backend_type" :options="ConsoleBackendType"/>
+ </b-col>
+ </b-row>
+
+ <b-row class="align-items-center my-2" v-if="console.backend_type === 'file'">
+ <b-col md="2">
+ <label>Output file path: </label>
+ </b-col>
+ <b-col md="4">
+ <b-form-input v-model="console.output_file_path"/>
+ </b-col>
+ </b-row>
+
+ <b-row class="align-items-center my-2" v-else-if="console.backend_type === 'tty'">
+ <b-col md="2">
+ <label>TTY device path: </label>
+ </b-col>
+ <b-col md="4">
+ <b-form-input v-model="console.tty_device_path"/>
+ </b-col>
+ </b-row>
+
+ <b-row class="align-items-center my-2" v-else-if="console.backend_type === 'sock client' || console.backend_type === 'sock server'">
+ <b-col md="2">
+ <label>Sock file path: </label>
+ </b-col>
+ <b-col md="4">
+ <b-form-input v-model="console.sock_file_path"/>
+ </b-col>
+ </b-row>
+
+ </div>
+ <div class="ToolSet">
+ <div>
+ <Icon size="18px" color="rgb(60,60,60)" @click="removeVirtioConsole(index)">
+ <Minus/>
+ </Icon>
+ </div>
+ <div>
+ <Icon size="18px" color="rgb(60,60,60)" @click="addVirtioConsole">
+ <Plus/>
+ </Icon>
+ </div>
+ </div>
+
+ </div>
+
+ </div>
+ <div v-else>
+ <b style="margin-bottom: 2rem">Virtio console device</b>
+ <div class="ToolSet">
+ <div @click="addVirtioConsole">
+ <Icon size="18px">
+ <Plus/>
+ </Icon>
+ </div>
+ </div>
+ </div>
+</template>
+
+<script>
+import _ from "lodash";
+import {Icon} from "@vicons/utils";
+import {Plus, Minus} from '@vicons/fa'
+import {fieldProps, vueUtils} from '@lljj/vue3-form-naive';
+
+export default {
+ name: "Console",
+ components: {Icon, Plus, Minus},
+ props: {
+ ...fieldProps,
+ fieldProps: {
+ type: null,
+ default: null
+ }
+ },
+ data() {
+ return {
+ ConsoleUseType: this.rootSchema.definitions['VirtioConsoleUseType']['enum'],
+ ConsoleBackendType: this.rootSchema.definitions['VirtioConsoleBackendType']['enum'],
+ defaultVal: vueUtils.getPathVal(this.rootFormData, this.curNodePath)
+ };
+ },
+ watch: {
+ rootFormData: {
+ handler(newValue, oldValue) {
+ this.defaultVal = vueUtils.getPathVal(newValue, this.curNodePath)
+ },
+ deep: true
+ },
+ defaultVal: {
+ handler(newValue, oldValue) {
+ // Note: `newValue` will be equal to `oldValue` here
+ // on nested mutations as long as the object itself
+ // hasn't been replaced.
+ vueUtils.setPathVal(this.rootFormData, this.curNodePath, newValue);
+ },
+ deep: true
+ }
+ },
+ methods: {
+ removeVirtioConsole(index) {
+ this.defaultVal.splice(index, 1);
+ },
+ addVirtioConsole() {
+ if (!_.isArray(this.defaultVal)) {
+ this.defaultVal = []
+ }
+ this.defaultVal.push({
+ "use_type": this.ConsoleUseType,
+ "backend_type": this.ConsoleBackendType,
+ "output_file_path": "",
+ "sock_file_path": "",
+ "tty_device_path": "",
+ })
+ }
+ }
+}
+</script>
+
+<style scoped>
+.ToolSet {
+ display: flex;
+ flex-direction: row-reverse;
+ gap: 8px;
+}
+.ToolSet div{
+ padding: 8px;
+ border: 1px solid rgb(193,193,193);
+ border-radius: 5px;
+}
+.virtio_consoles{
+ width: 100%;
+}
+.virtio_console {
+ width: 100%;
+ display: flex;
+ gap: 2rem;
+ align-items: end;
+}
+
+.virtio_console_demo {
+ width: 100%;
+ border: 2px solid #cccccc;
+ padding: 8px 2px 12px 6px;
+ border-radius: 5px;
+ margin-bottom: 1rem;
+}
+</style>
\ No newline at end of file
diff --git a/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/Virtio/Input.vue b/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/Virtio/Input.vue
new file mode 100644
index 000000000..ec7ac3f4c
--- /dev/null
+++ b/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/Virtio/Input.vue
@@ -0,0 +1,140 @@
+<template>
+ <div class="virtio_inputs" v-if="defaultVal && defaultVal.length>0">
+ <div class="virtio_input" v-for="(input, index) in defaultVal">
+ <div class="virtio_input_demo">
+ <b style="margin-bottom: 2rem">Virtio input device</b>
+ <b-row class="align-items-center my-2 mt-4">
+ <b-col md="2">
+ <label>Backend device file: </label>
+ </b-col>
+ <b-col md="8">
+ <b-form-select v-model="input.backend_device_file" :options="BackendDeviceFileType"/>
+ </b-col>
+ </b-row>
+
+ <b-row class="align-items-center my-2">
+ <b-col md="2">
+ Guest virtio input device unique identifier:
+ </b-col>
+ <b-col md="4">
+ <b-form-input v-model="input.id"/>
+ </b-col>
+ </b-row>
+ </div>
+ <div class="ToolSet">
+ <div>
+ <Icon size="18px" color="rgb(60,60,60)" @click="removeVirtioInput(index)">
+ <Minus/>
+ </Icon>
+ </div>
+ <div>
+ <Icon size="18px" color="rgb(60,60,60)" @click="addVirtioInput">
+ <Plus/>
+ </Icon>
+ </div>
+ </div>
+
+ </div>
+
+ </div>
+ <div v-else>
+ <b style="margin-bottom: 2rem">Virtio input device</b>
+ <div class="ToolSet">
+ <div @click="addVirtioInput">
+ <Icon size="18px">
+ <Plus/>
+ </Icon>
+ </div>
+ </div>
+ </div>
+</template>
+
+<script>
+import _ from "lodash";
+import {Icon} from "@vicons/utils";
+import {Plus, Minus} from '@vicons/fa'
+import {fieldProps, vueUtils} from '@lljj/vue3-form-naive';
+
+export default {
+ name: "Input",
+ components: {Icon, Plus, Minus},
+ props: {
+ ...fieldProps,
+ fieldProps: {
+ type: null,
+ default: null
+ }
+ },
+ data() {
+ return {
+ BackendDeviceFileType: this.rootSchema.definitions['VirtioInputConfiguration']['properties']['backend_device_file']['enum'],
+ defaultVal: vueUtils.getPathVal(this.rootFormData, this.curNodePath)
+ };
+ },
+ watch: {
+ rootFormData: {
+ handler(newValue, oldValue) {
+ this.defaultVal = vueUtils.getPathVal(newValue, this.curNodePath)
+ },
+ deep: true
+ },
+ defaultVal: {
+ handler(newValue, oldValue) {
+ // Note: `newValue` will be equal to `oldValue` here
+ // on nested mutations as long as the object itself
+ // hasn't been replaced.
+ vueUtils.setPathVal(this.rootFormData, this.curNodePath, newValue);
+ },
+ deep: true
+ }
+ },
+ methods: {
+ removeVirtioInput(index) {
+ this.defaultVal.splice(index, 1);
+ },
+ addVirtioInput() {
+ if (!_.isArray(this.defaultVal)) {
+ this.defaultVal = []
+ }
+ this.defaultVal.push({
+ "backend_device_file": "",
+ "id": "",
+ })
+ }
+ }
+}
+</script>
+
+<style scoped>
+label:after{
+ content: '*';
+ color: red;
+}
+.ToolSet {
+ display: flex;
+ flex-direction: row-reverse;
+ gap: 8px;
+}
+.ToolSet div{
+ padding: 8px;
+ border: 1px solid rgb(193,193,193);
+ border-radius: 5px;
+}
+.virtio_inputs{
+ width: 100%;
+}
+.virtio_input {
+ width: 100%;
+ display: flex;
+ gap: 2rem;
+ align-items: end;
+}
+
+.virtio_input_demo {
+ width: 100%;
+ border: 2px solid #cccccc;
+ padding: 8px 0 12px 6px;
+ border-radius: 5px;
+ margin-bottom: 1rem;
+}
+</style>
\ No newline at end of file
diff --git a/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/Virtio/Network.vue b/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/Virtio/Network.vue
new file mode 100644
index 000000000..c29145d15
--- /dev/null
+++ b/misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/Virtio/Network.vue
@@ -0,0 +1,141 @@
+<template>
+ <div class="virtio_networks" v-if="defaultVal && defaultVal.length>0">
+ <div class="virtio_network" v-for="(network, index) in defaultVal">
+ <div class="virtio_network_demo">
+ <b style="margin-bottom: 2rem">Virtio network device</b>
+ <b-row class="align-items-center my-2 mt-4">
+ <b-col md="2">
+ <label>Virtio framework: </label>
+ </b-col>
+ <b-col md="4">
+ <b-form-select v-model="network.virtio_framework" :options="NetworkFrameworkType"/>
+ </b-col>
+ </b-row>
+
+ <b-row class="align-items-center my-2">
+ <b-col md="2">
+ <label>Network interface name: </label>
+ </b-col>
+ <b-col md="4">
+ <b-form-input v-model="network.interface_name"/>
+ </b-col>
+ </b-row>
+ </div>
+ <div class="ToolSet">
+ <div>
+ <Icon size="18px" color="rgb(60,60,60)" @click="removeVirtioNetwork(index)">
+ <Minus/>
+ </Icon>
+ </div>
+ <div>
+ <Icon size="18px" color="rgb(60,60,60)" @click="addVirtioNetwork">
+ <Plus/>
+ </Icon>
+ </div>
+ </div>
+
+ </div>
+
+ </div>
+ <div v-else>
+ <b style="margin-bottom: 2rem">Virtio network device</b>
+ <div class="ToolSet">
+ <div @click="addVirtioNetwork">
+ <Icon size="18px">
+ <Plus/>
+ </Icon>
+ </div>
+ </div>
+ </div>
+</template>
+
+<script>
+import _ from "lodash";
+import {Icon} from "@vicons/utils";
+import {Plus, Minus} from '@vicons/fa'
+import {fieldProps, vueUtils} from '@lljj/vue3-form-naive';
+
+export default {
+ name: "Network",
+ components: {Icon, Plus, Minus},
+ props: {
+ ...fieldProps,
+ fieldProps: {
+ type: null,
+ default: null
+ }
+ },
+ data() {
+ return {
+ NetworkFrameworkType: this.rootSchema.definitions['VirtioNetworkFrameworkType']['enum'],
+ NetworkFrameworkDefault: this.rootSchema.definitions['VirtioNetworkConfiguration']['properties']['virtio_framework']['default'],
+ defaultVal: vueUtils.getPathVal(this.rootFormData, this.curNodePath)
+ };
+ },
+ watch: {
+ rootFormData: {
+ handler(newValue, oldValue) {
+ this.defaultVal = vueUtils.getPathVal(newValue, this.curNodePath)
+ },
+ deep: true
+ },
+ defaultVal: {
+ handler(newValue, oldValue) {
+ // Note: `newValue` will be equal to `oldValue` here
+ // on nested mutations as long as the object itself
+ // hasn't been replaced.
+ vueUtils.setPathVal(this.rootFormData, this.curNodePath, newValue);
+ },
+ deep: true
+ }
+ },
+ methods: {
+ removeVirtioNetwork(index) {
+ this.defaultVal.splice(index, 1);
+ },
+ addVirtioNetwork() {
+ if (!_.isArray(this.defaultVal)) {
+ this.defaultVal = []
+ }
+ this.defaultVal.push({
+ "virtio_framework": this.NetworkFrameworkDefault,
+ "interface_name": "",
+ })
+ }
+ }
+}
+</script>
+
+<style scoped>
+label:after{
+ content: '*';
+ color: red;
+}
+.ToolSet {
+ display: flex;
+ flex-direction: row-reverse;
+ gap: 8px;
+}
+.ToolSet div{
+ padding: 8px;
+ border: 1px solid rgb(193,193,193);
+ border-radius: 5px;
+}
+.virtio_networks{
+ width: 100%;
+}
+.virtio_network {
+ width: 100%;
+ display: flex;
+ gap: 2rem;
+ align-items: end;
+}
+
+.virtio_network_demo {
+ width: 100%;
+ border: 2px solid #cccccc;
+ padding: 8px 0 12px 6px;
+ border-radius: 5px;
+ margin-bottom: 1rem;
+}
+</style>
\ No newline at end of file
--
2.25.1


[PATCH 1/2] config_tools: format vitio input in configurator

Kunhui Li
 

This patch formats virtio input entry as "Device name: xxx, Device physical path: xxx".

Tracked-On: #6691
Signed-off-by: Kunhui-Li <kunhuix.li@...>
---
misc/config_tools/configurator/pyodide/loadBoard.py | 12 ++++++++++--
misc/config_tools/schema/VMtypes.xsd | 3 ++-
2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/misc/config_tools/configurator/pyodide/loadBoard.py b/misc/config_tools/configurator/pyodide/loadBoard.py
index 48bb02715..035c89fa2 100644
--- a/misc/config_tools/configurator/pyodide/loadBoard.py
+++ b/misc/config_tools/configurator/pyodide/loadBoard.py
@@ -2,6 +2,7 @@
__package__ = 'configurator.pyodide'

import json
+import logging
from copy import deepcopy

import elementpath
@@ -20,7 +21,11 @@ def get_dynamic_scenario(board):
board_xml = etree.fromstring(board)

def get_enum(source, options, obj_type):
- elements = [str(x) for x in elementpath.select(source, options) if x]
+ if options == "//inputs/input":
+ inputs_etree = [x for x in elementpath.select(source, options) if x is not None]
+ elements = [f"Device name: {str(elementpath.select(i, './name/text()')[0])}, Device physical path: {str(elementpath.select(i, './phys/text()')[0])}" for i in inputs_etree]
+ else:
+ elements = [str(x) for x in elementpath.select(source, options) if x]
elements = list(set(elements))
if not elements:
elements = ['']
@@ -42,7 +47,10 @@ def get_dynamic_scenario(board):
# get enum data
enum = function(source, selector, obj_type)
if sorted_func:
- enum = sorted(enum, key=eval(sorted_func))
+ try:
+ enum = sorted(enum, key=eval(sorted_func))
+ except IndexError as e:
+ logging.warning(e)
return enum

def dynamic_enum_apply(obj):
diff --git a/misc/config_tools/schema/VMtypes.xsd b/misc/config_tools/schema/VMtypes.xsd
index 302e152b6..8fe381caa 100644
--- a/misc/config_tools/schema/VMtypes.xsd
+++ b/misc/config_tools/schema/VMtypes.xsd
@@ -395,7 +395,8 @@ device file when user config it as virtio serial port, which can be read and wri
<xs:complexType name="VirtioInputConfiguration">
<xs:sequence>
<xs:element name="backend_device_file" type="xs:string" minOccurs="0">
- <xs:annotation acrn:title="Backend device file" acrn:widget-options="'placeholder': '/dev/input/eventX'">
+ <xs:annotation acrn:title="Backend device file" acrn:widget-options="'placeholder': '/dev/input/eventX'" acrn:options="//inputs/input"
+ acrn:options-sorted-by="lambda s: (s.split('Device name: ')[1].split(', Device physical path')[0], s.split('Device physical path: ')[1])">
<xs:documentation>Specifying backend device in service vm with device description.</xs:documentation>
</xs:annotation>
</xs:element>
--
2.25.1


[PATCH 0/2] add virtio devices widget

Kunhui Li
 

The patch series adds virtio devices(Input/Network/Console) widget
according to the new design.

Kunhui-Li (2):
config_tools: format vitio input in configurator
config_tools: add virtio devices widget

.../src/pages/Config/ConfigForm.vue | 17 ++
.../CustomWidget/Virtio/Console.vue | 168 ++++++++++++++++++
.../ConfigForm/CustomWidget/Virtio/Input.vue | 140 +++++++++++++++
.../CustomWidget/Virtio/Network.vue | 141 +++++++++++++++
.../configurator/pyodide/loadBoard.py | 12 +-
misc/config_tools/schema/VMtypes.xsd | 3 +-
6 files changed, 478 insertions(+), 3 deletions(-)
create mode 100644 misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/Virtio/Console.vue
create mode 100644 misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/Virtio/Input.vue
create mode 100644 misc/config_tools/configurator/packages/configurator/src/pages/Config/ConfigForm/CustomWidget/Virtio/Network.vue

--
2.25.1

1281 - 1300 of 37344