[PATCH 4/6] schema: nodedev: Allow interleaving of sub-elements of 'device'

Peter Krempa pkrempa at redhat.com
Wed Feb 1 16:03:51 UTC 2023


Note that the schema doesn't allow us to represent the two branches of
optional <devnode type='dev'> and zero or more <devnode type='link'>
definitions, so I've merged them under the <zeroOrMore> case.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/conf/schemas/nodedev.rng | 63 +++++++++++++++++-------------------
 1 file changed, 30 insertions(+), 33 deletions(-)

diff --git a/src/conf/schemas/nodedev.rng b/src/conf/schemas/nodedev.rng
index 6299c52671..a9b32bb80f 100644
--- a/src/conf/schemas/nodedev.rng
+++ b/src/conf/schemas/nodedev.rng
@@ -9,41 +9,38 @@

   <define name="device">
     <element name="device">
-      <!-- The name of the network, used to refer to it through the API
-         and in virsh -->
-      <element name="name"><text/></element>
-      <optional>
-        <element name="path"><text/></element>
-      </optional>
-      <optional>
-        <element name="devnode">
-          <attribute name="type">
-            <value>dev</value>
-          </attribute>
-          <text/>
-        </element>
-      </optional>
-      <zeroOrMore>
-        <element name="devnode">
-          <attribute name="type">
-            <value>link</value>
-          </attribute>
-          <text/>
-        </element>
-      </zeroOrMore>
-      <optional>
-        <ref name="parent"/>
-      </optional>
+      <interleave>
+        <!-- The name of the network, used to refer to it through the API
+        and in virsh -->
+        <element name="name"><text/></element>
+        <optional>
+          <element name="path"><text/></element>
+        </optional>
+        <zeroOrMore>
+          <element name="devnode">
+            <attribute name="type">
+              <choice>
+                <value>dev</value>
+                <value>link</value>
+              </choice>
+            </attribute>
+            <text/>
+          </element>
+        </zeroOrMore>
+        <optional>
+          <ref name="parent"/>
+        </optional>

-      <optional>
-        <element name="driver">
-          <element name="name"><text/></element>
-        </element>
-      </optional>
+        <optional>
+          <element name="driver">
+            <element name="name"><text/></element>
+          </element>
+        </optional>

-      <zeroOrMore>
-        <ref name="capability"/>
-      </zeroOrMore>
+        <zeroOrMore>
+          <ref name="capability"/>
+        </zeroOrMore>
+      </interleave>
     </element>
   </define>

-- 
2.39.1



More information about the libvir-list mailing list