c401cc
From cfa345c23cbb5f9e863f8b9cf1cd288229b78b44 Mon Sep 17 00:00:00 2001
c401cc
Message-Id: <cfa345c23cbb5f9e863f8b9cf1cd288229b78b44@dist-git>
c401cc
From: Eric Blake <eblake@redhat.com>
c401cc
Date: Wed, 26 Feb 2014 14:54:18 +0100
c401cc
Subject: [PATCH] storage: allow interleave in volume 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 volume from handwritten XML.
c401cc
(Compare also to commit caf516db for pools).
c401cc
c401cc
* docs/schemas/storagevol.rng: Support interleaving.
c401cc
* tests/storagevolxml2xmlin/vol-file-backing.xml: Test it.
c401cc
c401cc
Signed-off-by: Eric Blake <eblake@redhat.com>
c401cc
(cherry picked from commit f5580bd6d653e74a22f742cf20a9e864c8f52837)
c401cc
c401cc
Conflicts:
c401cc
	tests/storagevolxml2xmlin/vol-file-backing.xml: context
c401cc
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c401cc
---
c401cc
 docs/schemas/storagevol.rng                    | 138 +++++++++++++------------
c401cc
 tests/storagevolxml2xmlin/vol-file-backing.xml |  15 +--
c401cc
 2 files changed, 82 insertions(+), 71 deletions(-)
c401cc
c401cc
diff --git a/docs/schemas/storagevol.rng b/docs/schemas/storagevol.rng
c401cc
index 5da8e1f..e79bc35 100644
c401cc
--- a/docs/schemas/storagevol.rng
c401cc
+++ b/docs/schemas/storagevol.rng
c401cc
@@ -13,55 +13,61 @@
c401cc
 
c401cc
   <define name='vol'>
c401cc
     <element name='volume'>
c401cc
-      <element name='name'>
c401cc
-        <ref name='volName'/>
c401cc
-      </element>
c401cc
-      <optional>
c401cc
-        <element name='key'>
c401cc
-          <text/>
c401cc
+      <interleave>
c401cc
+        <element name='name'>
c401cc
+          <ref name='volName'/>
c401cc
         </element>
c401cc
-      </optional>
c401cc
-      <optional>
c401cc
-        <ref name='source'/>
c401cc
-      </optional>
c401cc
-      <ref name='sizing'/>
c401cc
-      <ref name='target'/>
c401cc
-      <optional>
c401cc
-        <ref name='backingStore'/>
c401cc
-      </optional>
c401cc
+        <optional>
c401cc
+          <element name='key'>
c401cc
+            <text/>
c401cc
+          </element>
c401cc
+        </optional>
c401cc
+        <optional>
c401cc
+          <ref name='source'/>
c401cc
+        </optional>
c401cc
+        <ref name='sizing'/>
c401cc
+        <ref name='target'/>
c401cc
+        <optional>
c401cc
+          <ref name='backingStore'/>
c401cc
+        </optional>
c401cc
+      </interleave>
c401cc
     </element>
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
+    <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
+    </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
-          <ref name='unsignedInt'/>
c401cc
-        </element>
c401cc
-        <element name='group'>
c401cc
-          <ref name='unsignedInt'/>
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
+            <ref name='unsignedInt'/>
c401cc
+          </element>
c401cc
+          <element name='group'>
c401cc
+            <ref name='unsignedInt'/>
c401cc
+          </element>
c401cc
+          <optional>
c401cc
+            <element name='label'>
c401cc
+              <text/>
c401cc
+            </element>
c401cc
+          </optional>
c401cc
+        </interleave>
c401cc
       </element>
c401cc
     </optional>
c401cc
   </define>
c401cc
@@ -103,36 +109,40 @@
c401cc
 
c401cc
   <define name='target'>
c401cc
     <element name='target'>
c401cc
-      <optional>
c401cc
-        <element name='path'>
c401cc
-          <choice>
c401cc
-            <data type='anyURI'/>
c401cc
-            <ref name='absFilePath'/>
c401cc
-          </choice>
c401cc
-        </element>
c401cc
-      </optional>
c401cc
-      <ref name='format'/>
c401cc
-      <ref name='permissions'/>
c401cc
-      <ref name='timestamps'/>
c401cc
-      <optional>
c401cc
-        <ref name='encryption'/>
c401cc
-      </optional>
c401cc
-      <optional>
c401cc
-        <ref name='compat'/>
c401cc
-      </optional>
c401cc
-      <optional>
c401cc
-        <ref name='fileFormatFeatures'/>
c401cc
-      </optional>
c401cc
+      <interleave>
c401cc
+        <optional>
c401cc
+          <element name='path'>
c401cc
+            <choice>
c401cc
+              <data type='anyURI'/>
c401cc
+              <ref name='absFilePath'/>
c401cc
+            </choice>
c401cc
+          </element>
c401cc
+        </optional>
c401cc
+        <ref name='format'/>
c401cc
+        <ref name='permissions'/>
c401cc
+        <ref name='timestamps'/>
c401cc
+        <optional>
c401cc
+          <ref name='encryption'/>
c401cc
+        </optional>
c401cc
+        <optional>
c401cc
+          <ref name='compat'/>
c401cc
+        </optional>
c401cc
+        <optional>
c401cc
+          <ref name='fileFormatFeatures'/>
c401cc
+        </optional>
c401cc
+      </interleave>
c401cc
     </element>
c401cc
   </define>
c401cc
 
c401cc
   <define name='backingStore'>
c401cc
     <element name='backingStore'>
c401cc
-      <element name='path'>
c401cc
-        <ref name='absFilePath'/>
c401cc
-      </element>
c401cc
-      <ref name='format'/>
c401cc
-      <ref name='permissions'/>
c401cc
+      <interleave>
c401cc
+        <element name='path'>
c401cc
+          <ref name='absFilePath'/>
c401cc
+        </element>
c401cc
+        <ref name='format'/>
c401cc
+        <ref name='permissions'/>
c401cc
+      </interleave>
c401cc
     </element>
c401cc
   </define>
c401cc
 
c401cc
diff --git a/tests/storagevolxml2xmlin/vol-file-backing.xml b/tests/storagevolxml2xmlin/vol-file-backing.xml
c401cc
index 73e7f28..8610ea4 100644
c401cc
--- a/tests/storagevolxml2xmlin/vol-file-backing.xml
c401cc
+++ b/tests/storagevolxml2xmlin/vol-file-backing.xml
c401cc
@@ -1,25 +1,26 @@
c401cc
 <volume>
c401cc
-  <name>sparse.img</name>
c401cc
+  
c401cc
   <key>/var/lib/libvirt/images/sparse.img</key>
c401cc
-  <source/>
c401cc
   <capacity unit='GB'>10</capacity>
c401cc
-  <allocation unit='MiB'>0</allocation>
c401cc
+  <source/>
c401cc
   <target>
c401cc
-    <path>/var/lib/libvirt/images/sparse.img</path>
c401cc
     <permissions>
c401cc
-      <mode>0</mode>
c401cc
       <owner>0744</owner>
c401cc
+      <mode>0</mode>
c401cc
       <group>0</group>
c401cc
     </permissions>
c401cc
+    <path>/var/lib/libvirt/images/sparse.img</path>
c401cc
   </target>
c401cc
+  <allocation unit='MiB'>0</allocation>
c401cc
   <backingStore>
c401cc
-    <path>/var/lib/virt/images/master.img</path>
c401cc
     <format type='vmdk'/>
c401cc
+    <path>/var/lib/virt/images/master.img</path>
c401cc
     <permissions>
c401cc
       <mode>0744</mode>
c401cc
+      <label>virt_image_t</label>
c401cc
       <owner>1</owner>
c401cc
       <group>1</group>
c401cc
-      <label>virt_image_t</label>
c401cc
     </permissions>
c401cc
   </backingStore>
c401cc
+  <name>sparse.img</name>
c401cc
 </volume>
c401cc
-- 
c401cc
1.9.0
c401cc