render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
Blob Blame History Raw
From 8845a0d5d365cc8c87c2fdb577f5f15f738c74e7 Mon Sep 17 00:00:00 2001
Message-Id: <8845a0d5d365cc8c87c2fdb577f5f15f738c74e7@dist-git>
From: Eric Blake <eblake@redhat.com>
Date: Wed, 26 Feb 2014 14:54:39 +0100
Subject: [PATCH] storage: allow interleave in pool XML

https://bugzilla.redhat.com/show_bug.cgi?id=1032370

The RNG grammar did not allow arbitrary interleaving, which makes
it harder than necessary to create a new pool from handwritten XML.

* docs/schemas/storagepool.rng: Allow interleaving.
* tests/storagepoolxml2xmlin/pool-sheepdog.xml: Test interleave.
* tests/storagepoolxml2xmlin/pool-iscsi-auth.xml: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit caf516db518ce01b97314932929fbe34deafac78)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 docs/schemas/storagepool.rng                   | 356 ++++++++++++++-----------
 tests/storagepoolxml2xmlin/pool-iscsi-auth.xml |  12 +-
 tests/storagepoolxml2xmlin/pool-sheepdog.xml   |   6 +-
 3 files changed, 211 insertions(+), 163 deletions(-)

diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng
index d1e8f36..8d7a94d 100644
--- a/docs/schemas/storagepool.rng
+++ b/docs/schemas/storagepool.rng
@@ -30,100 +30,120 @@
     <attribute name='type'>
       <value>dir</value>
     </attribute>
-    <ref name='commonmetadata'/>
-    <ref name='sizing'/>
-    <ref name='sourcedir'/>
-    <ref name='target'/>
+    <interleave>
+      <ref name='commonmetadata'/>
+      <ref name='sizing'/>
+      <ref name='sourcedir'/>
+      <ref name='target'/>
+    </interleave>
   </define>
 
   <define name='poolfs'>
     <attribute name='type'>
       <value>fs</value>
     </attribute>
-    <ref name='commonmetadata'/>
-    <ref name='sizing'/>
-    <ref name='sourcefs'/>
-    <ref name='target'/>
+    <interleave>
+      <ref name='commonmetadata'/>
+      <ref name='sizing'/>
+      <ref name='sourcefs'/>
+      <ref name='target'/>
+    </interleave>
   </define>
 
   <define name='poolnetfs'>
     <attribute name='type'>
       <value>netfs</value>
     </attribute>
-    <ref name='commonmetadata'/>
-    <ref name='sizing'/>
-    <ref name='sourcenetfs'/>
-    <ref name='target'/>
+    <interleave>
+      <ref name='commonmetadata'/>
+      <ref name='sizing'/>
+      <ref name='sourcenetfs'/>
+      <ref name='target'/>
+    </interleave>
   </define>
 
   <define name='poollogical'>
     <attribute name='type'>
       <value>logical</value>
     </attribute>
-    <ref name='commonmetadata'/>
-    <ref name='sizing'/>
-    <ref name='sourcelogical'/>
-    <ref name='targetlogical'/>
+    <interleave>
+      <ref name='commonmetadata'/>
+      <ref name='sizing'/>
+      <ref name='sourcelogical'/>
+      <ref name='targetlogical'/>
+    </interleave>
   </define>
 
   <define name='pooldisk'>
     <attribute name='type'>
       <value>disk</value>
     </attribute>
-    <ref name='commonmetadata'/>
-    <ref name='sizing'/>
-    <ref name='sourcedisk'/>
-    <ref name='target'/>
+    <interleave>
+      <ref name='commonmetadata'/>
+      <ref name='sizing'/>
+      <ref name='sourcedisk'/>
+      <ref name='target'/>
+    </interleave>
   </define>
 
   <define name='pooliscsi'>
     <attribute name='type'>
       <value>iscsi</value>
     </attribute>
-    <ref name='commonmetadata'/>
-    <ref name='sizing'/>
-    <ref name='sourceiscsi'/>
-    <ref name='target'/>
+    <interleave>
+      <ref name='commonmetadata'/>
+      <ref name='sizing'/>
+      <ref name='sourceiscsi'/>
+      <ref name='target'/>
+    </interleave>
   </define>
 
   <define name='poolscsi'>
     <attribute name='type'>
       <value>scsi</value>
     </attribute>
-    <ref name='commonmetadata'/>
-    <ref name='sizing'/>
-    <ref name='sourcescsi'/>
-    <ref name='target'/>
+    <interleave>
+      <ref name='commonmetadata'/>
+      <ref name='sizing'/>
+      <ref name='sourcescsi'/>
+      <ref name='target'/>
+    </interleave>
   </define>
 
   <define name='poolmpath'>
     <attribute name='type'>
       <value>mpath</value>
     </attribute>
-    <ref name='commonmetadata'/>
-    <ref name='sizing'/>
-    <optional>
-      <ref name='sourcempath'/>
-    </optional>
-    <ref name='target'/>
+    <interleave>
+      <ref name='commonmetadata'/>
+      <ref name='sizing'/>
+      <optional>
+        <ref name='sourcempath'/>
+      </optional>
+      <ref name='target'/>
+    </interleave>
   </define>
 
   <define name='poolrbd'>
     <attribute name='type'>
       <value>rbd</value>
     </attribute>
-    <ref name='commonmetadata'/>
-    <ref name='sizing'/>
-    <ref name='sourcerbd'/>
+    <interleave>
+      <ref name='commonmetadata'/>
+      <ref name='sizing'/>
+      <ref name='sourcerbd'/>
+    </interleave>
   </define>
 
   <define name='poolsheepdog'>
     <attribute name='type'>
       <value>sheepdog</value>
     </attribute>
-    <ref name='commonmetadata'/>
-    <ref name='sizing'/>
-    <ref name='sourcesheepdog'/>
+    <interleave>
+      <ref name='commonmetadata'/>
+      <ref name='sizing'/>
+      <ref name='sourcesheepdog'/>
+    </interleave>
   </define>
 
   <define name='poolgluster'>
@@ -138,95 +158,107 @@
   </define>
 
   <define name='sourceinfovendor'>
-    <optional>
-      <element name='vendor'>
-        <attribute name='name'>
-          <text/>
-        </attribute>
-      </element>
-    </optional>
-    <optional>
-      <element name='product'>
-        <attribute name='name'>
-          <text/>
-        </attribute>
-      </element>
-    </optional>
+    <interleave>
+      <optional>
+        <element name='vendor'>
+          <attribute name='name'>
+            <text/>
+          </attribute>
+        </element>
+      </optional>
+      <optional>
+        <element name='product'>
+          <attribute name='name'>
+            <text/>
+          </attribute>
+        </element>
+      </optional>
+    </interleave>
   </define>
 
   <define name='commonmetadata'>
-    <element name='name'>
-      <ref name='genericName'/>
-    </element>
-    <optional>
-      <element name='uuid'>
-        <ref name='UUID'/>
+    <interleave>
+      <element name='name'>
+        <ref name='genericName'/>
       </element>
-    </optional>
+      <optional>
+        <element name='uuid'>
+          <ref name='UUID'/>
+        </element>
+      </optional>
+    </interleave>
   </define>
 
   <define name='sizing'>
-    <optional>
-      <element name='capacity'>
-        <ref name='scaledInteger'/>
-      </element>
-    </optional>
-    <optional>
-      <element name='allocation'>
-        <ref name='scaledInteger'/>
-      </element>
-    </optional>
-    <optional>
-      <element name='available'>
-        <ref name='scaledInteger'/>
-      </element>
-    </optional>
+    <interleave>
+      <optional>
+        <element name='capacity'>
+          <ref name='scaledInteger'/>
+        </element>
+      </optional>
+      <optional>
+        <element name='allocation'>
+          <ref name='scaledInteger'/>
+        </element>
+      </optional>
+      <optional>
+        <element name='available'>
+          <ref name='scaledInteger'/>
+        </element>
+      </optional>
+    </interleave>
   </define>
 
   <define name='permissions'>
     <optional>
       <element name='permissions'>
-        <element name='mode'>
-          <ref name='octalMode'/>
-        </element>
-        <element name='owner'>
-          <choice>
-            <ref name='unsignedInt'/>
-            <value>-1</value>
-          </choice>
-        </element>
-        <element name='group'>
-          <choice>
-            <ref name='unsignedInt'/>
-            <value>-1</value>
-          </choice>
-        </element>
-        <optional>
-          <element name='label'>
-            <text/>
-        </element>
-        </optional>
+        <interleave>
+          <element name='mode'>
+            <ref name='octalMode'/>
+          </element>
+          <element name='owner'>
+            <choice>
+              <ref name='unsignedInt'/>
+              <value>-1</value>
+            </choice>
+          </element>
+          <element name='group'>
+            <choice>
+              <ref name='unsignedInt'/>
+              <value>-1</value>
+            </choice>
+          </element>
+          <optional>
+            <element name='label'>
+              <text/>
+            </element>
+          </optional>
+        </interleave>
       </element>
     </optional>
   </define>
 
   <define name='target'>
     <element name='target'>
-      <element name='path'>
-        <ref name='absFilePath'/>
-      </element>
-      <ref name='permissions'/>
+      <interleave>
+        <element name='path'>
+          <ref name='absFilePath'/>
+        </element>
+        <ref name='permissions'/>
+      </interleave>
     </element>
   </define>
 
   <define name='targetlogical'>
     <element name='target'>
-      <optional>
-        <element name='path'>
-          <ref name='absFilePath'/>
-        </element>
-      </optional>
-      <ref name='permissions'/>
+      <interleave>
+        <optional>
+          <element name='path'>
+            <ref name='absFilePath'/>
+          </element>
+        </optional>
+        <ref name='permissions'/>
+      </interleave>
     </element>
   </define>
 
@@ -424,74 +456,86 @@
 
   <define name='sourcefs'>
     <element name='source'>
-      <ref name='sourceinfodev'/>
-      <ref name='sourcefmtfs'/>
-      <optional>
-        <ref name='sourceinfovendor'/>
-      </optional>
+      <interleave>
+        <ref name='sourceinfodev'/>
+        <ref name='sourcefmtfs'/>
+        <optional>
+          <ref name='sourceinfovendor'/>
+        </optional>
+      </interleave>
     </element>
   </define>
 
   <define name='sourcenetfs'>
     <element name='source'>
-      <ref name='sourceinfohost'/>
-      <ref name='sourceinfodir'/>
-      <ref name='sourcefmtnetfs'/>
-      <optional>
-        <ref name='sourceinfovendor'/>
-      </optional>
+      <interleave>
+        <ref name='sourceinfohost'/>
+        <ref name='sourceinfodir'/>
+        <ref name='sourcefmtnetfs'/>
+        <optional>
+          <ref name='sourceinfovendor'/>
+        </optional>
+      </interleave>
     </element>
   </define>
 
   <define name='sourcelogical'>
     <element name='source'>
-      <oneOrMore>
-        <optional>
-          <ref name='sourceinfoname'/>
-        </optional>
+      <interleave>
+        <oneOrMore>
+          <optional>
+            <ref name='sourceinfoname'/>
+          </optional>
+          <optional>
+            <ref name='sourceinfodev'/>
+          </optional>
+        </oneOrMore>
+        <ref name='sourcefmtlogical'/>
         <optional>
-          <ref name='sourceinfodev'/>
+          <ref name='sourceinfovendor'/>
         </optional>
-      </oneOrMore>
-      <ref name='sourcefmtlogical'/>
-      <optional>
-        <ref name='sourceinfovendor'/>
-      </optional>
+      </interleave>
     </element>
   </define>
 
   <define name='sourcedisk'>
     <element name='source'>
-      <ref name='sourceinfodev'/>
-      <ref name='sourcefmtdisk'/>
-      <optional>
-        <ref name='sourceinfovendor'/>
-      </optional>
+      <interleave>
+        <ref name='sourceinfodev'/>
+        <ref name='sourcefmtdisk'/>
+        <optional>
+          <ref name='sourceinfovendor'/>
+        </optional>
+      </interleave>
     </element>
   </define>
 
   <define name='sourceiscsi'>
     <element name='source'>
-      <ref name='sourceinfohost'/>
-      <ref name='sourceinfodev'/>
-      <optional>
-        <ref name='initiatorinfo'/>
-      </optional>
-      <optional>
-        <ref name='sourceinfoauth'/>
-      </optional>
-      <optional>
-        <ref name='sourceinfovendor'/>
-      </optional>
+      <interleave>
+        <ref name='sourceinfohost'/>
+        <ref name='sourceinfodev'/>
+        <optional>
+          <ref name='initiatorinfo'/>
+        </optional>
+        <optional>
+          <ref name='sourceinfoauth'/>
+        </optional>
+        <optional>
+          <ref name='sourceinfovendor'/>
+        </optional>
+      </interleave>
     </element>
   </define>
 
   <define name='sourcescsi'>
     <element name='source'>
-      <ref name='sourceinfoadapter'/>
-      <optional>
-        <ref name='sourceinfovendor'/>
-      </optional>
+      <interleave>
+        <ref name='sourceinfoadapter'/>
+        <optional>
+          <ref name='sourceinfovendor'/>
+        </optional>
+      </interleave>
     </element>
   </define>
 
@@ -503,18 +547,22 @@
 
   <define name='sourcerbd'>
     <element name='source'>
-      <ref name='sourceinfoname'/>
-      <ref name='sourceinfohost'/>
-      <optional>
-        <ref name='sourceinfoauth'/>
-      </optional>
+      <interleave>
+        <ref name='sourceinfoname'/>
+        <ref name='sourceinfohost'/>
+        <optional>
+          <ref name='sourceinfoauth'/>
+        </optional>
+      </interleave>
     </element>
   </define>
 
   <define name='sourcesheepdog'>
     <element name='source'>
-      <ref name='sourceinfohost'/>
-      <ref name='sourceinfoname'/>
+      <interleave>
+        <ref name='sourceinfohost'/>
+        <ref name='sourceinfoname'/>
+      </interleave>
     </element>
   </define>
 
diff --git a/tests/storagepoolxml2xmlin/pool-iscsi-auth.xml b/tests/storagepoolxml2xmlin/pool-iscsi-auth.xml
index c81eb60..5e5d336 100644
--- a/tests/storagepoolxml2xmlin/pool-iscsi-auth.xml
+++ b/tests/storagepoolxml2xmlin/pool-iscsi-auth.xml
@@ -1,19 +1,19 @@
 <pool type='iscsi'>
-  <name>virtimages</name>
-  <uuid>e9392370-2917-565e-692b-d057f46512d6</uuid>
   <source>
-    <host name="iscsi.example.com"/>
-    <device path="demo-target"/>
     <auth type='chap' username='admin'>
       <secret uuid='2ec115d7-3a88-3ceb-bc12-0ac909a6fd87'/>
     </auth>
+    <device path="demo-target"/>
+    <host name="iscsi.example.com"/>
   </source>
+  <uuid>e9392370-2917-565e-692b-d057f46512d6</uuid>
   <target>
-    <path>/dev/disk/by-path</path>
     <permissions>
-      <mode>0700</mode>
       <owner>0</owner>
+      <mode>0700</mode>
       <group>0</group>
     </permissions>
+    <path>/dev/disk/by-path</path>
   </target>
+  <name>virtimages</name>
 </pool>
diff --git a/tests/storagepoolxml2xmlin/pool-sheepdog.xml b/tests/storagepoolxml2xmlin/pool-sheepdog.xml
index 1287047..49b6baf 100644
--- a/tests/storagepoolxml2xmlin/pool-sheepdog.xml
+++ b/tests/storagepoolxml2xmlin/pool-sheepdog.xml
@@ -1,8 +1,8 @@
 <pool type='sheepdog'>
-  <name>sheepdog</name>
-  <uuid>65fcba04-5b13-bd93-cff3-52ce48e11ad7</uuid>
   <source>
-    <host name='localhost' port='7000'/>
     <name>sheepdog</name>
+    <host name='localhost' port='7000'/>
   </source>
+  <uuid>65fcba04-5b13-bd93-cff3-52ce48e11ad7</uuid>
+  <name>sheepdog</name>
 </pool>
-- 
1.9.0