[PATCH v4 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.

v3->v4
1. the monitor_id cannot be duplicated when a VM's display_type is full
screen

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

diff --git a/misc/config_tools/schema/checks/virtio_devices.xsd b/misc/config_tools/schema/checks/virtio_devices.xsd
index b7eac7d45..32b393639 100644
--- a/misc/config_tools/schema/checks/virtio_devices.xsd
+++ b/misc/config_tools/schema/checks/virtio_devices.xsd
@@ -14,4 +14,27 @@
</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;= 4
+ ">
+ <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.</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;= 2
+ ">
+ <xs:annotation acrn:severity="error" acrn:report-on="$vm">
+ <xs:documentation>VM "{$vm/name}" support 2 virtual windows at most.</xs:documentation>
+ </xs:annotation>
+ </xs:assert>
+
+ <xs:assert test="every $monitor_id in /acrn-config/vm/virtio_devices/gpu[display_type = 'Full screen']//monitor_id satisfies
+ count(/acrn-config/vm/virtio_devices/gpu[display_type = 'Full screen']//monitor_id[./text()=$monitor_id]) = 1">
+ <xs:annotation acrn:severity="error" acrn:report-on="//vm[./virtio_devices/gpu[display_type = 'Full screen']/displays/display/monitor_id/text()=$monitor_id]">
+ <xs:documentation>The monitor_id '{$monitor_id}' has been assigned multiple times to VM(s) '{//vm[./virtio_devices/gpu[display_type = 'Full screen']/displays/display/monitor_id/text()=$monitor_id]/name}' </xs:documentation>
+ </xs:annotation>
+ </xs:assert>
+
</xs:schema>
--
2.25.1


Junjie Mao
 

-----Original Message-----
From: Yang, Yu-chu <yu-chu.yang@...>
Sent: Friday, October 14, 2022 7:27 AM
To: acrn-dev@...
Cc: Mao, Junjie <junjie.mao@...>
Subject: [PATCH v4 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.

v3->v4
1. the monitor_id cannot be duplicated when a VM's display_type is full
screen

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

diff --git a/misc/config_tools/schema/checks/virtio_devices.xsd
b/misc/config_tools/schema/checks/virtio_devices.xsd
index b7eac7d45..32b393639 100644
--- a/misc/config_tools/schema/checks/virtio_devices.xsd
+++ b/misc/config_tools/schema/checks/virtio_devices.xsd
@@ -14,4 +14,27 @@
</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;= 4
+ ">
+ <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.</xs:documentation>
Also explicitly guide users to fix this in error messages, e.g., "Remove some of the virtual displays so that the total number does not exceed that limit."

+ </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;= 2
+ ">
+ <xs:annotation acrn:severity="error" acrn:report-on="$vm">
+ <xs:documentation>VM "{$vm/name}" support 2 virtual windows at
most.</xs:documentation>
+ </xs:annotation>
+ </xs:assert>
+
Ditto.

+ <xs:assert test="every $monitor_id in /acrn-
config/vm/virtio_devices/gpu[display_type = 'Full screen']//monitor_id satisfies
+ count(/acrn-config/vm/virtio_devices/gpu[display_type = 'Full
screen']//monitor_id[./text()=$monitor_id]) = 1">
+ <xs:annotation acrn:severity="error" acrn:report-
on="//vm[./virtio_devices/gpu[display_type = 'Full
screen']/displays/display/monitor_id/text()=$monitor_id]">
+ <xs:documentation>The monitor_id '{$monitor_id}' has been assigned multiple times
to VM(s) '{//vm[./virtio_devices/gpu[display_type = 'Full
screen']/displays/display/monitor_id/text()=$monitor_id]/name}' </xs:documentation>
The XPATHs are too lengthy.

You can iterate over each VM using virtio-gpu in full screen mode and then each monitor ID there. With those you can refer to the VM directly in your error message.

---
Best Regards
Junjie Mao

+ </xs:annotation>
+ </xs:assert>
+
</xs:schema>
--
2.25.1