1<?xml version="1.0"?>
2<!-- Copyright (C) 2022 Intel Corporation. -->
3<!-- SPDX-License-Identifier: BSD-3-Clause -->
4<xs:schema xml:id="root"
5           xmlns:xs="http://www.w3.org/2001/XMLSchema"
6           xmlns:acrn="https://projectacrn.org">
7
8  <xs:assert test="every $vm in /acrn-config/vm satisfies
9                   every $vsock in $vm/virtio_devices/vsock satisfies
10                   count(//virtio_devices/vsock[text()=$vsock]) = 1
11                   ">
12    <xs:annotation acrn:severity="error" acrn:report-on="$vm">
13      <xs:documentation>VM "{$vm/name}" repeats a vsock CID assignment: {$vsock}, used in this VM or another VM. Make all vsock CID values unique.</xs:documentation>
14    </xs:annotation>
15  </xs:assert>
16
17  <xs:assert test="every $vm in /acrn-config/vm[./virtio_devices/gpu[display_type = 'Full screen']] satisfies
18                   $vm/virtio_devices/gpu/displays/display/monitor_id/text() != ''
19                   ">
20    <xs:annotation acrn:severity="error" acrn:report-on="$vm">
21      <xs:documentation>VM "{$vm/name}": monitor ID is required for "full screen" virtual display.</xs:documentation>
22    </xs:annotation>
23  </xs:assert>
24
25  <xs:assert test="every $vm in /acrn-config/vm[./virtio_devices/gpu[display_type = 'Window']] satisfies
26                   (count($vm//window_resolutions) = count($vm//horizontal_offset)
27                   and count($vm//window_resolutions) = count($vm//vertical_offset)
28                   and count($vm//horizontal_offset) = count($vm//vertical_offset))
29                   ">
30    <xs:annotation acrn:severity="error" acrn:report-on="$vm">
31      <xs:documentation>VM "{$vm/name}": every display's window resolution, horizontal offset and vertical offset are required.</xs:documentation>
32    </xs:annotation>
33  </xs:assert>
34
35  <xs:assert test="every $vm in /acrn-config/vm[./virtio_devices/gpu[display_type = 'Window']] satisfies
36                   $vm/virtio_devices/gpu/displays/display//window_resolutions/text() != ''
37                   ">
38    <xs:annotation acrn:severity="error" acrn:report-on="$vm">
39      <xs:documentation>VM "{$vm/name}": window resolution is required for "window" virtual display.</xs:documentation>
40    </xs:annotation>
41  </xs:assert>
42
43  <xs:assert test="every $vm in /acrn-config/vm[./virtio_devices/gpu[display_type = 'Window']] satisfies
44                   $vm/virtio_devices/gpu/displays/display//horizontal_offset/text() != ''
45                   ">
46    <xs:annotation acrn:severity="error" acrn:report-on="$vm">
47      <xs:documentation>VM "{$vm/name}": horizontal offset (pixels) is required for "window" virtual displays.</xs:documentation>
48    </xs:annotation>
49  </xs:assert>
50
51    <xs:assert test="every $vm in /acrn-config/vm[./virtio_devices/gpu[display_type = 'Window']] satisfies
52                     $vm/virtio_devices/gpu/displays/display//vertical_offset/text() != ''
53                     ">
54    <xs:annotation acrn:severity="error" acrn:report-on="$vm">
55      <xs:documentation>VM "{$vm/name}": vertical offset (pixels) is required for "window" virtual displays.</xs:documentation>
56    </xs:annotation>
57  </xs:assert>
58
59  <xs:assert test="every $vm in /acrn-config/vm[./virtio_devices/gpu[display_type = 'Full screen']] satisfies
60                   every $monitor_id in $vm/virtio_devices/gpu/displays/display/monitor_id satisfies
61                   count(//gpu[display_type = 'Full screen']//monitor_id[./text()=$monitor_id]) = 1
62                   ">
63    <xs:annotation acrn:severity="error" acrn:report-on="$vm">
64      <xs:documentation>The monitor id "{$monitor_id}" has been assigned multiple times to VM "{$vm/name}".
65Choose a different monitor id or remove some of the virtual displays which have the same monitor id.</xs:documentation>
66    </xs:annotation>
67  </xs:assert>
68
69  <xs:assert test="every $vm in /acrn-config/vm satisfies
70                   count($vm/virtio_devices/gpu[display_type = 'Full screen']/displays/display) &lt; 5
71                   ">
72    <xs:annotation acrn:severity="error" acrn:report-on="$vm">
73      <xs:documentation>VM "{$vm/name}" support 4 virtual displays at most in the full screen mode.
74Remove some of the virtual displays so that the total number does not exceed that limit.</xs:documentation>
75    </xs:annotation>
76  </xs:assert>
77
78  <xs:assert test="every $vm in /acrn-config/vm satisfies
79                   count($vm/virtio_devices/gpu[display_type = 'Window']/displays/display) &lt; 3
80                   ">
81    <xs:annotation acrn:severity="error" acrn:report-on="$vm">
82      <xs:documentation>VM "{$vm/name}" support 2 virtual windows at most.
83Remove some of the virtual displays so that the total number does not exceed that limit.</xs:documentation>
84    </xs:annotation>
85  </xs:assert>
86
87</xs:schema>
88