[libvirt] [PATCHv2 6/9] conf: move storage source details to common RNG file

Eric Blake eblake at redhat.com
Mon Apr 14 22:54:17 UTC 2014


Start reflecting the C source code by moving RelaxNG grammar
for virStorageSource into a common file.  There's still more
to move, but doing it in pieces makes it easier to validate.

* docs/schemas/domaincommon.rng (diskSourceFile, diskSourceBlock)
(diskSourceDir, diskSourceNetwork, diskSourceVolume)
(devSeclabel): Move...
* docs/schemas/storagecommon.rng (storageSourceFile)
(storageSourceBlock, storageSourceDir, storageSourceNetwork)
(storageSourceVolume, devSeclabel): ...and rename.
* docs/schemas/domainsnapshot.rng (disksnapshotsource): Update
client.

Signed-off-by: Eric Blake <eblake at redhat.com>
---
 docs/schemas/domaincommon.rng   | 215 ++--------------------------------------
 docs/schemas/domainsnapshot.rng |   6 +-
 docs/schemas/storagecommon.rng  | 205 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 215 insertions(+), 211 deletions(-)

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 7739fd8..a3e5278 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -71,6 +71,7 @@
     </element>
   </define>
   <define name="seclabel">
+    <!-- see also devseclabel in storagecommon.rng -->
     <element name="seclabel">
       <optional>
         <attribute name='model'>
@@ -149,42 +150,7 @@
       </choice>
     </element>
   </define>
-  <define name="devSeclabel">
-    <element name="seclabel">
-      <!-- A per-device seclabel override is more limited, either
-           relabel=no or a <label> must be present on input;
-           output also can include labelskip=yes.  -->
-      <optional>
-        <attribute name='model'>
-          <text/>
-        </attribute>
-      </optional>
-      <choice>
-        <group>
-          <attribute name='relabel'>
-            <value>no</value>
-          </attribute>
-        </group>
-        <group>
-          <attribute name='labelskip'>
-            <value>yes</value>
-          </attribute>
-        </group>
-        <group>
-          <optional>
-            <attribute name='relabel'>
-              <value>yes</value>
-            </attribute>
-          </optional>
-          <oneOrMore>
-            <element name='label'>
-              <text/>
-            </element>
-          </oneOrMore>
-        </group>
-      </choice>
-    </element>
-  </define>
+
   <define name="hvs">
     <attribute name="type">
       <choice>
@@ -1202,181 +1168,14 @@

   <define name="diskSource">
     <choice>
-      <ref name="diskSourceFile"/>
-      <ref name="diskSourceBlock"/>
-      <ref name="diskSourceDir"/>
-      <ref name="diskSourceNetwork"/>
-      <ref name="diskSourceVolume"/>
+      <ref name="storageSourceFile"/>
+      <ref name="storageSourceBlock"/>
+      <ref name="storageSourceDir"/>
+      <ref name="storageSourceNetwork"/>
+      <ref name="storageSourceVolume"/>
     </choice>
   </define>

-  <define name="diskSourceFile">
-    <optional>
-      <attribute name="type">
-        <value>file</value>
-      </attribute>
-    </optional>
-    <interleave>
-      <optional>
-        <element name="source">
-          <optional>
-            <attribute name="file">
-              <ref name="absFilePath"/>
-            </attribute>
-          </optional>
-          <optional>
-            <ref name="storageStartupPolicy"/>
-          </optional>
-          <optional>
-            <ref name='devSeclabel'/>
-          </optional>
-        </element>
-      </optional>
-      <ref name='storageSourceExtra'/>
-    </interleave>
-  </define>
-
-  <define name="diskSourceBlock">
-    <attribute name="type">
-      <value>block</value>
-    </attribute>
-    <interleave>
-      <optional>
-        <element name="source">
-          <optional>
-            <attribute name="dev">
-              <ref name="absFilePath"/>
-            </attribute>
-          </optional>
-          <optional>
-            <ref name="storageStartupPolicy"/>
-          </optional>
-          <optional>
-            <ref name='devSeclabel'/>
-          </optional>
-        </element>
-      </optional>
-      <ref name='storageSourceExtra'/>
-    </interleave>
-  </define>
-
-  <define name="diskSourceDir">
-    <attribute name="type">
-      <value>dir</value>
-    </attribute>
-    <interleave>
-      <optional>
-        <element name="source">
-          <attribute name="dir">
-            <ref name="absFilePath"/>
-          </attribute>
-          <optional>
-            <ref name="storageStartupPolicy"/>
-          </optional>
-          <empty/>
-        </element>
-      </optional>
-      <ref name='storageSourceExtra'/>
-    </interleave>
-  </define>
-
-  <define name="diskSourceNetwork">
-    <attribute name="type">
-      <value>network</value>
-    </attribute>
-    <interleave>
-      <element name="source">
-        <attribute name="protocol">
-          <choice>
-            <value>nbd</value>
-            <value>rbd</value>
-            <value>sheepdog</value>
-            <value>gluster</value>
-            <value>iscsi</value>
-            <value>http</value>
-            <value>https</value>
-            <value>ftp</value>
-            <value>ftps</value>
-            <value>tftp</value>
-          </choice>
-        </attribute>
-        <optional>
-          <attribute name="name"/>
-        </optional>
-        <zeroOrMore>
-          <element name="host">
-            <choice>
-              <group>
-                <optional>
-                  <attribute name="transport">
-                    <choice>
-                      <value>tcp</value>
-                      <value>rdma</value>
-                    </choice>
-                  </attribute>
-                </optional>
-                <attribute name="name">
-                  <choice>
-                    <ref name="dnsName"/>
-                    <ref name="ipAddr"/>
-                  </choice>
-                </attribute>
-                <optional>
-                  <attribute name="port">
-                    <ref name="unsignedInt"/>
-                  </attribute>
-                </optional>
-              </group>
-              <group>
-                <attribute name="transport">
-                  <value>unix</value>
-                </attribute>
-                <attribute name="socket">
-                  <ref name="absFilePath"/>
-                </attribute>
-              </group>
-            </choice>
-          </element>
-        </zeroOrMore>
-        <empty/>
-      </element>
-      <ref name='storageSourceExtra'/>
-    </interleave>
-  </define>
-
-  <define name="diskSourceVolume">
-    <attribute name="type">
-      <value>volume</value>
-    </attribute>
-    <interleave>
-      <optional>
-        <element name="source">
-          <attribute name="pool">
-            <ref name="genericName"/>
-          </attribute>
-          <attribute name="volume">
-            <ref name="volName"/>
-          </attribute>
-          <optional>
-            <attribute name="mode">
-              <choice>
-                <value>host</value>
-                <value>direct</value>
-              </choice>
-            </attribute>
-          </optional>
-          <optional>
-            <ref name="storageStartupPolicy"/>
-          </optional>
-          <optional>
-            <ref name='devSeclabel'/>
-          </optional>
-        </element>
-      </optional>
-      <ref name='storageSourceExtra'/>
-    </interleave>
-  </define>
-
   <define name="diskTarget">
     <data type="string">
       <param name="pattern">(ioemu:)?(fd|hd|sd|vd|xvd|ubd)[a-zA-Z0-9_]+</param>
diff --git a/docs/schemas/domainsnapshot.rng b/docs/schemas/domainsnapshot.rng
index ef3135f..fc630a6 100644
--- a/docs/schemas/domainsnapshot.rng
+++ b/docs/schemas/domainsnapshot.rng
@@ -141,9 +141,9 @@

   <define name='disksnapshotsource'>
     <choice>
-      <ref name='diskSourceFile'/>
-      <ref name='diskSourceBlock'/>
-      <ref name='diskSourceNetwork'/>
+      <ref name='storageSourceFile'/>
+      <ref name='storageSourceBlock'/>
+      <ref name='storageSourceNetwork'/>
     </choice>
   </define>

diff --git a/docs/schemas/storagecommon.rng b/docs/schemas/storagecommon.rng
index 372832d..e1db740 100644
--- a/docs/schemas/storagecommon.rng
+++ b/docs/schemas/storagecommon.rng
@@ -93,4 +93,209 @@
     <notAllowed/>
   </define>

+  <define name="devSeclabel">
+    <element name="seclabel">
+      <!-- A per-device seclabel override is more limited than
+           seclabel in domaincommon.rng.  Either
+           relabel=no or a <label> must be present on input;
+           output also can include labelskip=yes.  -->
+      <optional>
+        <attribute name='model'>
+          <text/>
+        </attribute>
+      </optional>
+      <choice>
+        <group>
+          <attribute name='relabel'>
+            <value>no</value>
+          </attribute>
+        </group>
+        <group>
+          <attribute name='labelskip'>
+            <value>yes</value>
+          </attribute>
+        </group>
+        <group>
+          <optional>
+            <attribute name='relabel'>
+              <value>yes</value>
+            </attribute>
+          </optional>
+          <oneOrMore>
+            <element name='label'>
+              <text/>
+            </element>
+          </oneOrMore>
+        </group>
+      </choice>
+    </element>
+  </define>
+
+  <define name="storageSourceFile">
+    <optional>
+      <attribute name="type">
+        <value>file</value>
+      </attribute>
+    </optional>
+    <interleave>
+      <optional>
+        <element name="source">
+          <optional>
+            <attribute name="file">
+              <ref name="absFilePath"/>
+            </attribute>
+          </optional>
+          <optional>
+            <ref name="storageStartupPolicy"/>
+          </optional>
+          <optional>
+            <ref name='devSeclabel'/>
+          </optional>
+        </element>
+      </optional>
+      <ref name='storageSourceExtra'/>
+    </interleave>
+  </define>
+
+  <define name="storageSourceBlock">
+    <attribute name="type">
+      <value>block</value>
+    </attribute>
+    <interleave>
+      <optional>
+        <element name="source">
+          <optional>
+            <attribute name="dev">
+              <ref name="absFilePath"/>
+            </attribute>
+          </optional>
+          <optional>
+            <ref name="storageStartupPolicy"/>
+          </optional>
+          <optional>
+            <ref name='devSeclabel'/>
+          </optional>
+        </element>
+      </optional>
+      <ref name='storageSourceExtra'/>
+    </interleave>
+  </define>
+
+  <define name="storageSourceDir">
+    <attribute name="type">
+      <value>dir</value>
+    </attribute>
+    <interleave>
+      <optional>
+        <element name="source">
+          <attribute name="dir">
+            <ref name="absFilePath"/>
+          </attribute>
+          <optional>
+            <ref name="storageStartupPolicy"/>
+          </optional>
+          <empty/>
+        </element>
+      </optional>
+      <ref name='storageSourceExtra'/>
+    </interleave>
+  </define>
+
+  <define name="storageSourceNetwork">
+    <attribute name="type">
+      <value>network</value>
+    </attribute>
+    <interleave>
+      <element name="source">
+        <attribute name="protocol">
+          <choice>
+            <value>nbd</value>
+            <value>rbd</value>
+            <value>sheepdog</value>
+            <value>gluster</value>
+            <value>iscsi</value>
+            <value>http</value>
+            <value>https</value>
+            <value>ftp</value>
+            <value>ftps</value>
+            <value>tftp</value>
+          </choice>
+        </attribute>
+        <optional>
+          <attribute name="name"/>
+        </optional>
+        <zeroOrMore>
+          <element name="host">
+            <choice>
+              <group>
+                <optional>
+                  <attribute name="transport">
+                    <choice>
+                      <value>tcp</value>
+                      <value>rdma</value>
+                    </choice>
+                  </attribute>
+                </optional>
+                <attribute name="name">
+                  <choice>
+                    <ref name="dnsName"/>
+                    <ref name="ipAddr"/>
+                  </choice>
+                </attribute>
+                <optional>
+                  <attribute name="port">
+                    <ref name="unsignedInt"/>
+                  </attribute>
+                </optional>
+              </group>
+              <group>
+                <attribute name="transport">
+                  <value>unix</value>
+                </attribute>
+                <attribute name="socket">
+                  <ref name="absFilePath"/>
+                </attribute>
+              </group>
+            </choice>
+          </element>
+        </zeroOrMore>
+        <empty/>
+      </element>
+      <ref name='storageSourceExtra'/>
+    </interleave>
+  </define>
+
+  <define name="storageSourceVolume">
+    <attribute name="type">
+      <value>volume</value>
+    </attribute>
+    <interleave>
+      <optional>
+        <element name="source">
+          <attribute name="pool">
+            <ref name="genericName"/>
+          </attribute>
+          <attribute name="volume">
+            <ref name="volName"/>
+          </attribute>
+          <optional>
+            <attribute name="mode">
+              <choice>
+                <value>host</value>
+                <value>direct</value>
+              </choice>
+            </attribute>
+          </optional>
+          <optional>
+            <ref name="storageStartupPolicy"/>
+          </optional>
+          <optional>
+            <ref name='devSeclabel'/>
+          </optional>
+        </element>
+      </optional>
+      <ref name='storageSourceExtra'/>
+    </interleave>
+  </define>
+
 </grammar>
-- 
1.9.0




More information about the libvir-list mailing list