[netcf-devel] [PATCH 1/2] allow reordering of elements in interface xml

Laine Stump laine at laine.org
Thu Aug 21 22:27:24 UTC 2014


The interface xml schema was written with strict rules about the
ordering of the elements. This was never intentional, but just due to
omission of <interleave> in the appropriate places. This patch just
adds in <interleave> wherever there is more than one element, and
re-indents everything else appropriately.

NB: this change was earlier made to the libvirt interface.rng (in
upstream commit a341fc73, which was in libvirt-1.2.6. Also included in
libvirt-1.2.6 was commit 0b33d7c9, which re-orders the emited
interface XML; it turns out that a libvirt that contains the latter
commit (i.e. it re-orders the XML), when paired with a netcf that
doesn't have this current patch (allowing the re-ordering) will log
and error and fail any attempt to define a new host interface. Because
of this, once this patch is in a netcf release, we may want to
consider putting

  Requires: netcf >= 0.2.6

in the libvirt rpm for libvirt 1.2.6 and beyond.
---
 data/xml/interface.rng | 310 ++++++++++++++++++++++++++-----------------------
 1 file changed, 166 insertions(+), 144 deletions(-)

diff --git a/data/xml/interface.rng b/data/xml/interface.rng
index 845d871..f22910f 100644
--- a/data/xml/interface.rng
+++ b/data/xml/interface.rng
@@ -27,45 +27,51 @@
        Ethernet adapter
   -->
   <define name="basic-ethernet-content">
-    <attribute name="type">
-      <value>ethernet</value>
-    </attribute>
-    <ref name="name-attr"/>
-    <!-- If no MAC is given when the interface is defined, it is determined
-         by using the device name.
-         FIXME: What if device name and MAC don't specify the same NIC ? -->
-    <optional>
-      <element name="mac">
-        <attribute name="address"><ref name="mac-addr"/></attribute>
-      </element>
-    </optional>
-    <optional>
-      <element name="link">
-        <optional>
-          <attribute name="speed"><ref name="uint"/></attribute>
-        </optional>
-        <optional>
-          <attribute name="state"><ref name="link-state"/></attribute>
-        </optional>
-      </element>
-      <empty/>
-    </optional>
-    <!-- FIXME: Allow (some) ethtool options -->
+    <interleave>
+      <attribute name="type">
+        <value>ethernet</value>
+      </attribute>
+      <ref name="name-attr"/>
+      <!-- If no MAC is given when the interface is defined, it is determined
+           by using the device name.
+           FIXME: What if device name and MAC don't specify the same NIC ? -->
+      <optional>
+        <element name="mac">
+          <attribute name="address"><ref name="mac-addr"/></attribute>
+        </element>
+      </optional>
+      <optional>
+        <element name="link">
+          <optional>
+            <attribute name="speed"><ref name="uint"/></attribute>
+          </optional>
+          <optional>
+            <attribute name="state"><ref name="link-state"/></attribute>
+          </optional>
+        </element>
+        <empty/>
+      </optional>
+      <!-- FIXME: Allow (some) ethtool options -->
+    </interleave>
   </define>
 
   <!-- Ethernet adapter without IP addressing, e.g. for a bridge -->
   <define name="bare-ethernet-interface">
     <element name="interface">
-      <ref name="basic-ethernet-content"/>
+      <interleave>
+        <ref name="basic-ethernet-content"/>
+      </interleave>
     </element>
   </define>
 
   <define name="ethernet-interface">
     <element name="interface">
-      <ref name="startmode"/>
-      <ref name="basic-ethernet-content"/>
-      <ref name="mtu"/>
-      <ref name="interface-addressing"/>
+      <interleave>
+        <ref name="startmode"/>
+        <ref name="basic-ethernet-content"/>
+        <ref name="mtu"/>
+        <ref name="interface-addressing"/>
+      </interleave>
     </element>
   </define>
 
@@ -93,18 +99,22 @@
 
   <define name="bare-vlan-interface">
     <element name="interface">
-      <ref name="vlan-interface-common"/>
-      <ref name="vlan-device"/>
+      <interleave>
+        <ref name="vlan-interface-common"/>
+        <ref name="vlan-device"/>
+      </interleave>
     </element>
   </define>
 
   <define name="vlan-interface">
     <element name="interface">
-      <ref name="vlan-interface-common"/>
-      <ref name="startmode"/>
-      <ref name="mtu"/>
-      <ref name="interface-addressing"/>
-      <ref name="vlan-device"/>
+      <interleave>
+        <ref name="vlan-interface-common"/>
+        <ref name="startmode"/>
+        <ref name="mtu"/>
+        <ref name="interface-addressing"/>
+        <ref name="vlan-device"/>
+      </interleave>
     </element>
   </define>
 
@@ -113,31 +123,33 @@
   -->
   <define name="bridge-interface">
     <element name="interface">
-      <attribute name="type">
-        <value>bridge</value>
-      </attribute>
-      <ref name="name-attr"/>
-      <ref name="startmode"/>
-      <ref name="mtu"/>
-      <ref name="interface-addressing"/>
-      <element name="bridge">
-        <optional>
-          <attribute name="stp">
-            <ref name="on-or-off"/>
-          </attribute>
-        </optional>
-        <!-- Bridge forward delay (see 'brctl setfd') -->
-        <optional v:since="2">
-          <attribute name="delay"><ref name="timeval"/></attribute>
-        </optional>
-        <zeroOrMore>
-          <choice>
-            <ref name="bare-ethernet-interface"/>
-            <ref name="bare-vlan-interface"/>
-            <ref v:since="2" name="bare-bond-interface"/>
-          </choice>
-        </zeroOrMore>
-      </element>
+      <interleave>
+        <attribute name="type">
+          <value>bridge</value>
+        </attribute>
+        <ref name="name-attr"/>
+        <ref name="startmode"/>
+        <ref name="mtu"/>
+        <ref name="interface-addressing"/>
+        <element name="bridge">
+          <optional>
+            <attribute name="stp">
+              <ref name="on-or-off"/>
+            </attribute>
+          </optional>
+          <!-- Bridge forward delay (see 'brctl setfd') -->
+          <optional v:since="2">
+            <attribute name="delay"><ref name="timeval"/></attribute>
+          </optional>
+          <zeroOrMore>
+            <choice>
+              <ref name="bare-ethernet-interface"/>
+              <ref name="bare-vlan-interface"/>
+              <ref v:since="2" name="bare-bond-interface"/>
+            </choice>
+          </zeroOrMore>
+        </element>
+      </interleave>
     </element>
   </define>
   <!-- Jim Fehlig would like support for other bridge attributes, in
@@ -188,67 +200,73 @@
              xmit_hash_policy       (since 2.6.3/3.2.2)
       -->
 
-      <optional>
-        <choice>
-          <element name="miimon">
-            <!-- miimon frequency in ms -->
-            <attribute name="freq"><ref name="uint"/></attribute>
-            <optional>
-              <attribute name="downdelay"><ref name="uint"/></attribute>
-            </optional>
-            <optional>
-              <attribute name="updelay"><ref name="uint"/></attribute>
-            </optional>
-            <optional>
-              <!-- use_carrier -->
-              <attribute name="carrier">
-                <choice>
-                  <!-- use MII/ETHTOOL ioctl -->
-                  <value>ioctl</value>
-                  <!-- use netif_carrier_ok() -->
-                  <value>netif</value>
-                </choice>
-              </attribute>
-            </optional>
-          </element>
-          <element name="arpmon">
-            <attribute name="interval"><ref name="uint"/></attribute>
-            <attribute name="target"><ref name="ipv4-addr"/></attribute>
-            <optional>
-              <attribute name="validate">
-                <choice>
-                  <value>none</value>
-                  <value>active</value>
-                  <value>backup</value>
-                  <value>all</value>
-                </choice>
-              </attribute>
-            </optional>
-          </element>
-        </choice>
-      </optional>
+      <interleave>
+        <optional>
+          <choice>
+            <element name="miimon">
+              <!-- miimon frequency in ms -->
+              <attribute name="freq"><ref name="uint"/></attribute>
+              <optional>
+                <attribute name="downdelay"><ref name="uint"/></attribute>
+              </optional>
+              <optional>
+                <attribute name="updelay"><ref name="uint"/></attribute>
+              </optional>
+              <optional>
+                <!-- use_carrier -->
+                <attribute name="carrier">
+                  <choice>
+                    <!-- use MII/ETHTOOL ioctl -->
+                    <value>ioctl</value>
+                    <!-- use netif_carrier_ok() -->
+                    <value>netif</value>
+                  </choice>
+                </attribute>
+              </optional>
+            </element>
+            <element name="arpmon">
+              <attribute name="interval"><ref name="uint"/></attribute>
+              <attribute name="target"><ref name="ipv4-addr"/></attribute>
+              <optional>
+                <attribute name="validate">
+                  <choice>
+                    <value>none</value>
+                    <value>active</value>
+                    <value>backup</value>
+                    <value>all</value>
+                  </choice>
+                </attribute>
+              </optional>
+            </element>
+          </choice>
+        </optional>
 
-      <oneOrMore>
-        <!-- The slave interfaces -->
-        <ref name="bare-ethernet-interface"/>
-      </oneOrMore>
+        <oneOrMore>
+          <!-- The slave interfaces -->
+          <ref name="bare-ethernet-interface"/>
+        </oneOrMore>
+      </interleave>
     </element>
   </define>
 
   <define name="bare-bond-interface">
     <element name="interface">
-      <ref name="bond-interface-common"/>
-      <ref name="bond-element"/>
+      <interleave>
+        <ref name="bond-interface-common"/>
+        <ref name="bond-element"/>
+      </interleave>
     </element>
   </define>
 
   <define name="bond-interface">
     <element name="interface">
-      <ref name="bond-interface-common"/>
-      <ref name="startmode"/>
-      <ref name="mtu"/>
-      <ref name="interface-addressing"/>
-      <ref name="bond-element"/>
+      <interleave>
+        <ref name="bond-interface-common"/>
+        <ref name="startmode"/>
+        <ref name="mtu"/>
+        <ref name="interface-addressing"/>
+        <ref name="bond-element"/>
+      </interleave>
     </element>
   </define>
 
@@ -310,22 +328,24 @@
       <attribute name="family">
         <value>ipv4</value>
       </attribute>
-      <choice>
-        <ref name="dhcp-element"/>
-        <group>
-          <element name="ip">
-            <attribute name="address"><ref name="ipv4-addr"/></attribute>
+      <interleave>
+        <choice>
+          <ref name="dhcp-element"/>
+          <group>
+            <element name="ip">
+              <attribute name="address"><ref name="ipv4-addr"/></attribute>
+              <optional>
+                <attribute name="prefix"><ref name="ipv4-prefix"/></attribute>
+              </optional>
+            </element>
             <optional>
-              <attribute name="prefix"><ref name="ipv4-prefix"/></attribute>
+              <element name="route">
+                <attribute name="gateway"><ref name="ipv4-addr"/></attribute>
+              </element>
             </optional>
-          </element>
-          <optional>
-            <element name="route">
-              <attribute name="gateway"><ref name="ipv4-addr"/></attribute>
-            </element>
-          </optional>
-        </group>
-      </choice>
+          </group>
+        </choice>
+      </interleave>
     </element>
   </define>
 
@@ -334,25 +354,27 @@
       <attribute name="family">
         <value>ipv6</value>
       </attribute>
-      <optional>
-        <element name="autoconf"><empty/></element>
-      </optional>
-      <optional>
-        <ref name="dhcp-element"/>
-      </optional>
-      <zeroOrMore>
-        <element name="ip">
-          <attribute name="address"><ref name="ipv6-addr"/></attribute>
-          <optional>
-            <attribute name="prefix"><ref name="ipv6-prefix"/></attribute>
-          </optional>
-        </element>
-      </zeroOrMore>
-      <optional>
-        <element name="route">
-          <attribute name="gateway"><ref name="ipv6-addr"/></attribute>
-        </element>
-      </optional>
+      <interleave>
+        <optional>
+          <element name="autoconf"><empty/></element>
+        </optional>
+        <optional>
+          <ref name="dhcp-element"/>
+        </optional>
+        <zeroOrMore>
+          <element name="ip">
+            <attribute name="address"><ref name="ipv6-addr"/></attribute>
+            <optional>
+              <attribute name="prefix"><ref name="ipv6-prefix"/></attribute>
+            </optional>
+          </element>
+        </zeroOrMore>
+        <optional>
+          <element name="route">
+            <attribute name="gateway"><ref name="ipv6-addr"/></attribute>
+          </element>
+        </optional>
+      </interleave>
     </element>
   </define>
 
-- 
1.9.3



More information about the netcf-devel mailing list