storage: Add storage pool namespace options to fs and netfs command lines

If the Storage Pool Namespace XML data exists, format the mount
options on the MOUNT command line and issue a VIR_WARN to indicate
that the storage pool was tainted by custom mount_opts.

When the pool is started, the options will be generated on the
command line along with the options already defined.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
John Ferlan 2018-12-12 17:41:14 -05:00
parent 7a227688a8
commit ab995c1fe9
5 changed files with 29 additions and 4 deletions

View File

@ -4284,6 +4284,7 @@ virStorageBackendFileSystemGetPoolSource(virStoragePoolObjPtr pool)
static void
virStorageBackendFileSystemMountAddOptions(virCommandPtr cmd,
virStoragePoolDefPtr def,
const char *providedOpts)
{
VIR_AUTOFREE(char *) mountOpts = NULL;
@ -4295,6 +4296,19 @@ virStorageBackendFileSystemMountAddOptions(virCommandPtr cmd,
if (providedOpts)
virBufferAsprintf(&buf, "%s,", providedOpts);
if (def->namespaceData) {
size_t i;
virStoragePoolFSMountOptionsDefPtr opts = def->namespaceData;
char uuidstr[VIR_UUID_STRING_BUFLEN];
for (i = 0; i < opts->noptions; i++)
virBufferAsprintf(&buf, "%s,", opts->options[i]);
virUUIDFormat(def->uuid, uuidstr);
VIR_WARN("Storage Pool name='%s' uuid='%s' is tainted by custom "
"mount_opts from XML", def->name, uuidstr);
}
virBufferTrim(&buf, ",", -1);
mountOpts = virBufferContentAndReset(&buf);
@ -4310,7 +4324,7 @@ virStorageBackendFileSystemMountNFSArgs(virCommandPtr cmd,
const char *nfsVers)
{
virCommandAddArgList(cmd, src, def->target.path, NULL);
virStorageBackendFileSystemMountAddOptions(cmd, nfsVers);
virStorageBackendFileSystemMountAddOptions(cmd, def, nfsVers);
}
@ -4323,7 +4337,7 @@ virStorageBackendFileSystemMountGlusterArgs(virCommandPtr cmd,
fmt = virStoragePoolFormatFileSystemNetTypeToString(def->source.format);
virCommandAddArgList(cmd, "-t", fmt, src, def->target.path, NULL);
virStorageBackendFileSystemMountAddOptions(cmd, "direct-io-mode=1");
virStorageBackendFileSystemMountAddOptions(cmd, def, "direct-io-mode=1");
}
@ -4336,7 +4350,7 @@ virStorageBackendFileSystemMountCIFSArgs(virCommandPtr cmd,
fmt = virStoragePoolFormatFileSystemNetTypeToString(def->source.format);
virCommandAddArgList(cmd, "-t", fmt, src, def->target.path, NULL);
virStorageBackendFileSystemMountAddOptions(cmd, "guest");
virStorageBackendFileSystemMountAddOptions(cmd, def, "guest");
}
@ -4353,7 +4367,7 @@ virStorageBackendFileSystemMountDefaultArgs(virCommandPtr cmd,
else
fmt = virStoragePoolFormatFileSystemNetTypeToString(def->source.format);
virCommandAddArgList(cmd, "-t", fmt, src, def->target.path, NULL);
virStorageBackendFileSystemMountAddOptions(cmd, nfsVers);
virStorageBackendFileSystemMountAddOptions(cmd, def, nfsVers);
}

View File

@ -0,0 +1,2 @@
mount -t nfs localhost:/var/lib/libvirt/images /mnt -o nosuid,noexec,nfsvers=3,\
sync,lazytime

View File

@ -0,0 +1,2 @@
mount -t nfs localhost:/var/lib/libvirt/images /mnt -o nodev,nosuid,noexec,\
nfsvers=3,sync,lazytime

View File

@ -0,0 +1 @@
mount -t nfs localhost:/var/lib/libvirt/images /mnt -o nfsvers=3,sync,lazytime

View File

@ -162,6 +162,9 @@ mymain(void)
#define DO_TEST_FREEBSD(pool, ...) \
DO_TEST_FULL(false, pool, false, true)
if (storageRegisterAll() < 0)
return EXIT_FAILURE;
DO_TEST_FAIL("pool-dir");
DO_TEST_FAIL("pool-dir-naming");
DO_TEST("pool-logical");
@ -177,6 +180,7 @@ mymain(void)
DO_TEST_LINUX("pool-netfs");
DO_TEST_LINUX("pool-netfs-auto");
DO_TEST_LINUX("pool-netfs-protocol-ver");
DO_TEST_LINUX("pool-netfs-ns-mountopts");
DO_TEST_LINUX("pool-netfs-gluster");
DO_TEST_LINUX("pool-netfs-cifs");
#elif defined(__FreeBSD__)
@ -184,6 +188,7 @@ mymain(void)
DO_TEST_FREEBSD("pool-netfs");
DO_TEST_FREEBSD("pool-netfs-auto");
DO_TEST_FREEBSD("pool-netfs-protocol-ver");
DO_TEST_FREEBSD("pool-netfs-ns-mountopts");
DO_TEST_FREEBSD("pool-netfs-gluster");
DO_TEST_FREEBSD("pool-netfs-cifs");
#else
@ -191,6 +196,7 @@ mymain(void)
DO_TEST("pool-netfs");
DO_TEST("pool-netfs-auto");
DO_TEST("pool-netfs-protocol-ver");
DO_TEST("pool-netfs-ns-mountopts");
DO_TEST("pool-netfs-gluster");
DO_TEST("pool-netfs-cifs");
#endif