提交 ab995c1f 编写于 作者: J John Ferlan

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: NJohn Ferlan <jferlan@redhat.com>
Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 7a227688
...@@ -4284,6 +4284,7 @@ virStorageBackendFileSystemGetPoolSource(virStoragePoolObjPtr pool) ...@@ -4284,6 +4284,7 @@ virStorageBackendFileSystemGetPoolSource(virStoragePoolObjPtr pool)
static void static void
virStorageBackendFileSystemMountAddOptions(virCommandPtr cmd, virStorageBackendFileSystemMountAddOptions(virCommandPtr cmd,
virStoragePoolDefPtr def,
const char *providedOpts) const char *providedOpts)
{ {
VIR_AUTOFREE(char *) mountOpts = NULL; VIR_AUTOFREE(char *) mountOpts = NULL;
...@@ -4295,6 +4296,19 @@ virStorageBackendFileSystemMountAddOptions(virCommandPtr cmd, ...@@ -4295,6 +4296,19 @@ virStorageBackendFileSystemMountAddOptions(virCommandPtr cmd,
if (providedOpts) if (providedOpts)
virBufferAsprintf(&buf, "%s,", 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); virBufferTrim(&buf, ",", -1);
mountOpts = virBufferContentAndReset(&buf); mountOpts = virBufferContentAndReset(&buf);
...@@ -4310,7 +4324,7 @@ virStorageBackendFileSystemMountNFSArgs(virCommandPtr cmd, ...@@ -4310,7 +4324,7 @@ virStorageBackendFileSystemMountNFSArgs(virCommandPtr cmd,
const char *nfsVers) const char *nfsVers)
{ {
virCommandAddArgList(cmd, src, def->target.path, NULL); virCommandAddArgList(cmd, src, def->target.path, NULL);
virStorageBackendFileSystemMountAddOptions(cmd, nfsVers); virStorageBackendFileSystemMountAddOptions(cmd, def, nfsVers);
} }
...@@ -4323,7 +4337,7 @@ virStorageBackendFileSystemMountGlusterArgs(virCommandPtr cmd, ...@@ -4323,7 +4337,7 @@ virStorageBackendFileSystemMountGlusterArgs(virCommandPtr cmd,
fmt = virStoragePoolFormatFileSystemNetTypeToString(def->source.format); fmt = virStoragePoolFormatFileSystemNetTypeToString(def->source.format);
virCommandAddArgList(cmd, "-t", fmt, src, def->target.path, NULL); 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, ...@@ -4336,7 +4350,7 @@ virStorageBackendFileSystemMountCIFSArgs(virCommandPtr cmd,
fmt = virStoragePoolFormatFileSystemNetTypeToString(def->source.format); fmt = virStoragePoolFormatFileSystemNetTypeToString(def->source.format);
virCommandAddArgList(cmd, "-t", fmt, src, def->target.path, NULL); virCommandAddArgList(cmd, "-t", fmt, src, def->target.path, NULL);
virStorageBackendFileSystemMountAddOptions(cmd, "guest"); virStorageBackendFileSystemMountAddOptions(cmd, def, "guest");
} }
...@@ -4353,7 +4367,7 @@ virStorageBackendFileSystemMountDefaultArgs(virCommandPtr cmd, ...@@ -4353,7 +4367,7 @@ virStorageBackendFileSystemMountDefaultArgs(virCommandPtr cmd,
else else
fmt = virStoragePoolFormatFileSystemNetTypeToString(def->source.format); fmt = virStoragePoolFormatFileSystemNetTypeToString(def->source.format);
virCommandAddArgList(cmd, "-t", fmt, src, def->target.path, NULL); virCommandAddArgList(cmd, "-t", fmt, src, def->target.path, NULL);
virStorageBackendFileSystemMountAddOptions(cmd, nfsVers); virStorageBackendFileSystemMountAddOptions(cmd, def, nfsVers);
} }
......
mount -t nfs localhost:/var/lib/libvirt/images /mnt -o nosuid,noexec,nfsvers=3,\
sync,lazytime
mount -t nfs localhost:/var/lib/libvirt/images /mnt -o nodev,nosuid,noexec,\
nfsvers=3,sync,lazytime
mount -t nfs localhost:/var/lib/libvirt/images /mnt -o nfsvers=3,sync,lazytime
...@@ -162,6 +162,9 @@ mymain(void) ...@@ -162,6 +162,9 @@ mymain(void)
#define DO_TEST_FREEBSD(pool, ...) \ #define DO_TEST_FREEBSD(pool, ...) \
DO_TEST_FULL(false, pool, false, true) DO_TEST_FULL(false, pool, false, true)
if (storageRegisterAll() < 0)
return EXIT_FAILURE;
DO_TEST_FAIL("pool-dir"); DO_TEST_FAIL("pool-dir");
DO_TEST_FAIL("pool-dir-naming"); DO_TEST_FAIL("pool-dir-naming");
DO_TEST("pool-logical"); DO_TEST("pool-logical");
...@@ -177,6 +180,7 @@ mymain(void) ...@@ -177,6 +180,7 @@ mymain(void)
DO_TEST_LINUX("pool-netfs"); DO_TEST_LINUX("pool-netfs");
DO_TEST_LINUX("pool-netfs-auto"); DO_TEST_LINUX("pool-netfs-auto");
DO_TEST_LINUX("pool-netfs-protocol-ver"); 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-gluster");
DO_TEST_LINUX("pool-netfs-cifs"); DO_TEST_LINUX("pool-netfs-cifs");
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__)
...@@ -184,6 +188,7 @@ mymain(void) ...@@ -184,6 +188,7 @@ mymain(void)
DO_TEST_FREEBSD("pool-netfs"); DO_TEST_FREEBSD("pool-netfs");
DO_TEST_FREEBSD("pool-netfs-auto"); DO_TEST_FREEBSD("pool-netfs-auto");
DO_TEST_FREEBSD("pool-netfs-protocol-ver"); 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-gluster");
DO_TEST_FREEBSD("pool-netfs-cifs"); DO_TEST_FREEBSD("pool-netfs-cifs");
#else #else
...@@ -191,6 +196,7 @@ mymain(void) ...@@ -191,6 +196,7 @@ mymain(void)
DO_TEST("pool-netfs"); DO_TEST("pool-netfs");
DO_TEST("pool-netfs-auto"); DO_TEST("pool-netfs-auto");
DO_TEST("pool-netfs-protocol-ver"); DO_TEST("pool-netfs-protocol-ver");
DO_TEST("pool-netfs-ns-mountopts");
DO_TEST("pool-netfs-gluster"); DO_TEST("pool-netfs-gluster");
DO_TEST("pool-netfs-cifs"); DO_TEST("pool-netfs-cifs");
#endif #endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册