[PATCH v2 3/6] docs, tests: Add schema, description, and tests for NFS namespace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Modify the storagepool.rng to allow for the usage of a different
XML namespace to parse the netfs_mount_opts to be included with
the storage source.

Modify the storagepoolxml2xmltest to utilize a properly modified
XML file to parse and format the namespace for a netfs storage pool.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 docs/formatstorage.html.in                    | 42 +++++++++++++++++++
 docs/schemas/storagepool.rng                  | 20 +++++++++
 tests/Makefile.am                             |  4 +-
 .../pool-netfs-mountopts.xml                  | 24 +++++++++++
 .../pool-netfs-mountopts.xml                  | 24 +++++++++++
 tests/storagepoolxml2xmltest.c                |  6 +++
 6 files changed, 119 insertions(+), 1 deletion(-)
 create mode 100644 tests/storagepoolxml2xmlin/pool-netfs-mountopts.xml
 create mode 100644 tests/storagepoolxml2xmlout/pool-netfs-mountopts.xml

diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in
index b6bf3edbd2..308b94f5e5 100644
--- a/docs/formatstorage.html.in
+++ b/docs/formatstorage.html.in
@@ -395,6 +395,48 @@
       <dd>Provides an optional product name of the storage device.
         This contains a single attribute <code>name</code> whose value
         is backend specific.  <span class="since">Since 0.8.4</span></dd>
+
+      <dt><code>netfs:mount_opts</code></dt>
+      <dd>Provides an XML namespace mechanism to optionally utilize
+        specifically named options for the mount command via the "-o"
+        option for the <code>netfs</code> type storage pools. In order
+        to designate that the Storage Pool will be using the mechanism,
+        the <code>pool</code> element must be modified to provide the
+        XML namespace attribute syntax as follows:
+
+        <p>
+        xmlns:netfs='http://libvirt.org/schemas/storagepool/source/netfs/1.0'
+        </p>
+
+        <p>
+        The <code>netfs:mount_opts</code> defines the mount options by
+        specifying multiple <code>netfs:option</code> subelements with
+        the attribute <code>name</code> specifying the mount option to
+        be added. The value of the named option is not checked since
+        it's possible options don't exist on all distributions. It is
+        expected that proper and valid options will be supplied for the
+        target host.
+        </p>
+
+        The following XML snippet shows the syntax required in order to
+        utilize
+      <pre>
+&lt;pool type="netfs" xmlns:netfs='http://libvirt.org/schemas/storagepool/source/netfs/1.0'&gt;
+  &lt;name&gt;nfsimages&lt;/name&gt;
+...
+  &lt;source&gt;
+    &lt;host name='localhost'/&gt;
+    &lt;dir path='/var/lib/libvirt/images'/&gt;
+    &lt;format type='nfs'/&gt;
+    &lt;netfs:mount_opts&gt;
+      &lt;netfs:option name='nodev'/&gt;
+      &lt;netfs:option name='nosuid'/&gt;
+    &lt;/netfs:mount_opts&gt;
+  &lt;/source&gt;
+...</pre>
+
+      <span class="since">Since 5.0.0.</span></dd>
+
     </dl>
 
     <h3><a id="StoragePoolTarget">Target elements</a></h3>
diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng
index 74f4363106..20c7ae5744 100644
--- a/docs/schemas/storagepool.rng
+++ b/docs/schemas/storagepool.rng
@@ -534,6 +534,9 @@
             <optional>
               <ref name='sourceinfovendor'/>
             </optional>
+            <optional>
+              <ref name='netfs_mount_opts'/>
+            </optional>
           </interleave>
         </group>
         <group>
@@ -675,4 +678,21 @@
     </data>
   </define>
 
+  <!--
+       Optional storage pool extensions in their own namespace:
+         NetFS
+    -->
+
+  <define name="netfs_mount_opts">
+    <element name="mount_opts" ns="http://libvirt.org/schemas/storagepool/source/netfs/1.0";>
+      <zeroOrMore>
+        <element name="option">
+          <attribute name='name'>
+            <text/>
+          </attribute>
+        </element>
+      </zeroOrMore>
+    </element>
+  </define>
+
 </grammar>
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f74d8463b6..373d347389 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -937,7 +937,9 @@ storagevolxml2xmltest_LDADD = $(LDADDS)
 storagepoolxml2xmltest_SOURCES = \
 	storagepoolxml2xmltest.c \
 	testutils.c testutils.h
-storagepoolxml2xmltest_LDADD = $(LDADDS)
+storagepoolxml2xmltest_LDADD = $(LDADDS) \
+	../src/libvirt_driver_storage_impl.la \
+	../gnulib/lib/libgnu.la
 
 nodedevxml2xmltest_SOURCES = \
 	nodedevxml2xmltest.c \
diff --git a/tests/storagepoolxml2xmlin/pool-netfs-mountopts.xml b/tests/storagepoolxml2xmlin/pool-netfs-mountopts.xml
new file mode 100644
index 0000000000..2b720656c7
--- /dev/null
+++ b/tests/storagepoolxml2xmlin/pool-netfs-mountopts.xml
@@ -0,0 +1,24 @@
+<pool type='netfs' xmlns:netfs='http://libvirt.org/schemas/storagepool/source/netfs/1.0'>
+  <name>nfsimages</name>
+  <uuid>7641d5a8-af11-f730-a34e-0a7dfcede71f</uuid>
+  <capacity>0</capacity>
+  <allocation>0</allocation>
+  <available>0</available>
+  <source>
+    <host name='localhost'/>
+    <dir path='/var/lib/libvirt/images'/>
+    <format type='nfs'/>
+    <netfs:mount_opts>
+      <netfs:option name='nodev'/>
+      <netfs:option name='nosuid'/>
+    </netfs:mount_opts>
+  </source>
+  <target>
+    <path>/mnt</path>
+    <permissions>
+      <mode>0700</mode>
+      <owner>0</owner>
+      <group>0</group>
+    </permissions>
+  </target>
+</pool>
diff --git a/tests/storagepoolxml2xmlout/pool-netfs-mountopts.xml b/tests/storagepoolxml2xmlout/pool-netfs-mountopts.xml
new file mode 100644
index 0000000000..ec78ff0d2f
--- /dev/null
+++ b/tests/storagepoolxml2xmlout/pool-netfs-mountopts.xml
@@ -0,0 +1,24 @@
+<pool type='netfs' xmlns:netfs='http://libvirt.org/schemas/storagepool/source/netfs/1.0'>
+  <name>nfsimages</name>
+  <uuid>7641d5a8-af11-f730-a34e-0a7dfcede71f</uuid>
+  <capacity unit='bytes'>0</capacity>
+  <allocation unit='bytes'>0</allocation>
+  <available unit='bytes'>0</available>
+  <source>
+    <host name='localhost'/>
+    <dir path='/var/lib/libvirt/images'/>
+    <format type='nfs'/>
+    <netfs:mount_opts>
+      <netfs:option name='nodev'/>
+      <netfs:option name='nosuid'/>
+    </netfs:mount_opts>
+  </source>
+  <target>
+    <path>/mnt</path>
+    <permissions>
+      <mode>0700</mode>
+      <owner>0</owner>
+      <group>0</group>
+    </permissions>
+  </target>
+</pool>
diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c
index 707d09f5c2..c08313d236 100644
--- a/tests/storagepoolxml2xmltest.c
+++ b/tests/storagepoolxml2xmltest.c
@@ -11,6 +11,8 @@
 #include "testutilsqemu.h"
 #include "virstring.h"
 
+#include "storage/storage_util.h"
+
 #define VIR_FROM_THIS VIR_FROM_NONE
 
 static int
@@ -70,6 +72,9 @@ mymain(void)
                    testCompareXMLToXMLHelper, (name)) < 0) \
         ret = -1
 
+    if (storageRegisterAll() < 0)
+       return EXIT_FAILURE;
+
     DO_TEST("pool-dir");
     DO_TEST("pool-dir-naming");
     DO_TEST("pool-fs");
@@ -85,6 +90,7 @@ mymain(void)
     DO_TEST("pool-netfs-auto");
     DO_TEST("pool-netfs-gluster");
     DO_TEST("pool-netfs-cifs");
+    DO_TEST("pool-netfs-mountopts");
     DO_TEST("pool-scsi");
     DO_TEST("pool-scsi-type-scsi-host");
     DO_TEST("pool-scsi-type-fc-host");
-- 
2.20.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux