[libvirt] [PATCH] schema: pool: netfs: Don't enforce slash in glusterfs pool source

Peter Krempa pkrempa at redhat.com
Fri Jul 11 10:11:33 UTC 2014


Gluster volumes don't start with a leading slash. Our schema for netfs
gluster pools enforces it though. Luckily mount.glusterfs skips it.
Allow a slashless volume name for glusterfs netfs mounts in the schema.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1101999
---
 docs/schemas/basictypes.rng                        |  6 +++
 docs/schemas/storagepool.rng                       | 44 +++++++++++++++++-----
 .../pool-netfs-gluster-without-slash.xml           | 12 ++++++
 3 files changed, 53 insertions(+), 9 deletions(-)
 create mode 100644 tests/storagepoolxml2xmlin/pool-netfs-gluster-without-slash.xml

diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng
index 5fe3a97..9c9419f 100644
--- a/docs/schemas/basictypes.rng
+++ b/docs/schemas/basictypes.rng
@@ -231,6 +231,12 @@
     </data>
   </define>

+  <define name="dirPath">
+    <data type="string">
+      <param name="pattern">[a-zA-Z0-9_\.\+\-\\&"'<>/%]*</param>
+    </data>
+  </define>
+
   <define name="absFilePath">
     <data type="string">
       <param name="pattern">/[a-zA-Z0-9_\.\+\-\\&"'<>/%,]+</param>
diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng
index 8d7a94d..b2d1473 100644
--- a/docs/schemas/storagepool.rng
+++ b/docs/schemas/storagepool.rng
@@ -327,6 +327,15 @@
     </element>
   </define>

+  <define name='sourceinfonetfsgluster'>
+    <element name='dir'>
+      <attribute name='path'>
+        <ref name='dirPath'/>
+      </attribute>
+      <empty/>
+    </element>
+  </define>
+
   <define name='sourceinfoname'>
     <element name='name'>
       <text/>
@@ -394,7 +403,6 @@
             <value>auto</value>
             <value>nfs</value>
             <value>cifs</value>
-            <value>glusterfs</value>
           </choice>
         </attribute>
       </element>
@@ -468,14 +476,32 @@

   <define name='sourcenetfs'>
     <element name='source'>
-      <interleave>
-        <ref name='sourceinfohost'/>
-        <ref name='sourceinfodir'/>
-        <ref name='sourcefmtnetfs'/>
-        <optional>
-          <ref name='sourceinfovendor'/>
-        </optional>
-      </interleave>
+      <choice>
+        <group>
+          <interleave>
+            <ref name='sourceinfohost'/>
+            <ref name='sourceinfodir'/>
+            <ref name='sourcefmtnetfs'/>
+            <optional>
+                <ref name='sourceinfovendor'/>
+            </optional>
+          </interleave>
+        </group>
+        <group>
+          <interleave>
+            <ref name='sourceinfohost'/>
+            <ref name='sourceinfonetfsgluster'/>
+            <element name='format'>
+              <attribute name='type'>
+                <value>glusterfs</value>
+              </attribute>
+            </element>
+            <optional>
+                <ref name='sourceinfovendor'/>
+            </optional>
+          </interleave>
+        </group>
+      </choice>
     </element>
   </define>

diff --git a/tests/storagepoolxml2xmlin/pool-netfs-gluster-without-slash.xml b/tests/storagepoolxml2xmlin/pool-netfs-gluster-without-slash.xml
new file mode 100644
index 0000000..69a2c6d
--- /dev/null
+++ b/tests/storagepoolxml2xmlin/pool-netfs-gluster-without-slash.xml
@@ -0,0 +1,12 @@
+<pool type='netfs'>
+  <source>
+    <host name='example.com'/>
+    <format type='glusterfs'/>
+    <dir path='volume'/>
+  </source>
+  <name>netfs-gluster</name>
+  <uuid>d5609ced-94b1-489e-b218-eff35c30336a</uuid>
+  <target>
+    <path>/mnt/gluster</path>
+  </target>
+</pool>
-- 
2.0.0




More information about the libvir-list mailing list