[PATCH v6 5/5] config_tools: add assertions for virtio gpu


Yang, Yu-chu
 

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

1. In the full screen mode, a VM supports 4 virtual displays at most.
2. A vm supports 2 virtual windows at most.
3. The monitor ID cannot be duplicated in the full screen mode.
4. All the display elements are in DisplayConfiguration of VMType.xsd. It
cannot be set as required. Using assertions to check if the sub-elements
are set for any type of virtual display accordingly.
- check if a display has been added and a display type is set.
- check if monitor ID is set for full screen virtual display.
- check if resolution and offsets are set for window virtual display.

v5->v6
1. Remove redudant assertions of gpu node and display_type.
2. monitor ID cannot be duplicated across all VMs

Tracked-On: #7970
Signed-off-by: Kunhui-Li <kunhuix.li@...>
Signed-off-by: Yang,Yu-chu <yu-chu.yang@...>
---
.../schema/checks/virtio_devices.xsd | 61 +++++++++++++++++++
1 file changed, 61 insertions(+)

diff --git a/misc/config_tools/schema/checks/virtio_devices.xsd b/misc/config_tools/schema/checks/virtio_devices.xsd
index b7eac7d45..60ccef0e6 100644
--- a/misc/config_tools/schema/checks/virtio_devices.xsd
+++ b/misc/config_tools/schema/checks/virtio_devices.xsd
@@ -14,4 +14,65 @@
</xs:annotation>
</xs:assert>

+ <xs:assert test="every $vm in /acrn-config/vm[./virtio_devices/gpu[display_type = 'Full screen']] satisfies
+ $vm/virtio_devices/gpu/displays/display/monitor_id/text() != ''
+ ">
+ <xs:annotation acrn:severity="error" acrn:report-on="$vm">
+ <xs:documentation>VM "{$vm/name}": monitor ID is required for "full screen" virtual display.</xs:documentation>
+ </xs:annotation>
+ </xs:assert>
+
+ <xs:assert test="every $vm in /acrn-config/vm[./virtio_devices/gpu[display_type = 'Window']] satisfies
+ $vm/virtio_devices/gpu/displays/display/window_resolutions/text() != ''
+ ">
+ <xs:annotation acrn:severity="error" acrn:report-on="$vm">
+ <xs:documentation>VM "{$vm/name}": window resolution is required for "window" virtual display.</xs:documentation>
+ </xs:annotation>
+ </xs:assert>
+
+ <xs:assert test="every $vm in /acrn-config/vm[./virtio_devices/gpu[display_type = 'Window']] satisfies
+ $vm/virtio_devices/gpu/displays/display/horizontal_offset/text() != ''
+ ">
+ <xs:annotation acrn:severity="error" acrn:report-on="$vm">
+ <xs:documentation>VM "{$vm/name}": horizontal offset (pixels) is required for "window" virtual displays.</xs:documentation>
+ </xs:annotation>
+ </xs:assert>
+
+ <xs:assert test="every $vm in /acrn-config/vm[./virtio_devices/gpu[display_type = 'Window']] satisfies
+ $vm/virtio_devices/gpu/displays/display/vertical_offset/text() != ''
+ ">
+ <xs:annotation acrn:severity="error" acrn:report-on="$vm">
+ <xs:documentation>VM "{$vm/name}" support 2 virtual windows at most.
+Remove some of the virtual displays so that the total number does not exceed that limit.</xs:documentation>
+ </xs:annotation>
+ </xs:assert>
+
+ <xs:assert test="every $vm in /acrn-config/vm[./virtio_devices/gpu[display_type = 'Full screen']] satisfies
+ every $monitor_id in $vm/virtio_devices/gpu/displays/display/monitor_id satisfies
+ count(//gpu[display_type = 'Full screen']//monitor_id[./text()=$monitor_id]) = 1
+ ">
+ <xs:annotation acrn:severity="error" acrn:report-on="$vm">
+ <xs:documentation>The monitor id "{$monitor_id}" has been assigned multiple times to VM "{$vm/name}".
+Choose a different monitor id or remove some of the virtual displays which have the same monitor id.</xs:documentation>
+ </xs:annotation>
+ </xs:assert>
+
+ <xs:assert test="every $vm in /acrn-config/vm satisfies
+ count($vm/virtio_devices/gpu[display_type = 'Full screen']/displays/display) &lt; 5
+ ">
+ <xs:annotation acrn:severity="error" acrn:report-on="$vm">
+ <xs:documentation>VM "{$vm/name}" support 4 virtual displays at most in the full screen mode.
+Remove some of the virtual displays so that the total number does not exceed that limit.</xs:documentation>
+ </xs:annotation>
+ </xs:assert>
+
+ <xs:assert test="every $vm in /acrn-config/vm satisfies
+ count($vm/virtio_devices/gpu[display_type = 'Window']/displays/display) &lt; 3
+ ">
+ <xs:annotation acrn:severity="error" acrn:report-on="$vm">
+ <xs:documentation>VM "{$vm/name}" support 2 virtual windows at most.
+Remove some of the virtual displays so that the total number does not exceed that limit.</xs:documentation>
+ </xs:annotation>
+ </xs:assert>
+
</xs:schema>
--
2.25.1


Junjie Mao
 

-----Original Message-----
From: Yang, Yu-chu <yu-chu.yang@...>
Sent: Thursday, October 20, 2022 7:11 AM
To: acrn-dev@...
Cc: Mao, Junjie <junjie.mao@...>
Subject: [PATCH v6 5/5] config_tools: add assertions for virtio gpu

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

1. In the full screen mode, a VM supports 4 virtual displays at most.
2. A vm supports 2 virtual windows at most.
3. The monitor ID cannot be duplicated in the full screen mode.
4. All the display elements are in DisplayConfiguration of VMType.xsd. It
cannot be set as required. Using assertions to check if the sub-elements
are set for any type of virtual display accordingly.
- check if a display has been added and a display type is set.
- check if monitor ID is set for full screen virtual display.
- check if resolution and offsets are set for window virtual display.

v5->v6
1. Remove redudant assertions of gpu node and display_type.
2. monitor ID cannot be duplicated across all VMs

Tracked-On: #7970
Signed-off-by: Kunhui-Li <kunhuix.li@...>
Signed-off-by: Yang,Yu-chu <yu-chu.yang@...>
Reviewed-by: Junjie Mao <junjie.mao@...>

---
Best Regards
Junjie Mao

---
.../schema/checks/virtio_devices.xsd | 61 +++++++++++++++++++
1 file changed, 61 insertions(+)

diff --git a/misc/config_tools/schema/checks/virtio_devices.xsd
b/misc/config_tools/schema/checks/virtio_devices.xsd
index b7eac7d45..60ccef0e6 100644
--- a/misc/config_tools/schema/checks/virtio_devices.xsd
+++ b/misc/config_tools/schema/checks/virtio_devices.xsd
@@ -14,4 +14,65 @@
</xs:annotation>
</xs:assert>

+ <xs:assert test="every $vm in /acrn-config/vm[./virtio_devices/gpu[display_type = 'Full
screen']] satisfies
+ $vm/virtio_devices/gpu/displays/display/monitor_id/text() != ''
+ ">
+ <xs:annotation acrn:severity="error" acrn:report-on="$vm">
+ <xs:documentation>VM "{$vm/name}": monitor ID is required for "full screen" virtual
display.</xs:documentation>
+ </xs:annotation>
+ </xs:assert>
+
+ <xs:assert test="every $vm in /acrn-config/vm[./virtio_devices/gpu[display_type =
'Window']] satisfies
+ $vm/virtio_devices/gpu/displays/display/window_resolutions/text() !=
''
+ ">
+ <xs:annotation acrn:severity="error" acrn:report-on="$vm">
+ <xs:documentation>VM "{$vm/name}": window resolution is required for "window"
virtual display.</xs:documentation>
+ </xs:annotation>
+ </xs:assert>
+
+ <xs:assert test="every $vm in /acrn-config/vm[./virtio_devices/gpu[display_type =
'Window']] satisfies
+ $vm/virtio_devices/gpu/displays/display/horizontal_offset/text() != ''
+ ">
+ <xs:annotation acrn:severity="error" acrn:report-on="$vm">
+ <xs:documentation>VM "{$vm/name}": horizontal offset (pixels) is required for
"window" virtual displays.</xs:documentation>
+ </xs:annotation>
+ </xs:assert>
+
+ <xs:assert test="every $vm in /acrn-config/vm[./virtio_devices/gpu[display_type =
'Window']] satisfies
+ $vm/virtio_devices/gpu/displays/display/vertical_offset/text() != ''
+ ">
+ <xs:annotation acrn:severity="error" acrn:report-on="$vm">
+ <xs:documentation>VM "{$vm/name}" support 2 virtual windows at most.
+Remove some of the virtual displays so that the total number does not exceed that
limit.</xs:documentation>
+ </xs:annotation>
+ </xs:assert>
+
+ <xs:assert test="every $vm in /acrn-config/vm[./virtio_devices/gpu[display_type = 'Full
screen']] satisfies
+ every $monitor_id in
$vm/virtio_devices/gpu/displays/display/monitor_id satisfies
+ count(//gpu[display_type = 'Full
screen']//monitor_id[./text()=$monitor_id]) = 1
+ ">
+ <xs:annotation acrn:severity="error" acrn:report-on="$vm">
+ <xs:documentation>The monitor id "{$monitor_id}" has been assigned multiple times
to VM "{$vm/name}".
+Choose a different monitor id or remove some of the virtual displays which have the same
monitor id.</xs:documentation>
+ </xs:annotation>
+ </xs:assert>
+
+ <xs:assert test="every $vm in /acrn-config/vm satisfies
+ count($vm/virtio_devices/gpu[display_type = 'Full
screen']/displays/display) &lt; 5
+ ">
+ <xs:annotation acrn:severity="error" acrn:report-on="$vm">
+ <xs:documentation>VM "{$vm/name}" support 4 virtual displays at most in the full
screen mode.
+Remove some of the virtual displays so that the total number does not exceed that
limit.</xs:documentation>
+ </xs:annotation>
+ </xs:assert>
+
+ <xs:assert test="every $vm in /acrn-config/vm satisfies
+ count($vm/virtio_devices/gpu[display_type = 'Window']/displays/display)
&lt; 3
+ ">
+ <xs:annotation acrn:severity="error" acrn:report-on="$vm">
+ <xs:documentation>VM "{$vm/name}" support 2 virtual windows at most.
+Remove some of the virtual displays so that the total number does not exceed that
limit.</xs:documentation>
+ </xs:annotation>
+ </xs:assert>
+
</xs:schema>
--
2.25.1