From nobody Wed Nov 27 14:41:59 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 1546969986144988.3119198652037; Tue, 8 Jan 2019 09:53:06 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1A2327F6D0; Tue, 8 Jan 2019 17:53:03 +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 A32826013A; 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 44D4A3F774; 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 x08HqZZp025801 for ; Tue, 8 Jan 2019 12:52:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5040960E3F; Tue, 8 Jan 2019 17:52:35 +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 09F3A60C67 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:25 -0500 Message-Id: <20190108175226.32693-6-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 5/6] 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: , 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 08 Jan 2019 17:53:04 +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, such as. virsh pool-define-as nfstest netfs \ --source-host localhost \ --source-path "/var/lib/libvirt/images" \ --source-format nfs \ --source-mount-opts "nodev,nosuid" \ --target "/mnt" in order to generate XML: nfstest /mnt Signed-off-by: John Ferlan --- tools/virsh-pool.c | 39 +++++++++++++++++++++++++++++++++++---- tools/virsh.pod | 5 +++++ 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index 70ca39bd3d..7f8de4a08c 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -136,6 +136,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_("comma separated list for NFS pool mount options") \ } =20 virStoragePoolPtr @@ -319,7 +323,9 @@ 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; + size_t noptsList =3D 0; + char **optsList =3D NULL; virBuffer buf =3D VIR_BUFFER_INITIALIZER; =20 VSH_EXCLUSIVE_OPTIONS("secret-usage", "secret-uuid"); @@ -345,10 +351,19 @@ virshBuildPoolXML(vshControl *ctl, vshCommandOptStringReq(ctl, cmd, "adapter-parent", &adapterParent)= < 0 || vshCommandOptStringReq(ctl, cmd, "adapter-parent-wwnn", &adapterPa= rentWwnn) < 0 || vshCommandOptStringReq(ctl, cmd, "adapter-parent-wwpn", &adapterPa= rentWwpn) < 0 || - vshCommandOptStringReq(ctl, cmd, "adapter-parent-fabric-wwn", &ada= pterParentFabricWwn) < 0) + vshCommandOptStringReq(ctl, cmd, "adapter-parent-fabric-wwn", &ada= pterParentFabricWwn) < 0 || + vshCommandOptStringReq(ctl, cmd, "source-mount-opts", &mountOpts) = < 0) + goto cleanup; + + if (mountOpts && + !(optsList =3D virStringSplitCount(mountOpts, ",", 0, &noptsList))) goto cleanup; =20 - virBufferAsprintf(&buf, "\n", type); + virBufferAsprintf(&buf, "\n"); virBufferAdjustIndent(&buf, 2); virBufferAsprintf(&buf, "%s\n", name); if (srcHost || srcPath || srcDev || srcFormat || srcName || @@ -394,6 +409,20 @@ virshBuildPoolXML(vshControl *ctl, if (srcName) virBufferAsprintf(&buf, "%s\n", srcName); =20 + if (mountOpts) { + size_t i; + + virBufferAddLit(&buf, "\n"); + virBufferAdjustIndent(&buf, 2); + + for (i =3D 0; i < noptsList; i++) + virBufferAsprintf(&buf, "\n", + optsList[i]); + + virBufferAdjustIndent(&buf, -2); + virBufferAddLit(&buf, "\n"); + } + virBufferAdjustIndent(&buf, -2); virBufferAddLit(&buf, "\n"); } @@ -409,14 +438,16 @@ virshBuildPoolXML(vshControl *ctl, =20 if (virBufferError(&buf)) { vshError(ctl, "%s", _("Failed to allocate XML buffer")); - return false; + goto cleanup; } =20 + virStringListFree(optsList); *xml =3D virBufferContentAndReset(&buf); *retname =3D name; return true; =20 cleanup: + virStringListFree(optsList); virBufferFreeAndReset(&buf); return false; } diff --git a/tools/virsh.pod b/tools/virsh.pod index 86a4996cae..881981e159 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 must 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.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list