From nobody Wed Nov 27 14:20:21 2024 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 154696998586990.76912689952565; Tue, 8 Jan 2019 09:53:05 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ECA6780F7D; Tue, 8 Jan 2019 17:53:02 +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 9D3B21A917; Tue, 8 Jan 2019 17:53:02 +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 498841888B46; Tue, 8 Jan 2019 17:53:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x08HqYME025789 for ; Tue, 8 Jan 2019 12:52:34 -0500 Received: by smtp.corp.redhat.com (Postfix) id D493B60C67; Tue, 8 Jan 2019 17:52:34 +0000 (UTC) Received: from unknown0050b6a41c42.attlocal.net.com (ovpn-116-153.phx2.redhat.com [10.3.116.153]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8ED6684E0 for ; Tue, 8 Jan 2019 17:52:34 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 8 Jan 2019 12:52:24 -0500 Message-Id: <20190108175226.32693-5-jferlan@redhat.com> In-Reply-To: <20190108175226.32693-1-jferlan@redhat.com> References: <20190108175226.32693-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 4/6] storage: Add NFS storage pool mount options to command line 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 08 Jan 2019 17:53:04 +0000 (UTC) Content-Type: text/plain; charset="utf-8" If the NetFS Storage Pool Namespace XML data exists, format the mount options on the MOUNT command line. When the pool is started, the options will be generated on the command line along with the exportfs options already defined. To view the options of the running pool, use either 'nfsstat -m' or 'grep $POOLNAME /proc/mounts' for the added Flags/options. Signed-off-by: John Ferlan --- src/storage/storage_util.c | 20 +++++++++++++++++++ .../pool-netfs-mountopts.argv | 1 + tests/storagepoolxml2argvtest.c | 4 ++++ 3 files changed, 25 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 ff0a0239e6..debf5aa133 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -4352,6 +4352,26 @@ virStorageBackendFileSystemMountCmd(const char *cmds= tr, virStorageBackendFileSystemMountCIFSArgs(cmd, src, def); else virStorageBackendFileSystemMountDefaultArgs(cmd, src, def); + + if (def->type =3D=3D VIR_STORAGE_POOL_NETFS && def->source.namespaceDa= ta) { + size_t i; + virStoragePoolNetFSMountOptionsDefPtr opts =3D def->source.namespa= ceData; + virBuffer buf =3D VIR_BUFFER_INITIALIZER; + VIR_AUTOFREE(char *) mountOpts =3D NULL; + + for (i =3D 0; i < opts->noptions; i++) + virBufferAsprintf(&buf, "%s,", opts->options[i]); + + virBufferTrim(&buf, ",", -1); + + if (virBufferCheckError(&buf) < 0) + return NULL; + + mountOpts =3D virBufferContentAndReset(&buf); + + virCommandAddArgList(cmd, "-o", mountOpts, NULL); + } + return cmd; } =20 diff --git a/tests/storagepoolxml2argvdata/pool-netfs-mountopts.argv b/test= s/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/storagepoolxml2argvtes= t.c index 2f2d40e027..338fe6d5f5 100644 --- a/tests/storagepoolxml2argvtest.c +++ b/tests/storagepoolxml2argvtest.c @@ -144,6 +144,9 @@ mymain(void) #define DO_TEST_FAIL(pool, ...) \ DO_TEST_FULL(true, pool) =20 + if (storageRegisterAll() < 0) + return EXIT_FAILURE; + DO_TEST_FAIL("pool-dir"); DO_TEST_FAIL("pool-dir-naming"); DO_TEST("pool-fs"); @@ -159,6 +162,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"); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list