]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
xml: share 'unit' in RNG
authorEric Blake <eblake@redhat.com>
Wed, 29 Feb 2012 04:16:28 +0000 (21:16 -0700)
committerEric Blake <eblake@redhat.com>
Thu, 8 Mar 2012 01:24:43 +0000 (18:24 -0700)
The code supported unit='E' for "exabyte", but the RNG did not;
conversely, the RNG supported "z" and "y" but the code did not
(I'm jealous if you have that much storage, particularly since
it won't fit in 64-bit off_t).  Also, the code supported
<allocation unit='...'>, but not the RNG.

In an effort to make 'unit' more worthwhile in future patches,
it's easier to share it between files.

In making this factorization, note that absFilePath is more
permissive than 'path', so storage pools and storage volumes
will now validate with a wider set of file names than before.
I don't think this should be a problem in practice.

* docs/schemas/storagepool.rng: Include basic types, rather than
repeating things here.
* docs/schemas/storagevol.rng: Likewise.
* docs/schemas/basictypes.rng: Add 'unsignedLong', 'unit', and fix
to match storage code.

docs/schemas/basictypes.rng
docs/schemas/storagepool.rng
docs/schemas/storagevol.rng

index 3b4b952f26ec8dc94486693fb8d8d4ca5a51e12a..4f16fa7d216fab60cb52ccc953a759cdadd4708b 100644 (file)
@@ -8,6 +8,11 @@
       <param name="pattern">[0-9]+</param>
     </data>
   </define>
+  <define name='unsignedLong'>
+    <data type='unsignedLong'>
+      <param name='pattern'>[0-9]+</param>
+    </data>
+  </define>
 
   <define name="positiveInteger">
     <data type="positiveInteger">
     </data>
   </define>
 
+  <define name='unit'>
+    <data type='string'>
+      <param name='pattern'>[kKmMgGtTpPeE]</param>
+    </data>
+  </define>
+
 </grammar>
index 330147296a4155edb38991a1aefc3844dc5716aa..6399f12e34a245602405989dde160bfce848b42f 100644 (file)
@@ -2,6 +2,7 @@
 <!-- A Relax NG schema for the libvirt storage pool XML format -->
 <grammar xmlns="http://relaxng.org/ns/structure/1.0"
     datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
+  <include href='basictypes.rng'/>
   <start>
     <ref name='pool'/>
   </start>
     </element>
     <optional>
       <element name='uuid'>
-        <ref name='uuid'/>
+        <ref name='UUID'/>
       </element>
     </optional>
   </define>
   <define name='sizing'>
     <optional>
       <element name='capacity'>
-        <ref name='uint'/>
+        <ref name='unsignedLong'/>
       </element>
     </optional>
     <optional>
       <element name='allocation'>
-        <ref name='uint'/>
+        <ref name='unsignedLong'/>
       </element>
     </optional>
     <optional>
       <element name='available'>
-        <ref name='uint'/>
+        <ref name='unsignedLong'/>
       </element>
     </optional>
   </define>
     <optional>
       <element name='permissions'>
         <element name='mode'>
-          <ref name='uint'/>
+          <ref name='unsignedInt'/>
         </element>
         <element name='owner'>
-          <ref name='uint'/>
+          <ref name='unsignedInt'/>
         </element>
         <element name='group'>
-          <ref name='uint'/>
+          <ref name='unsignedInt'/>
         </element>
         <optional>
           <element name='label'>
     <element name='target'>
       <optional>
         <element name='path'>
-          <ref name='path'/>
+          <ref name='absFilePath'/>
         </element>
       </optional>
       <ref name='permissions'/>
     <element name='device'>
       <attribute name='path'>
         <choice>
-          <ref name='path'/>
+          <ref name='absFilePath'/>
           <ref name='name'/>
         </choice>
       </attribute>
     <oneOrMore>
       <element name='freeExtent'>
         <attribute name='start'>
-          <ref name='uint'/>
+          <ref name='unsignedLong'/>
         </attribute>
         <attribute name='end'>
-          <ref name='uint'/>
+          <ref name='unsignedLong'/>
         </attribute>
       </element>
     </oneOrMore>
   <define name='sourceinfodir'>
     <element name='dir'>
       <attribute name='path'>
-        <ref name='path'/>
+        <ref name='absFilePath'/>
       </attribute>
       <empty/>
     </element>
       <param name="pattern">[a-zA-Z0-9_\+\-]+</param>
     </data>
   </define>
-  <define name='uuid'>
-    <choice>
-      <data type='string'>
-        <param name="pattern">[a-fA-F0-9]{32}</param>
-      </data>
-      <data type='string'>
-        <param name="pattern">[a-fA-F0-9]{8}\-([a-fA-F0-9]{4}\-){3}[a-fA-F0-9]{12}</param>
-      </data>
-    </choice>
-  </define>
-
-  <define name='uint'>
-    <data type='string'>
-      <param name="pattern">[0-9]+</param>
-    </data>
-  </define>
-
-  <define name='path'>
-    <data type='string'>
-      <param name="pattern">/[a-zA-Z0-9_\+\-/%]+</param>
-    </data>
-  </define>
 
   <define name="PortNumber">
     <data type="short">
index 994004d997f07ee186d82c6de4df0498f967a76f..d06884c9309d25319fa4813472213dbd3f28e68d 100644 (file)
@@ -1,6 +1,8 @@
+<?xml version="1.0"?>
 <!-- A Relax NG schema for the libvirt storage volume XML format -->
 <grammar xmlns="http://relaxng.org/ns/structure/1.0"
     datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
+  <include href='basictypes.rng'/>
   <start>
     <ref name='vol'/>
   </start>
             <ref name='unit'/>
           </attribute>
         </optional>
-        <ref name='uint'/>
+        <ref name='unsignedLong'/>
       </element>
     </optional>
     <optional>
       <element name='allocation'>
-        <ref name='uint'/>
+        <optional>
+          <attribute name='unit'>
+            <ref name='unit'/>
+          </attribute>
+        </optional>
+        <ref name='unsignedLong'/>
       </element>
     </optional>
   </define>
     <optional>
       <element name='permissions'>
         <element name='mode'>
-          <ref name='uint'/>
+          <ref name='unsignedInt'/>
         </element>
         <element name='owner'>
-          <ref name='uint'/>
+          <ref name='unsignedInt'/>
         </element>
         <element name='group'>
-          <ref name='uint'/>
+          <ref name='unsignedInt'/>
         </element>
         <optional>
           <element name='label'>
@@ -70,7 +77,7 @@
     <element name='target'>
       <optional>
         <element name='path'>
-          <ref name='path'/>
+          <ref name='absFilePath'/>
         </element>
       </optional>
       <ref name='format'/>
@@ -84,7 +91,7 @@
   <define name='backingStore'>
     <element name='backingStore'>
       <element name='path'>
-        <ref name='path'/>
+        <ref name='absFilePath'/>
       </element>
       <ref name='format'/>
       <ref name='permissions'/>
   <define name='sourcedev'>
     <element name='device'>
       <attribute name='path'>
-        <ref name='path'/>
+        <ref name='absFilePath'/>
       </attribute>
       <choice>
         <empty/>
     <oneOrMore>
       <element name='extent'>
         <attribute name='start'>
-          <ref name='uint'/>
+          <ref name='unsignedLong'/>
         </attribute>
         <attribute name='end'>
-          <ref name='uint'/>
+          <ref name='unsignedLong'/>
         </attribute>
       </element>
     </oneOrMore>
     </data>
   </define>
 
-  <define name='uint'>
-    <data type='string'>
-      <param name="pattern">[0-9]+</param>
-    </data>
-  </define>
-
-  <define name='path'>
-    <data type='string'>
-      <param name="pattern">/[a-zA-Z0-9_\+\-\./%]+</param>
-    </data>
-  </define>
-
-  <define name='unit'>
-    <data type='string'>
-      <param name="pattern">[kKmMgGtTpPyYzZ]</param>
-    </data>
-  </define>
-
-  <define name="UUID">
-    <choice>
-      <data type="string">
-        <param name="pattern">[a-fA-F0-9]{32}</param>
-      </data>
-      <data type="string">
-        <param name="pattern">[a-fA-F0-9]{8}\-([a-fA-F0-9]{4}\-){3}[a-fA-F0-9]{12}</param>
-      </data>
-    </choice>
-  </define>
-
 </grammar>