[libvirt] [PATCH 3/3] virsh: Add source-mount-opts for pool commands

John Ferlan jferlan at redhat.com
Tue Dec 18 20:03:17 UTC 2018


Add the ability to add the mount options for the pool on the
virsh command line for pool-{create|define}-as commands.

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 tools/virsh-pool.c | 15 ++++++++++++---
 tools/virsh.pod    |  5 +++++
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c
index 75ec572af2..8c14de97f1 100644
--- a/tools/virsh-pool.c
+++ b/tools/virsh-pool.c
@@ -141,6 +141,10 @@
     {.name = "adapter-parent-fabric-wwn", \
      .type = VSH_OT_STRING, \
      .help = N_("adapter parent scsi_hostN fabric_wwn to be used for underlying vHBA storage") \
+    }, \
+    {.name = "source-mount-opts", \
+     .type = VSH_OT_STRING, \
+     .help = N_("source mount options for an nfs pool's source-path") \
     }
 
 virStoragePoolPtr
@@ -324,7 +328,7 @@ virshBuildPoolXML(vshControl *ctl,
                *secretUsage = NULL, *adapterName = NULL, *adapterParent = NULL,
                *adapterWwnn = NULL, *adapterWwpn = NULL, *secretUUID = NULL,
                *adapterParentWwnn = NULL, *adapterParentWwpn = NULL,
-               *adapterParentFabricWwn = NULL;
+               *adapterParentFabricWwn = NULL, *mountOpts = NULL;
     virBuffer buf = VIR_BUFFER_INITIALIZER;
 
     VSH_EXCLUSIVE_OPTIONS("secret-usage", "secret-uuid");
@@ -336,6 +340,7 @@ virshBuildPoolXML(vshControl *ctl,
 
     if (vshCommandOptStringReq(ctl, cmd, "source-host", &srcHost) < 0 ||
         vshCommandOptStringReq(ctl, cmd, "source-path", &srcPath) < 0 ||
+        vshCommandOptStringReq(ctl, cmd, "source-mount-opts", &mountOpts) < 0 ||
         vshCommandOptStringReq(ctl, cmd, "source-dev", &srcDev) < 0 ||
         vshCommandOptStringReq(ctl, cmd, "source-name", &srcName) < 0 ||
         vshCommandOptStringReq(ctl, cmd, "source-format", &srcFormat) < 0 ||
@@ -363,8 +368,12 @@ virshBuildPoolXML(vshControl *ctl,
 
         if (srcHost)
             virBufferAsprintf(&buf, "<host name='%s'/>\n", srcHost);
-        if (srcPath)
-            virBufferAsprintf(&buf, "<dir path='%s'/>\n", srcPath);
+        if (srcPath) {
+            virBufferAsprintf(&buf, "<dir path='%s'", srcPath);
+            if (mountOpts)
+                virBufferAsprintf(&buf, " mount_opts='%s'", mountOpts);
+            virBufferAddLit(&buf, "/>\n");
+        }
         if (srcDev)
             virBufferAsprintf(&buf, "<device path='%s'/>\n", srcDev);
         if (adapterWwnn && adapterWwpn) {
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 86a4996cae..aa40c580ab 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -3884,6 +3884,7 @@ just I<--build> is provided, then B<pool-build> is called with no flags.
 
 =item B<pool-create-as> I<name> I<type>
 [I<--source-host hostname>] [I<--source-path path>] [I<--source-dev path>]
+[I<--source-mount-opts mountOpts>]
 [I<--source-name name>] [I<--target path>] [I<--source-format format>]
 [I<--auth-type authtype> I<--auth-username username>
 [I<--secret-usage usage> | I<--secret-uuid uuid>]]
@@ -3910,6 +3911,10 @@ gluster).
 [I<--source-path path>] provides the source directory path for pools backed
 by directories (pool type dir).
 
+[<--source-mount-opts mountOpts>] provides a string to be used when creating
+the mount command for a netfs type pool. The options should be in a comma
+separated list format as described by the mount options command.
+
 [I<--source-dev path>] provides the source path for pools backed by physical
 devices (pool types fs, logical, disk, iscsi, zfs).
 
-- 
2.17.2




More information about the libvir-list mailing list