render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
Blob Blame History Raw
From cfa345c23cbb5f9e863f8b9cf1cd288229b78b44 Mon Sep 17 00:00:00 2001
Message-Id: <cfa345c23cbb5f9e863f8b9cf1cd288229b78b44@dist-git>
From: Eric Blake <eblake@redhat.com>
Date: Wed, 26 Feb 2014 14:54:18 +0100
Subject: [PATCH] storage: allow interleave in volume 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 volume from handwritten XML.
(Compare also to commit caf516db for pools).

* docs/schemas/storagevol.rng: Support interleaving.
* tests/storagevolxml2xmlin/vol-file-backing.xml: Test it.

Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit f5580bd6d653e74a22f742cf20a9e864c8f52837)

Conflicts:
	tests/storagevolxml2xmlin/vol-file-backing.xml: context
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 docs/schemas/storagevol.rng                    | 138 +++++++++++++------------
 tests/storagevolxml2xmlin/vol-file-backing.xml |  15 +--
 2 files changed, 82 insertions(+), 71 deletions(-)

diff --git a/docs/schemas/storagevol.rng b/docs/schemas/storagevol.rng
index 5da8e1f..e79bc35 100644
--- a/docs/schemas/storagevol.rng
+++ b/docs/schemas/storagevol.rng
@@ -13,55 +13,61 @@
 
   <define name='vol'>
     <element name='volume'>
-      <element name='name'>
-        <ref name='volName'/>
-      </element>
-      <optional>
-        <element name='key'>
-          <text/>
+      <interleave>
+        <element name='name'>
+          <ref name='volName'/>
         </element>
-      </optional>
-      <optional>
-        <ref name='source'/>
-      </optional>
-      <ref name='sizing'/>
-      <ref name='target'/>
-      <optional>
-        <ref name='backingStore'/>
-      </optional>
+        <optional>
+          <element name='key'>
+            <text/>
+          </element>
+        </optional>
+        <optional>
+          <ref name='source'/>
+        </optional>
+        <ref name='sizing'/>
+        <ref name='target'/>
+        <optional>
+          <ref name='backingStore'/>
+        </optional>
+      </interleave>
     </element>
   </define>
 
   <define name='sizing'>
-    <optional>
-      <element name='capacity'>
-        <ref name='scaledInteger'/>
-      </element>
-    </optional>
-    <optional>
-      <element name='allocation'>
-        <ref name='scaledInteger'/>
-      </element>
-    </optional>
+    <interleave>
+      <optional>
+        <element name='capacity'>
+          <ref name='scaledInteger'/>
+        </element>
+      </optional>
+      <optional>
+        <element name='allocation'>
+          <ref name='scaledInteger'/>
+        </element>
+      </optional>
+    </interleave>
   </define>
 
   <define name='permissions'>
     <optional>
       <element name='permissions'>
-        <element name='mode'>
-          <ref name='octalMode'/>
-        </element>
-        <element name='owner'>
-          <ref name='unsignedInt'/>
-        </element>
-        <element name='group'>
-          <ref name='unsignedInt'/>
-        </element>
-        <optional>
-          <element name='label'>
-            <text/>
-        </element>
-        </optional>
+        <interleave>
+          <element name='mode'>
+            <ref name='octalMode'/>
+          </element>
+          <element name='owner'>
+            <ref name='unsignedInt'/>
+          </element>
+          <element name='group'>
+            <ref name='unsignedInt'/>
+          </element>
+          <optional>
+            <element name='label'>
+              <text/>
+            </element>
+          </optional>
+        </interleave>
       </element>
     </optional>
   </define>
@@ -103,36 +109,40 @@
 
   <define name='target'>
     <element name='target'>
-      <optional>
-        <element name='path'>
-          <choice>
-            <data type='anyURI'/>
-            <ref name='absFilePath'/>
-          </choice>
-        </element>
-      </optional>
-      <ref name='format'/>
-      <ref name='permissions'/>
-      <ref name='timestamps'/>
-      <optional>
-        <ref name='encryption'/>
-      </optional>
-      <optional>
-        <ref name='compat'/>
-      </optional>
-      <optional>
-        <ref name='fileFormatFeatures'/>
-      </optional>
+      <interleave>
+        <optional>
+          <element name='path'>
+            <choice>
+              <data type='anyURI'/>
+              <ref name='absFilePath'/>
+            </choice>
+          </element>
+        </optional>
+        <ref name='format'/>
+        <ref name='permissions'/>
+        <ref name='timestamps'/>
+        <optional>
+          <ref name='encryption'/>
+        </optional>
+        <optional>
+          <ref name='compat'/>
+        </optional>
+        <optional>
+          <ref name='fileFormatFeatures'/>
+        </optional>
+      </interleave>
     </element>
   </define>
 
   <define name='backingStore'>
     <element name='backingStore'>
-      <element name='path'>
-        <ref name='absFilePath'/>
-      </element>
-      <ref name='format'/>
-      <ref name='permissions'/>
+      <interleave>
+        <element name='path'>
+          <ref name='absFilePath'/>
+        </element>
+        <ref name='format'/>
+        <ref name='permissions'/>
+      </interleave>
     </element>
   </define>
 
diff --git a/tests/storagevolxml2xmlin/vol-file-backing.xml b/tests/storagevolxml2xmlin/vol-file-backing.xml
index 73e7f28..8610ea4 100644
--- a/tests/storagevolxml2xmlin/vol-file-backing.xml
+++ b/tests/storagevolxml2xmlin/vol-file-backing.xml
@@ -1,25 +1,26 @@
 <volume>
-  <name>sparse.img</name>
+  <!-- lines scrambled to test interleaves -->
   <key>/var/lib/libvirt/images/sparse.img</key>
-  <source/>
   <capacity unit='GB'>10</capacity>
-  <allocation unit='MiB'>0</allocation>
+  <source/>
   <target>
-    <path>/var/lib/libvirt/images/sparse.img</path>
     <permissions>
-      <mode>0</mode>
       <owner>0744</owner>
+      <mode>0</mode>
       <group>0</group>
     </permissions>
+    <path>/var/lib/libvirt/images/sparse.img</path>
   </target>
+  <allocation unit='MiB'>0</allocation>
   <backingStore>
-    <path>/var/lib/virt/images/master.img</path>
     <format type='vmdk'/>
+    <path>/var/lib/virt/images/master.img</path>
     <permissions>
       <mode>0744</mode>
+      <label>virt_image_t</label>
       <owner>1</owner>
       <group>1</group>
-      <label>virt_image_t</label>
     </permissions>
   </backingStore>
+  <name>sparse.img</name>
 </volume>
-- 
1.9.0