From nobody Sun Feb 8 14:51:53 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1548786167049283.68748236121553; Tue, 29 Jan 2019 10:22:47 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C547874EEC; Tue, 29 Jan 2019 18:22:41 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8194717C30; Tue, 29 Jan 2019 18:22:41 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 339E618033EC; Tue, 29 Jan 2019 18:22:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x0TIMFxY002145 for ; Tue, 29 Jan 2019 13:22:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id BB1A32E167; Tue, 29 Jan 2019 18:22:15 +0000 (UTC) Received: from unknown0050b6a41c42.attlocal.net.com (ovpn-116-45.phx2.redhat.com [10.3.116.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BE6F177AB for ; Tue, 29 Jan 2019 18:22:15 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 29 Jan 2019 13:22:07 -0500 Message-Id: <20190129182208.23788-9-jferlan@redhat.com> In-Reply-To: <20190129182208.23788-1-jferlan@redhat.com> References: <20190129182208.23788-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v5 8/9] storage: Add storage pool namespace options to fs and netfs command lines X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 29 Jan 2019 18:22:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Daniel P. Berrang=C3=A9 --- src/storage/storage_util.c | 22 +++++++++++++++---- .../pool-netfs-ns-mountopts-freebsd.argv | 2 ++ .../pool-netfs-ns-mountopts-linux.argv | 2 ++ .../pool-netfs-ns-mountopts.argv | 1 + tests/storagepoolxml2argvtest.c | 6 +++++ 5 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts-f= reebsd.argv create mode 100644 tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts-l= inux.argv create mode 100644 tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts.a= rgv diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 4596cd4518..37b3d58667 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -4284,6 +4284,7 @@ virStorageBackendFileSystemGetPoolSource(virStoragePo= olObjPtr pool) =20 static void virStorageBackendFileSystemMountAddOptions(virCommandPtr cmd, + virStoragePoolDefPtr def, const char *providedOpts) { VIR_AUTOFREE(char *) mountOpts =3D NULL; @@ -4295,6 +4296,19 @@ virStorageBackendFileSystemMountAddOptions(virComman= dPtr cmd, if (providedOpts) virBufferAsprintf(&buf, "%s,", providedOpts); =20 + if (def->namespaceData) { + size_t i; + virStoragePoolFSMountOptionsDefPtr opts =3D def->namespaceData; + char uuidstr[VIR_UUID_STRING_BUFLEN]; + + for (i =3D 0; i < opts->noptions; i++) + virBufferAsprintf(&buf, "%s,", opts->options[i]); + + virUUIDFormat(def->uuid, uuidstr); + VIR_WARN("Storage Pool name=3D'%s' uuid=3D'%s' is tainted by custo= m " + "mount_opts from XML", def->name, uuidstr); + } + virBufferTrim(&buf, ",", -1); mountOpts =3D virBufferContentAndReset(&buf); =20 @@ -4310,7 +4324,7 @@ virStorageBackendFileSystemMountNFSArgs(virCommandPtr= cmd, const char *nfsVers) { virCommandAddArgList(cmd, src, def->target.path, NULL); - virStorageBackendFileSystemMountAddOptions(cmd, nfsVers); + virStorageBackendFileSystemMountAddOptions(cmd, def, nfsVers); } =20 =20 @@ -4323,7 +4337,7 @@ virStorageBackendFileSystemMountGlusterArgs(virComman= dPtr cmd, =20 fmt =3D virStoragePoolFormatFileSystemNetTypeToString(def->source.form= at); virCommandAddArgList(cmd, "-t", fmt, src, def->target.path, NULL); - virStorageBackendFileSystemMountAddOptions(cmd, "direct-io-mode=3D1"); + virStorageBackendFileSystemMountAddOptions(cmd, def, "direct-io-mode= =3D1"); } =20 =20 @@ -4336,7 +4350,7 @@ virStorageBackendFileSystemMountCIFSArgs(virCommandPt= r cmd, =20 fmt =3D virStoragePoolFormatFileSystemNetTypeToString(def->source.form= at); virCommandAddArgList(cmd, "-t", fmt, src, def->target.path, NULL); - virStorageBackendFileSystemMountAddOptions(cmd, "guest"); + virStorageBackendFileSystemMountAddOptions(cmd, def, "guest"); } =20 =20 @@ -4353,7 +4367,7 @@ virStorageBackendFileSystemMountDefaultArgs(virComman= dPtr cmd, else fmt =3D virStoragePoolFormatFileSystemNetTypeToString(def->source.= format); virCommandAddArgList(cmd, "-t", fmt, src, def->target.path, NULL); - virStorageBackendFileSystemMountAddOptions(cmd, nfsVers); + virStorageBackendFileSystemMountAddOptions(cmd, def, nfsVers); } =20 =20 diff --git a/tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts-freebsd.= argv b/tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts-freebsd.argv new file mode 100644 index 0000000000..ac5c0acd00 --- /dev/null +++ b/tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts-freebsd.argv @@ -0,0 +1,2 @@ +mount -t nfs localhost:/var/lib/libvirt/images /mnt -o nosuid,noexec,nfsve= rs=3D3,\ +sync,lazytime diff --git a/tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts-linux.ar= gv b/tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts-linux.argv new file mode 100644 index 0000000000..8e10379c04 --- /dev/null +++ b/tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts-linux.argv @@ -0,0 +1,2 @@ +mount -t nfs localhost:/var/lib/libvirt/images /mnt -o nodev,nosuid,noexec= ,\ +nfsvers=3D3,sync,lazytime diff --git a/tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts.argv b/t= ests/storagepoolxml2argvdata/pool-netfs-ns-mountopts.argv new file mode 100644 index 0000000000..a63d6da456 --- /dev/null +++ b/tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts.argv @@ -0,0 +1 @@ +mount -t nfs localhost:/var/lib/libvirt/images /mnt -o nfsvers=3D3,sync,la= zytime diff --git a/tests/storagepoolxml2argvtest.c b/tests/storagepoolxml2argvtes= t.c index 88059cbdfc..786fb26402 100644 --- a/tests/storagepoolxml2argvtest.c +++ b/tests/storagepoolxml2argvtest.c @@ -162,6 +162,9 @@ mymain(void) #define DO_TEST_FREEBSD(pool, ...) \ DO_TEST_FULL(false, pool, false, true) =20 + 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 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list