From nobody Wed May 1 11:51:27 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 154516342048127.262183852091994; Tue, 18 Dec 2018 12:03:40 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B27CA9F72B; Tue, 18 Dec 2018 20:03:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6A5477C810; Tue, 18 Dec 2018 20:03:37 +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 0FE643D39F; Tue, 18 Dec 2018 20:03:37 +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 wBIK3N4j001810 for ; Tue, 18 Dec 2018 15:03:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id 100D260C44; Tue, 18 Dec 2018 20:03:23 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-117-129.phx2.redhat.com [10.3.117.129]) by smtp.corp.redhat.com (Postfix) with ESMTP id C0DD217BBD for ; Tue, 18 Dec 2018 20:03:22 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 18 Dec 2018 15:03:15 -0500 Message-Id: <20181218200317.24947-2-jferlan@redhat.com> In-Reply-To: <20181218200317.24947-1-jferlan@redhat.com> References: <20181218200317.24947-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/3] storage: Add mount options attribute for pool source dir element 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: , MIME-Version: 1.0 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 18 Dec 2018 20:03:38 +0000 (UTC) Content-Type: text/plain; charset="utf-8" If libvirt creates the command to mount the storage pool, it should be able to provide a list of mount options per the policy of the consumer. Add the "mount_opts" RNG/XML variable and the corresponding _virStoragePoolSource field to take whatever is provided in the XML to use in order to create the command. Signed-off-by: John Ferlan --- docs/formatstorage.html.in | 8 ++++++++ docs/schemas/storagepool.rng | 5 +++++ src/conf/storage_conf.c | 12 +++++++++-- src/conf/storage_conf.h | 3 +++ .../pool-netfs-mountopts.xml | 20 +++++++++++++++++++ .../pool-netfs-mountopts.xml | 20 +++++++++++++++++++ tests/storagepoolxml2xmltest.c | 1 + 7 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 tests/storagepoolxml2xmlin/pool-netfs-mountopts.xml create mode 100644 tests/storagepoolxml2xmlout/pool-netfs-mountopts.xml diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in index b6bf3edbd2..491d75c2b1 100644 --- a/docs/formatstorage.html.in +++ b/docs/formatstorage.html.in @@ -155,6 +155,14 @@ for a netfs pool type using format type "cifs", the path to the Samba share without the leading slash. Since 0.4.1 + +

An optional mount_opts may be provided to add + mount options for pools such as netfs in order to + provide a list of mount options to be provided to the mount command + via the "-o" option during pool startup or creation. The options + are passed directly via a string to the command. + Since 5.0.0. +

adapter
Provides the source for pools backed by SCSI adapters (pool type scsi). May only occur once. diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng index 74f4363106..7252d8d44b 100644 --- a/docs/schemas/storagepool.rng +++ b/docs/schemas/storagepool.rng @@ -354,6 +354,11 @@ + + + + + diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 55db7a96f5..56710395be 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -372,6 +372,7 @@ virStoragePoolSourceClear(virStoragePoolSourcePtr sourc= e) virStoragePoolSourceDeviceClear(&source->devices[i]); VIR_FREE(source->devices); VIR_FREE(source->dir); + VIR_FREE(source->mountOpts); VIR_FREE(source->name); virStorageAdapterClear(&source->adapter); virStorageSourceInitiatorClear(&source->initiator); @@ -527,6 +528,9 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, VIR_STRDUP(source->dir, "/") < 0) goto cleanup; =20 + /* Optional mount options for the directory */ + source->mountOpts =3D virXPathString("string(./dir/@mount_opts)", ctxt= ); + if ((adapternode =3D virXPathNode("./adapter", ctxt))) { if (virStorageAdapterParseXML(&source->adapter, adapternode, ctxt)= < 0) goto cleanup; @@ -934,8 +938,12 @@ virStoragePoolSourceFormat(virBufferPtr buf, } } =20 - if (options->flags & VIR_STORAGE_POOL_SOURCE_DIR) - virBufferEscapeString(buf, "\n", src->dir); + if (options->flags & VIR_STORAGE_POOL_SOURCE_DIR) { + virBufferEscapeString(buf, "dir); + if (src->mountOpts) + virBufferEscapeString(buf, " mount_opts=3D'%s'", src->mountOpt= s); + virBufferAddLit(buf, "/>\n"); + } =20 if ((options->flags & VIR_STORAGE_POOL_SOURCE_ADAPTER) && (src->adapter.type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_HOST || diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h index dc0aa2ab29..780a219d3f 100644 --- a/src/conf/storage_conf.h +++ b/src/conf/storage_conf.h @@ -175,6 +175,9 @@ struct _virStoragePoolSource { /* Or a directory */ char *dir; =20 + /* If provided, a list of mount(8) options for mounting the pool's dir= */ + char *mountOpts; + /* Or an adapter */ virStorageAdapter adapter; =20 diff --git a/tests/storagepoolxml2xmlin/pool-netfs-mountopts.xml b/tests/st= oragepoolxml2xmlin/pool-netfs-mountopts.xml new file mode 100644 index 0000000000..ae312f6e5c --- /dev/null +++ b/tests/storagepoolxml2xmlin/pool-netfs-mountopts.xml @@ -0,0 +1,20 @@ + + nfsimages + 7641d5a8-af11-f730-a34e-0a7dfcede71f + 0 + 0 + 0 + + + + + + + /mnt + + 0700 + 0 + 0 + + + diff --git a/tests/storagepoolxml2xmlout/pool-netfs-mountopts.xml b/tests/s= toragepoolxml2xmlout/pool-netfs-mountopts.xml new file mode 100644 index 0000000000..3c6913d370 --- /dev/null +++ b/tests/storagepoolxml2xmlout/pool-netfs-mountopts.xml @@ -0,0 +1,20 @@ + + nfsimages + 7641d5a8-af11-f730-a34e-0a7dfcede71f + 0 + 0 + 0 + + + + + + + /mnt + + 0700 + 0 + 0 + + + diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c index 707d09f5c2..08d9a08020 100644 --- a/tests/storagepoolxml2xmltest.c +++ b/tests/storagepoolxml2xmltest.c @@ -85,6 +85,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("pool-scsi"); DO_TEST("pool-scsi-type-scsi-host"); DO_TEST("pool-scsi-type-fc-host"); --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 11:51:27 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 1545163409461893.9052778133638; Tue, 18 Dec 2018 12:03:29 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 27235356F6; Tue, 18 Dec 2018 20:03:27 +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 ADF397A5FC; Tue, 18 Dec 2018 20:03:25 +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 EBF3C181B9E7; Tue, 18 Dec 2018 20:03:24 +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 wBIK3NIE001816 for ; Tue, 18 Dec 2018 15:03:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7C42C1895F; Tue, 18 Dec 2018 20:03:23 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-117-129.phx2.redhat.com [10.3.117.129]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3993660C44 for ; Tue, 18 Dec 2018 20:03:23 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 18 Dec 2018 15:03:16 -0500 Message-Id: <20181218200317.24947-3-jferlan@redhat.com> In-Reply-To: <20181218200317.24947-1-jferlan@redhat.com> References: <20181218200317.24947-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/3] storage: Add mountOpts to the storage pool mount 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: , MIME-Version: 1.0 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 18 Dec 2018 20:03:28 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add the mountOpts to the generated backend mount command line for the storage pool. Signed-off-by: John Ferlan --- src/storage/storage_util.c | 4 ++++ tests/storagepoolxml2argvdata/pool-netfs-mountopts.argv | 1 + tests/storagepoolxml2argvtest.c | 1 + 3 files changed, 6 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..6d7c01e425 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -4336,6 +4336,10 @@ virStorageBackendFileSystemMountCmd(const char *cmds= tr, virStorageBackendFileSystemMountCIFSArgs(cmd, src, def); else virStorageBackendFileSystemMountDefaultArgs(cmd, src, def); + + if (def->source.mountOpts) + virCommandAddArgList(cmd, "-o", def->source.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..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"); --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 11:51:27 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 1545163421137817.7527474043856; Tue, 18 Dec 2018 12:03:41 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B5F7D9FDF9; Tue, 18 Dec 2018 20:03:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6850C18976; Tue, 18 Dec 2018 20:03:37 +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 108543D3A0; Tue, 18 Dec 2018 20:03:37 +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 wBIK3Nxc001828 for ; Tue, 18 Dec 2018 15:03:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id EBFF21895F; Tue, 18 Dec 2018 20:03:23 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-117-129.phx2.redhat.com [10.3.117.129]) by smtp.corp.redhat.com (Postfix) with ESMTP id A57E660C44 for ; Tue, 18 Dec 2018 20:03:23 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 18 Dec 2018 15:03:17 -0500 Message-Id: <20181218200317.24947-4-jferlan@redhat.com> In-Reply-To: <20181218200317.24947-1-jferlan@redhat.com> References: <20181218200317.24947-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/3] virsh: Add source-mount-opts for pool commands 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: , MIME-Version: 1.0 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 18 Dec 2018 20:03:38 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add the ability to add the mount options for the pool on the virsh command line for pool-{create|define}-as commands. Signed-off-by: John Ferlan --- tools/virsh-pool.c | 15 ++++++++++++--- tools/virsh.pod | 5 +++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index 75ec572af2..8c14de97f1 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -141,6 +141,10 @@ {.name =3D "adapter-parent-fabric-wwn", \ .type =3D VSH_OT_STRING, \ .help =3D N_("adapter parent scsi_hostN fabric_wwn to be used for und= erlying vHBA storage") \ + }, \ + {.name =3D "source-mount-opts", \ + .type =3D VSH_OT_STRING, \ + .help =3D N_("source mount options for an nfs pool's source-path") \ } =20 virStoragePoolPtr @@ -324,7 +328,7 @@ virshBuildPoolXML(vshControl *ctl, *secretUsage =3D NULL, *adapterName =3D NULL, *adapterParen= t =3D NULL, *adapterWwnn =3D NULL, *adapterWwpn =3D NULL, *secretUUID = =3D NULL, *adapterParentWwnn =3D NULL, *adapterParentWwpn =3D NULL, - *adapterParentFabricWwn =3D NULL; + *adapterParentFabricWwn =3D NULL, *mountOpts =3D NULL; virBuffer buf =3D VIR_BUFFER_INITIALIZER; =20 VSH_EXCLUSIVE_OPTIONS("secret-usage", "secret-uuid"); @@ -336,6 +340,7 @@ virshBuildPoolXML(vshControl *ctl, =20 if (vshCommandOptStringReq(ctl, cmd, "source-host", &srcHost) < 0 || vshCommandOptStringReq(ctl, cmd, "source-path", &srcPath) < 0 || + vshCommandOptStringReq(ctl, cmd, "source-mount-opts", &mountOpts) = < 0 || vshCommandOptStringReq(ctl, cmd, "source-dev", &srcDev) < 0 || vshCommandOptStringReq(ctl, cmd, "source-name", &srcName) < 0 || vshCommandOptStringReq(ctl, cmd, "source-format", &srcFormat) < 0 = || @@ -363,8 +368,12 @@ virshBuildPoolXML(vshControl *ctl, =20 if (srcHost) virBufferAsprintf(&buf, "\n", srcHost); - if (srcPath) - virBufferAsprintf(&buf, "\n", srcPath); + if (srcPath) { + virBufferAsprintf(&buf, "\n"); + } if (srcDev) virBufferAsprintf(&buf, "\n", srcDev); if (adapterWwnn && adapterWwpn) { diff --git a/tools/virsh.pod b/tools/virsh.pod index 86a4996cae..aa40c580ab 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -3884,6 +3884,7 @@ just I<--build> is provided, then B is ca= lled with no flags. =20 =3Ditem B I I [I<--source-host hostname>] [I<--source-path path>] [I<--source-dev path>] +[I<--source-mount-opts mountOpts>] [I<--source-name name>] [I<--target path>] [I<--source-format format>] [I<--auth-type authtype> I<--auth-username username> [I<--secret-usage usage> | I<--secret-uuid uuid>]] @@ -3910,6 +3911,10 @@ gluster). [I<--source-path path>] provides the source directory path for pools backed by directories (pool type dir). =20 +[<--source-mount-opts mountOpts>] provides a string to be used when creati= ng +the mount command for a netfs type pool. The options should be in a comma +separated list format as described by the mount options command. + [I<--source-dev path>] provides the source path for pools backed by physic= al devices (pool types fs, logical, disk, iscsi, zfs). =20 --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list