c401cc
From 8845a0d5d365cc8c87c2fdb577f5f15f738c74e7 Mon Sep 17 00:00:00 2001
c401cc
Message-Id: <8845a0d5d365cc8c87c2fdb577f5f15f738c74e7@dist-git>
c401cc
From: Eric Blake <eblake@redhat.com>
c401cc
Date: Wed, 26 Feb 2014 14:54:39 +0100
c401cc
Subject: [PATCH] storage: allow interleave in pool XML
c401cc
c401cc
https://bugzilla.redhat.com/show_bug.cgi?id=1032370
c401cc
c401cc
The RNG grammar did not allow arbitrary interleaving, which makes
c401cc
it harder than necessary to create a new pool from handwritten XML.
c401cc
c401cc
* docs/schemas/storagepool.rng: Allow interleaving.
c401cc
* tests/storagepoolxml2xmlin/pool-sheepdog.xml: Test interleave.
c401cc
* tests/storagepoolxml2xmlin/pool-iscsi-auth.xml: Likewise.
c401cc
c401cc
Signed-off-by: Eric Blake <eblake@redhat.com>
c401cc
(cherry picked from commit caf516db518ce01b97314932929fbe34deafac78)
c401cc
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c401cc
---
c401cc
 docs/schemas/storagepool.rng                   | 356 ++++++++++++++-----------
c401cc
 tests/storagepoolxml2xmlin/pool-iscsi-auth.xml |  12 +-
c401cc
 tests/storagepoolxml2xmlin/pool-sheepdog.xml   |   6 +-
c401cc
 3 files changed, 211 insertions(+), 163 deletions(-)
c401cc
c401cc
diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng
c401cc
index d1e8f36..8d7a94d 100644
c401cc
--- a/docs/schemas/storagepool.rng
c401cc
+++ b/docs/schemas/storagepool.rng
c401cc
@@ -30,100 +30,120 @@
c401cc
     <attribute name='type'>
c401cc
       <value>dir</value>
c401cc
     </attribute>
c401cc
-    <ref name='commonmetadata'/>
c401cc
-    <ref name='sizing'/>
c401cc
-    <ref name='sourcedir'/>
c401cc
-    <ref name='target'/>
c401cc
+    <interleave>
c401cc
+      <ref name='commonmetadata'/>
c401cc
+      <ref name='sizing'/>
c401cc
+      <ref name='sourcedir'/>
c401cc
+      <ref name='target'/>
c401cc
+    </interleave>
c401cc
   </define>
c401cc
 
c401cc
   <define name='poolfs'>
c401cc
     <attribute name='type'>
c401cc
       <value>fs</value>
c401cc
     </attribute>
c401cc
-    <ref name='commonmetadata'/>
c401cc
-    <ref name='sizing'/>
c401cc
-    <ref name='sourcefs'/>
c401cc
-    <ref name='target'/>
c401cc
+    <interleave>
c401cc
+      <ref name='commonmetadata'/>
c401cc
+      <ref name='sizing'/>
c401cc
+      <ref name='sourcefs'/>
c401cc
+      <ref name='target'/>
c401cc
+    </interleave>
c401cc
   </define>
c401cc
 
c401cc
   <define name='poolnetfs'>
c401cc
     <attribute name='type'>
c401cc
       <value>netfs</value>
c401cc
     </attribute>
c401cc
-    <ref name='commonmetadata'/>
c401cc
-    <ref name='sizing'/>
c401cc
-    <ref name='sourcenetfs'/>
c401cc
-    <ref name='target'/>
c401cc
+    <interleave>
c401cc
+      <ref name='commonmetadata'/>
c401cc
+      <ref name='sizing'/>
c401cc
+      <ref name='sourcenetfs'/>
c401cc
+      <ref name='target'/>
c401cc
+    </interleave>
c401cc
   </define>
c401cc
 
c401cc
   <define name='poollogical'>
c401cc
     <attribute name='type'>
c401cc
       <value>logical</value>
c401cc
     </attribute>
c401cc
-    <ref name='commonmetadata'/>
c401cc
-    <ref name='sizing'/>
c401cc
-    <ref name='sourcelogical'/>
c401cc
-    <ref name='targetlogical'/>
c401cc
+    <interleave>
c401cc
+      <ref name='commonmetadata'/>
c401cc
+      <ref name='sizing'/>
c401cc
+      <ref name='sourcelogical'/>
c401cc
+      <ref name='targetlogical'/>
c401cc
+    </interleave>
c401cc
   </define>
c401cc
 
c401cc
   <define name='pooldisk'>
c401cc
     <attribute name='type'>
c401cc
       <value>disk</value>
c401cc
     </attribute>
c401cc
-    <ref name='commonmetadata'/>
c401cc
-    <ref name='sizing'/>
c401cc
-    <ref name='sourcedisk'/>
c401cc
-    <ref name='target'/>
c401cc
+    <interleave>
c401cc
+      <ref name='commonmetadata'/>
c401cc
+      <ref name='sizing'/>
c401cc
+      <ref name='sourcedisk'/>
c401cc
+      <ref name='target'/>
c401cc
+    </interleave>
c401cc
   </define>
c401cc
 
c401cc
   <define name='pooliscsi'>
c401cc
     <attribute name='type'>
c401cc
       <value>iscsi</value>
c401cc
     </attribute>
c401cc
-    <ref name='commonmetadata'/>
c401cc
-    <ref name='sizing'/>
c401cc
-    <ref name='sourceiscsi'/>
c401cc
-    <ref name='target'/>
c401cc
+    <interleave>
c401cc
+      <ref name='commonmetadata'/>
c401cc
+      <ref name='sizing'/>
c401cc
+      <ref name='sourceiscsi'/>
c401cc
+      <ref name='target'/>
c401cc
+    </interleave>
c401cc
   </define>
c401cc
 
c401cc
   <define name='poolscsi'>
c401cc
     <attribute name='type'>
c401cc
       <value>scsi</value>
c401cc
     </attribute>
c401cc
-    <ref name='commonmetadata'/>
c401cc
-    <ref name='sizing'/>
c401cc
-    <ref name='sourcescsi'/>
c401cc
-    <ref name='target'/>
c401cc
+    <interleave>
c401cc
+      <ref name='commonmetadata'/>
c401cc
+      <ref name='sizing'/>
c401cc
+      <ref name='sourcescsi'/>
c401cc
+      <ref name='target'/>
c401cc
+    </interleave>
c401cc
   </define>
c401cc
 
c401cc
   <define name='poolmpath'>
c401cc
     <attribute name='type'>
c401cc
       <value>mpath</value>
c401cc
     </attribute>
c401cc
-    <ref name='commonmetadata'/>
c401cc
-    <ref name='sizing'/>
c401cc
-    <optional>
c401cc
-      <ref name='sourcempath'/>
c401cc
-    </optional>
c401cc
-    <ref name='target'/>
c401cc
+    <interleave>
c401cc
+      <ref name='commonmetadata'/>
c401cc
+      <ref name='sizing'/>
c401cc
+      <optional>
c401cc
+        <ref name='sourcempath'/>
c401cc
+      </optional>
c401cc
+      <ref name='target'/>
c401cc
+    </interleave>
c401cc
   </define>
c401cc
 
c401cc
   <define name='poolrbd'>
c401cc
     <attribute name='type'>
c401cc
       <value>rbd</value>
c401cc
     </attribute>
c401cc
-    <ref name='commonmetadata'/>
c401cc
-    <ref name='sizing'/>
c401cc
-    <ref name='sourcerbd'/>
c401cc
+    <interleave>
c401cc
+      <ref name='commonmetadata'/>
c401cc
+      <ref name='sizing'/>
c401cc
+      <ref name='sourcerbd'/>
c401cc
+    </interleave>
c401cc
   </define>
c401cc
 
c401cc
   <define name='poolsheepdog'>
c401cc
     <attribute name='type'>
c401cc
       <value>sheepdog</value>
c401cc
     </attribute>
c401cc
-    <ref name='commonmetadata'/>
c401cc
-    <ref name='sizing'/>
c401cc
-    <ref name='sourcesheepdog'/>
c401cc
+    <interleave>
c401cc
+      <ref name='commonmetadata'/>
c401cc
+      <ref name='sizing'/>
c401cc
+      <ref name='sourcesheepdog'/>
c401cc
+    </interleave>
c401cc
   </define>
c401cc
 
c401cc
   <define name='poolgluster'>
c401cc
@@ -138,95 +158,107 @@
c401cc
   </define>
c401cc
 
c401cc
   <define name='sourceinfovendor'>
c401cc
-    <optional>
c401cc
-      <element name='vendor'>
c401cc
-        <attribute name='name'>
c401cc
-          <text/>
c401cc
-        </attribute>
c401cc
-      </element>
c401cc
-    </optional>
c401cc
-    <optional>
c401cc
-      <element name='product'>
c401cc
-        <attribute name='name'>
c401cc
-          <text/>
c401cc
-        </attribute>
c401cc
-      </element>
c401cc
-    </optional>
c401cc
+    <interleave>
c401cc
+      <optional>
c401cc
+        <element name='vendor'>
c401cc
+          <attribute name='name'>
c401cc
+            <text/>
c401cc
+          </attribute>
c401cc
+        </element>
c401cc
+      </optional>
c401cc
+      <optional>
c401cc
+        <element name='product'>
c401cc
+          <attribute name='name'>
c401cc
+            <text/>
c401cc
+          </attribute>
c401cc
+        </element>
c401cc
+      </optional>
c401cc
+    </interleave>
c401cc
   </define>
c401cc
 
c401cc
   <define name='commonmetadata'>
c401cc
-    <element name='name'>
c401cc
-      <ref name='genericName'/>
c401cc
-    </element>
c401cc
-    <optional>
c401cc
-      <element name='uuid'>
c401cc
-        <ref name='UUID'/>
c401cc
+    <interleave>
c401cc
+      <element name='name'>
c401cc
+        <ref name='genericName'/>
c401cc
       </element>
c401cc
-    </optional>
c401cc
+      <optional>
c401cc
+        <element name='uuid'>
c401cc
+          <ref name='UUID'/>
c401cc
+        </element>
c401cc
+      </optional>
c401cc
+    </interleave>
c401cc
   </define>
c401cc
 
c401cc
   <define name='sizing'>
c401cc
-    <optional>
c401cc
-      <element name='capacity'>
c401cc
-        <ref name='scaledInteger'/>
c401cc
-      </element>
c401cc
-    </optional>
c401cc
-    <optional>
c401cc
-      <element name='allocation'>
c401cc
-        <ref name='scaledInteger'/>
c401cc
-      </element>
c401cc
-    </optional>
c401cc
-    <optional>
c401cc
-      <element name='available'>
c401cc
-        <ref name='scaledInteger'/>
c401cc
-      </element>
c401cc
-    </optional>
c401cc
+    <interleave>
c401cc
+      <optional>
c401cc
+        <element name='capacity'>
c401cc
+          <ref name='scaledInteger'/>
c401cc
+        </element>
c401cc
+      </optional>
c401cc
+      <optional>
c401cc
+        <element name='allocation'>
c401cc
+          <ref name='scaledInteger'/>
c401cc
+        </element>
c401cc
+      </optional>
c401cc
+      <optional>
c401cc
+        <element name='available'>
c401cc
+          <ref name='scaledInteger'/>
c401cc
+        </element>
c401cc
+      </optional>
c401cc
+    </interleave>
c401cc
   </define>
c401cc
 
c401cc
   <define name='permissions'>
c401cc
     <optional>
c401cc
       <element name='permissions'>
c401cc
-        <element name='mode'>
c401cc
-          <ref name='octalMode'/>
c401cc
-        </element>
c401cc
-        <element name='owner'>
c401cc
-          <choice>
c401cc
-            <ref name='unsignedInt'/>
c401cc
-            <value>-1</value>
c401cc
-          </choice>
c401cc
-        </element>
c401cc
-        <element name='group'>
c401cc
-          <choice>
c401cc
-            <ref name='unsignedInt'/>
c401cc
-            <value>-1</value>
c401cc
-          </choice>
c401cc
-        </element>
c401cc
-        <optional>
c401cc
-          <element name='label'>
c401cc
-            <text/>
c401cc
-        </element>
c401cc
-        </optional>
c401cc
+        <interleave>
c401cc
+          <element name='mode'>
c401cc
+            <ref name='octalMode'/>
c401cc
+          </element>
c401cc
+          <element name='owner'>
c401cc
+            <choice>
c401cc
+              <ref name='unsignedInt'/>
c401cc
+              <value>-1</value>
c401cc
+            </choice>
c401cc
+          </element>
c401cc
+          <element name='group'>
c401cc
+            <choice>
c401cc
+              <ref name='unsignedInt'/>
c401cc
+              <value>-1</value>
c401cc
+            </choice>
c401cc
+          </element>
c401cc
+          <optional>
c401cc
+            <element name='label'>
c401cc
+              <text/>
c401cc
+            </element>
c401cc
+          </optional>
c401cc
+        </interleave>
c401cc
       </element>
c401cc
     </optional>
c401cc
   </define>
c401cc
 
c401cc
   <define name='target'>
c401cc
     <element name='target'>
c401cc
-      <element name='path'>
c401cc
-        <ref name='absFilePath'/>
c401cc
-      </element>
c401cc
-      <ref name='permissions'/>
c401cc
+      <interleave>
c401cc
+        <element name='path'>
c401cc
+          <ref name='absFilePath'/>
c401cc
+        </element>
c401cc
+        <ref name='permissions'/>
c401cc
+      </interleave>
c401cc
     </element>
c401cc
   </define>
c401cc
 
c401cc
   <define name='targetlogical'>
c401cc
     <element name='target'>
c401cc
-      <optional>
c401cc
-        <element name='path'>
c401cc
-          <ref name='absFilePath'/>
c401cc
-        </element>
c401cc
-      </optional>
c401cc
-      <ref name='permissions'/>
c401cc
+      <interleave>
c401cc
+        <optional>
c401cc
+          <element name='path'>
c401cc
+            <ref name='absFilePath'/>
c401cc
+          </element>
c401cc
+        </optional>
c401cc
+        <ref name='permissions'/>
c401cc
+      </interleave>
c401cc
     </element>
c401cc
   </define>
c401cc
 
c401cc
@@ -424,74 +456,86 @@
c401cc
 
c401cc
   <define name='sourcefs'>
c401cc
     <element name='source'>
c401cc
-      <ref name='sourceinfodev'/>
c401cc
-      <ref name='sourcefmtfs'/>
c401cc
-      <optional>
c401cc
-        <ref name='sourceinfovendor'/>
c401cc
-      </optional>
c401cc
+      <interleave>
c401cc
+        <ref name='sourceinfodev'/>
c401cc
+        <ref name='sourcefmtfs'/>
c401cc
+        <optional>
c401cc
+          <ref name='sourceinfovendor'/>
c401cc
+        </optional>
c401cc
+      </interleave>
c401cc
     </element>
c401cc
   </define>
c401cc
 
c401cc
   <define name='sourcenetfs'>
c401cc
     <element name='source'>
c401cc
-      <ref name='sourceinfohost'/>
c401cc
-      <ref name='sourceinfodir'/>
c401cc
-      <ref name='sourcefmtnetfs'/>
c401cc
-      <optional>
c401cc
-        <ref name='sourceinfovendor'/>
c401cc
-      </optional>
c401cc
+      <interleave>
c401cc
+        <ref name='sourceinfohost'/>
c401cc
+        <ref name='sourceinfodir'/>
c401cc
+        <ref name='sourcefmtnetfs'/>
c401cc
+        <optional>
c401cc
+          <ref name='sourceinfovendor'/>
c401cc
+        </optional>
c401cc
+      </interleave>
c401cc
     </element>
c401cc
   </define>
c401cc
 
c401cc
   <define name='sourcelogical'>
c401cc
     <element name='source'>
c401cc
-      <oneOrMore>
c401cc
-        <optional>
c401cc
-          <ref name='sourceinfoname'/>
c401cc
-        </optional>
c401cc
+      <interleave>
c401cc
+        <oneOrMore>
c401cc
+          <optional>
c401cc
+            <ref name='sourceinfoname'/>
c401cc
+          </optional>
c401cc
+          <optional>
c401cc
+            <ref name='sourceinfodev'/>
c401cc
+          </optional>
c401cc
+        </oneOrMore>
c401cc
+        <ref name='sourcefmtlogical'/>
c401cc
         <optional>
c401cc
-          <ref name='sourceinfodev'/>
c401cc
+          <ref name='sourceinfovendor'/>
c401cc
         </optional>
c401cc
-      </oneOrMore>
c401cc
-      <ref name='sourcefmtlogical'/>
c401cc
-      <optional>
c401cc
-        <ref name='sourceinfovendor'/>
c401cc
-      </optional>
c401cc
+      </interleave>
c401cc
     </element>
c401cc
   </define>
c401cc
 
c401cc
   <define name='sourcedisk'>
c401cc
     <element name='source'>
c401cc
-      <ref name='sourceinfodev'/>
c401cc
-      <ref name='sourcefmtdisk'/>
c401cc
-      <optional>
c401cc
-        <ref name='sourceinfovendor'/>
c401cc
-      </optional>
c401cc
+      <interleave>
c401cc
+        <ref name='sourceinfodev'/>
c401cc
+        <ref name='sourcefmtdisk'/>
c401cc
+        <optional>
c401cc
+          <ref name='sourceinfovendor'/>
c401cc
+        </optional>
c401cc
+      </interleave>
c401cc
     </element>
c401cc
   </define>
c401cc
 
c401cc
   <define name='sourceiscsi'>
c401cc
     <element name='source'>
c401cc
-      <ref name='sourceinfohost'/>
c401cc
-      <ref name='sourceinfodev'/>
c401cc
-      <optional>
c401cc
-        <ref name='initiatorinfo'/>
c401cc
-      </optional>
c401cc
-      <optional>
c401cc
-        <ref name='sourceinfoauth'/>
c401cc
-      </optional>
c401cc
-      <optional>
c401cc
-        <ref name='sourceinfovendor'/>
c401cc
-      </optional>
c401cc
+      <interleave>
c401cc
+        <ref name='sourceinfohost'/>
c401cc
+        <ref name='sourceinfodev'/>
c401cc
+        <optional>
c401cc
+          <ref name='initiatorinfo'/>
c401cc
+        </optional>
c401cc
+        <optional>
c401cc
+          <ref name='sourceinfoauth'/>
c401cc
+        </optional>
c401cc
+        <optional>
c401cc
+          <ref name='sourceinfovendor'/>
c401cc
+        </optional>
c401cc
+      </interleave>
c401cc
     </element>
c401cc
   </define>
c401cc
 
c401cc
   <define name='sourcescsi'>
c401cc
     <element name='source'>
c401cc
-      <ref name='sourceinfoadapter'/>
c401cc
-      <optional>
c401cc
-        <ref name='sourceinfovendor'/>
c401cc
-      </optional>
c401cc
+      <interleave>
c401cc
+        <ref name='sourceinfoadapter'/>
c401cc
+        <optional>
c401cc
+          <ref name='sourceinfovendor'/>
c401cc
+        </optional>
c401cc
+      </interleave>
c401cc
     </element>
c401cc
   </define>
c401cc
 
c401cc
@@ -503,18 +547,22 @@
c401cc
 
c401cc
   <define name='sourcerbd'>
c401cc
     <element name='source'>
c401cc
-      <ref name='sourceinfoname'/>
c401cc
-      <ref name='sourceinfohost'/>
c401cc
-      <optional>
c401cc
-        <ref name='sourceinfoauth'/>
c401cc
-      </optional>
c401cc
+      <interleave>
c401cc
+        <ref name='sourceinfoname'/>
c401cc
+        <ref name='sourceinfohost'/>
c401cc
+        <optional>
c401cc
+          <ref name='sourceinfoauth'/>
c401cc
+        </optional>
c401cc
+      </interleave>
c401cc
     </element>
c401cc
   </define>
c401cc
 
c401cc
   <define name='sourcesheepdog'>
c401cc
     <element name='source'>
c401cc
-      <ref name='sourceinfohost'/>
c401cc
-      <ref name='sourceinfoname'/>
c401cc
+      <interleave>
c401cc
+        <ref name='sourceinfohost'/>
c401cc
+        <ref name='sourceinfoname'/>
c401cc
+      </interleave>
c401cc
     </element>
c401cc
   </define>
c401cc
 
c401cc
diff --git a/tests/storagepoolxml2xmlin/pool-iscsi-auth.xml b/tests/storagepoolxml2xmlin/pool-iscsi-auth.xml
c401cc
index c81eb60..5e5d336 100644
c401cc
--- a/tests/storagepoolxml2xmlin/pool-iscsi-auth.xml
c401cc
+++ b/tests/storagepoolxml2xmlin/pool-iscsi-auth.xml
c401cc
@@ -1,19 +1,19 @@
c401cc
 <pool type='iscsi'>
c401cc
-  <name>virtimages</name>
c401cc
-  <uuid>e9392370-2917-565e-692b-d057f46512d6</uuid>
c401cc
   <source>
c401cc
-    <host name="iscsi.example.com"/>
c401cc
-    <device path="demo-target"/>
c401cc
     <auth type='chap' username='admin'>
c401cc
       <secret uuid='2ec115d7-3a88-3ceb-bc12-0ac909a6fd87'/>
c401cc
     </auth>
c401cc
+    <device path="demo-target"/>
c401cc
+    <host name="iscsi.example.com"/>
c401cc
   </source>
c401cc
+  <uuid>e9392370-2917-565e-692b-d057f46512d6</uuid>
c401cc
   <target>
c401cc
-    <path>/dev/disk/by-path</path>
c401cc
     <permissions>
c401cc
-      <mode>0700</mode>
c401cc
       <owner>0</owner>
c401cc
+      <mode>0700</mode>
c401cc
       <group>0</group>
c401cc
     </permissions>
c401cc
+    <path>/dev/disk/by-path</path>
c401cc
   </target>
c401cc
+  <name>virtimages</name>
c401cc
 </pool>
c401cc
diff --git a/tests/storagepoolxml2xmlin/pool-sheepdog.xml b/tests/storagepoolxml2xmlin/pool-sheepdog.xml
c401cc
index 1287047..49b6baf 100644
c401cc
--- a/tests/storagepoolxml2xmlin/pool-sheepdog.xml
c401cc
+++ b/tests/storagepoolxml2xmlin/pool-sheepdog.xml
c401cc
@@ -1,8 +1,8 @@
c401cc
 <pool type='sheepdog'>
c401cc
-  <name>sheepdog</name>
c401cc
-  <uuid>65fcba04-5b13-bd93-cff3-52ce48e11ad7</uuid>
c401cc
   <source>
c401cc
-    <host name='localhost' port='7000'/>
c401cc
     <name>sheepdog</name>
c401cc
+    <host name='localhost' port='7000'/>
c401cc
   </source>
c401cc
+  <uuid>65fcba04-5b13-bd93-cff3-52ce48e11ad7</uuid>
c401cc
+  <name>sheepdog</name>
c401cc
 </pool>
c401cc
-- 
c401cc
1.9.0
c401cc