[libvirt] [PATCH v3 02/11] storage: Add mountOpts to the storage pool mount command line

John Ferlan jferlan at redhat.com
Wed Jan 16 01:09:13 UTC 2019


https://bugzilla.redhat.com/show_bug.cgi?id=1584663

Add the mountOpts to the generated backend mount command line for
the storage pool.

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 src/storage/storage_util.c                    | 19 +++++++++++++++++++
 .../pool-netfs-mountopts.argv                 |  1 +
 tests/storagepoolxml2argvtest.c               |  1 +
 3 files changed, 21 insertions(+)
 create mode 100644 tests/storagepoolxml2argvdata/pool-netfs-mountopts.argv

diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index a84ee5b600..8fe6139682 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -4336,6 +4336,25 @@ virStorageBackendFileSystemMountCmd(const char *cmdstr,
         virStorageBackendFileSystemMountCIFSArgs(cmd, src, def);
     else
         virStorageBackendFileSystemMountDefaultArgs(cmd, src, def);
+
+    if (def->type == VIR_STORAGE_POOL_NETFS && def->source.mountOpts) {
+        size_t i;
+        virBuffer buf = VIR_BUFFER_INITIALIZER;
+        VIR_AUTOFREE(char *) mountOpts = NULL;
+
+        for (i = 0; i < def->source.nmountOpts; i++)
+            virBufferAsprintf(&buf, "%s,", def->source.mountOpts[i]);
+
+        virBufferTrim(&buf, ",", -1);
+
+        if (virBufferCheckError(&buf) < 0)
+            return NULL;
+
+        mountOpts = virBufferContentAndReset(&buf);
+
+        virCommandAddArgList(cmd, "-o", mountOpts, NULL);
+    }
+
     return cmd;
 }
 
diff --git a/tests/storagepoolxml2argvdata/pool-netfs-mountopts.argv b/tests/storagepoolxml2argvdata/pool-netfs-mountopts.argv
new file mode 100644
index 0000000000..16d35bc175
--- /dev/null
+++ b/tests/storagepoolxml2argvdata/pool-netfs-mountopts.argv
@@ -0,0 +1 @@
+mount -t nfs localhost:/var/lib/libvirt/images /mnt -o nodev,nosuid
diff --git a/tests/storagepoolxml2argvtest.c b/tests/storagepoolxml2argvtest.c
index 2f2d40e027..0df97fb390 100644
--- a/tests/storagepoolxml2argvtest.c
+++ b/tests/storagepoolxml2argvtest.c
@@ -159,6 +159,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_FAIL("pool-scsi");
     DO_TEST_FAIL("pool-scsi-type-scsi-host");
     DO_TEST_FAIL("pool-scsi-type-fc-host");
-- 
2.20.1




More information about the libvir-list mailing list