]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Add optional NFS Source Pool <protocol ver='n'/> option
authorJohn Ferlan <jferlan@redhat.com>
Fri, 11 Jan 2019 00:23:27 +0000 (19:23 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 30 Jan 2019 00:15:27 +0000 (19:15 -0500)
Add an optional way to define which NFS Server version will be
used to content the target NFS server.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
docs/formatstorage.html.in
docs/schemas/storagepool.rng
src/conf/storage_conf.c
src/conf/storage_conf.h
tests/storagepoolxml2xmlin/pool-netfs-protocol-ver.xml [new file with mode: 0644]
tests/storagepoolxml2xmlout/pool-netfs-protocol-ver.xml [new file with mode: 0644]
tests/storagepoolxml2xmltest.c

index be4aa26105cc9abe891fe14dab7ada638d68dee6..85107c85ae6030679737ce539c8de41e3bc6d1f9 100644 (file)
 &lt;/source&gt;
 ...</pre>
 
+    <pre>
+...
+  &lt;source&gt;
+    &lt;host name='localhost'/&gt;
+    &lt;dir path='/var/lib/libvirt/images'/&gt;
+    &lt;format type='nfs'/&gt;
+    &lt;protocol ver='3'/&gt;
+  &lt;/source&gt;
+...</pre>
+
     <dl>
       <dt><code>device</code></dt>
       <dd>Provides the source for pools backed by physical devices
         LVM metadata type. All drivers are required to have a default
         value for this, so it is optional. <span class="since">Since 0.4.1</span></dd>
 
+      <dt><code>protocol</code></dt>
+      <dd>For a <code>netfs</code> Storage Pool provide a mechanism to
+        define which NFS protocol version number will be used to contact
+        the server's NFS service. The attribute <code>ver</code> accepts
+        an unsigned integer as the version number to use.
+        <span class="since">Since 5.1.0</span></dd>
       <dt><code>vendor</code></dt>
       <dd>Provides optional information about the vendor of the
         storage device. This contains a single
index 74f436310629ea901583bb41ddb5681101f8743a..f9a16422cc89af725fec1c0b1ed0c53b51562f08 100644 (file)
             <ref name='sourceinfohost'/>
             <ref name='sourceinfodir'/>
             <ref name='sourcefmtnetfs'/>
+            <optional>
+              <element name='protocol'>
+                <attribute name='ver'>
+                  <ref name='unsignedInt'/>
+                </attribute>
+              </element>
+            </optional>
             <optional>
               <ref name='sourceinfovendor'/>
             </optional>
index ba5b1f1783ec8fe7579002bbd0c27b9318d85b6f..bb666af3ecee67171417d6e02bf23bccc97f05e9 100644 (file)
@@ -420,6 +420,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
     virStorageAuthDefPtr authdef = NULL;
     char *name = NULL;
     char *port = NULL;
+    char *ver = NULL;
     int n;
 
     relnode = ctxt->node;
@@ -546,6 +547,24 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
         authdef = NULL;
     }
 
+    /* Option protocol version string (NFSvN) */
+    if ((ver = virXPathString("string(./protocol/@ver)", ctxt))) {
+        if ((source->format != VIR_STORAGE_POOL_NETFS_NFS) &&
+            (source->format != VIR_STORAGE_POOL_NETFS_AUTO)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("storage pool protocol ver unsupported for "
+                             "pool type '%s'"),
+                           virStoragePoolFormatFileSystemNetTypeToString(source->format));
+            goto cleanup;
+        }
+        if (virStrToLong_uip(ver, NULL, 0, &source->protocolVer) < 0) {
+            virReportError(VIR_ERR_XML_ERROR,
+                           _("storage pool protocol ver '%s' is malformaed"),
+                           ver);
+            goto cleanup;
+        }
+    }
+
     source->vendor = virXPathString("string(./vendor/@name)", ctxt);
     source->product = virXPathString("string(./product/@name)", ctxt);
 
@@ -961,6 +980,9 @@ virStoragePoolSourceFormat(virBufferPtr buf,
     if (src->auth)
         virStorageAuthDefFormat(buf, src->auth);
 
+    if (src->protocolVer)
+        virBufferAsprintf(buf, "<protocol ver='%u'/>\n", src->protocolVer);
+
     virBufferEscapeString(buf, "<vendor name='%s'/>\n", src->vendor);
     virBufferEscapeString(buf, "<product name='%s'/>\n", src->product);
 
index dc0aa2ab2919a8adedb640c2068f9d37d5d97649..a6763447a742270ef6a90fb0ba664951beead0a0 100644 (file)
@@ -197,6 +197,9 @@ struct _virStoragePoolSource {
      * or lvm version, etc.
      */
     int format;
+
+    /* Protocol version value for netfs */
+    unsigned int protocolVer;
 };
 
 typedef struct _virStoragePoolTarget virStoragePoolTarget;
diff --git a/tests/storagepoolxml2xmlin/pool-netfs-protocol-ver.xml b/tests/storagepoolxml2xmlin/pool-netfs-protocol-ver.xml
new file mode 100644 (file)
index 0000000..40f3f94
--- /dev/null
@@ -0,0 +1,21 @@
+<pool type='netfs'>
+  <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'/>
+    <protocol ver='3'/>
+  </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-protocol-ver.xml b/tests/storagepoolxml2xmlout/pool-netfs-protocol-ver.xml
new file mode 100644 (file)
index 0000000..5fcad13
--- /dev/null
@@ -0,0 +1,21 @@
+<pool type='netfs'>
+  <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'/>
+    <protocol ver='3'/>
+  </source>
+  <target>
+    <path>/mnt</path>
+    <permissions>
+      <mode>0700</mode>
+      <owner>0</owner>
+      <group>0</group>
+    </permissions>
+  </target>
+</pool>
index 707d09f5c28070fcbecae2c5951e9add5cfede12..d18390034fc3fef62b5ebc97d172c2f070a184ad 100644 (file)
@@ -83,6 +83,7 @@ mymain(void)
     DO_TEST("pool-iscsi-auth");
     DO_TEST("pool-netfs");
     DO_TEST("pool-netfs-auto");
+    DO_TEST("pool-netfs-protocol-ver");
     DO_TEST("pool-netfs-gluster");
     DO_TEST("pool-netfs-cifs");
     DO_TEST("pool-scsi");