From nobody Mon Apr 29 08:30:55 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 1547600998871225.06606892115929; Tue, 15 Jan 2019 17:09:58 -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 97E82C050939; Wed, 16 Jan 2019 01:09:56 +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 563355EDE0; Wed, 16 Jan 2019 01:09:56 +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 0A11B3F6E4; Wed, 16 Jan 2019 01:09:56 +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 x0G19VC3020452 for ; Tue, 15 Jan 2019 20:09:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7D45E17A65; Wed, 16 Jan 2019 01:09:31 +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 23CBF177BD for ; Wed, 16 Jan 2019 01:09:31 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 15 Jan 2019 20:09:12 -0500 Message-Id: <20190116010922.28250-2-jferlan@redhat.com> In-Reply-To: <20190116010922.28250-1-jferlan@redhat.com> References: <20190116010922.28250-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 v3 01/11] conf: Add some defined NFS Storage Pool mount options 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.31]); Wed, 16 Jan 2019 01:09:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1584663 Add the ability to parse/manage some defined NFS Storage Pool mount options. Keep the set of defined options limited to noexec, nosuid, nodev, and ro. Subsequent patches will add the ability to provide the NFS nfsvers value and eventally any option via storage pool namespaces. Signed-off-by: John Ferlan --- docs/formatstorage.html.in | 21 +++++++++ docs/schemas/storagepool.rng | 20 ++++++++ src/conf/storage_conf.c | 47 +++++++++++++++++++ src/conf/storage_conf.h | 13 +++++ .../pool-netfs-mountopts.xml | 24 ++++++++++ .../pool-netfs-mountopts.xml | 24 ++++++++++ tests/storagepoolxml2xmltest.c | 1 + 7 files changed, 150 insertions(+) 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..97c90f0797 100644 --- a/docs/formatstorage.html.in +++ b/docs/formatstorage.html.in @@ -121,6 +121,19 @@ </source> ... =20 +
+...
+  <source>
+    <host name=3D'localhost'/>
+    <dir path=3D'/var/lib/libvirt/images'/>
+    <format type=3D'nfs'/>
+    <mount_opts>
+      <option name=3D'nodev'/>
+      <option name=3D'nosuid'/>
+    </mount_opts>
+  </source>
+...
+
device
Provides the source for pools backed by physical devices @@ -386,6 +399,14 @@ LVM metadata type. All drivers are required to have a default value for this, so it is optional. Since 0.4= .1
=20 +
mount_opts
+
Provide an optional set of mount options for the netfs + pool startup or creation to be provided via the "-o" option. + The desired options are specified by using the subelement + option with the attribute name to + provide the option. Supported option names are "noexec", "nosuid", + "nodev", and "ro". + Since 5.1.0
vendor
Provides optional information about the vendor of the storage device. This contains a single diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng index 74f4363106..d52856b556 100644 --- a/docs/schemas/storagepool.rng +++ b/docs/schemas/storagepool.rng @@ -531,6 +531,9 @@ + + + @@ -576,6 +579,23 @@ =20 + + + + + + + noexec + nosuid + nodev + ro + + + + + + + diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 55db7a96f5..aafb7980e7 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -70,6 +70,10 @@ VIR_ENUM_IMPL(virStoragePoolFormatFileSystemNet, VIR_STORAGE_POOL_NETFS_LAST, "auto", "nfs", "glusterfs", "cifs") =20 +VIR_ENUM_IMPL(virStoragePoolSourceMountOpts, + VIR_STORAGE_POOL_SOURCE_MOUNT_OPTS_LAST, + "noexec", "nosuid", "nodev", "ro") + VIR_ENUM_IMPL(virStoragePoolFormatDisk, VIR_STORAGE_POOL_DISK_LAST, "unknown", "dos", "dvh", "gpt", @@ -378,6 +382,10 @@ virStoragePoolSourceClear(virStoragePoolSourcePtr sour= ce) virStorageAuthDefFree(source->auth); VIR_FREE(source->vendor); VIR_FREE(source->product); + for (i =3D 0; i < source->nmountOpts; i++) + VIR_FREE(source->mountOpts[i]); + VIR_FREE(source->mountOpts); + source->nmountOpts =3D 0; } =20 =20 @@ -546,6 +554,33 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, authdef =3D NULL; } =20 + /* Optional, but defined mount ops */ + VIR_FREE(nodeset); + n =3D virXPathNodeSet("./mount_opts/option", ctxt, &nodeset); + if (n < 0) + goto cleanup; + + if (n > 0) { + if (VIR_ALLOC_N(source->mountOpts, n) < 0) + goto cleanup; + for (i =3D 0; i < n; i++) { + if (!(source->mountOpts[i] =3D virXMLPropString(nodeset[i], + "name"))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("no mount option name specified")); + goto cleanup; + } + source->nmountOpts++; + /* Do we recognize the string? */ + if (virStoragePoolSourceMountOptsTypeFromString(source->mountO= pts[i]) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown mount option name '%s' specified= "), + source->mountOpts[i]); + goto cleanup; + } + } + } + source->vendor =3D virXPathString("string(./vendor/@name)", ctxt); source->product =3D virXPathString("string(./product/@name)", ctxt); =20 @@ -962,6 +997,18 @@ virStoragePoolSourceFormat(virBufferPtr buf, if (src->auth) virStorageAuthDefFormat(buf, src->auth); =20 + if (src->mountOpts) { + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); + + for (i =3D 0; i < src->nmountOpts; i++) + virBufferEscapeString(buf, "\n"); + } + virBufferEscapeString(buf, "\n", src->vendor); virBufferEscapeString(buf, "\n", src->product); =20 diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h index dc0aa2ab29..c23e6720ac 100644 --- a/src/conf/storage_conf.h +++ b/src/conf/storage_conf.h @@ -193,6 +193,10 @@ struct _virStoragePoolSource { /* Product name of the source*/ char *product; =20 + /* Defined mount options to be added to mount command line */ + char **mountOpts; + size_t nmountOpts; + /* Pool type specific format such as filesystem type, * or lvm version, etc. */ @@ -332,6 +336,15 @@ typedef enum { } virStoragePoolFormatFileSystemNet; VIR_ENUM_DECL(virStoragePoolFormatFileSystemNet) =20 +typedef enum { + VIR_STORAGE_POOL_SOURCE_MOUNT_OPTS_NOEXEC =3D 0, + VIR_STORAGE_POOL_SOURCE_MOUNT_OPTS_NOSUID, + VIR_STORAGE_POOL_SOURCE_MOUNT_OPTS_NODEV, + VIR_STORAGE_POOL_SOURCE_MOUNT_OPTS_RO, + VIR_STORAGE_POOL_SOURCE_MOUNT_OPTS_LAST, +} virStoragePoolSourceMountOpts; +VIR_ENUM_DECL(virStoragePoolSourceMountOpts) + typedef enum { VIR_STORAGE_POOL_DISK_UNKNOWN =3D 0, VIR_STORAGE_POOL_DISK_DOS =3D 1, diff --git a/tests/storagepoolxml2xmlin/pool-netfs-mountopts.xml b/tests/st= oragepoolxml2xmlin/pool-netfs-mountopts.xml new file mode 100644 index 0000000000..c2bb3bf4ed --- /dev/null +++ b/tests/storagepoolxml2xmlin/pool-netfs-mountopts.xml @@ -0,0 +1,24 @@ + + 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..786acf8887 --- /dev/null +++ b/tests/storagepoolxml2xmlout/pool-netfs-mountopts.xml @@ -0,0 +1,24 @@ + + 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.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 08:30:55 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 1547601004696852.0588314937607; Tue, 15 Jan 2019 17:10:04 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 187D389ACF; Wed, 16 Jan 2019 01:10:01 +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 D37475C234; Wed, 16 Jan 2019 01:10:00 +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 8EB7E1803393; Wed, 16 Jan 2019 01:10:00 +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 x0G19Vfk020457 for ; Tue, 15 Jan 2019 20:09:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id EDB44177BD; Wed, 16 Jan 2019 01:09:31 +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 A9BC917A6B for ; Wed, 16 Jan 2019 01:09:31 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 15 Jan 2019 20:09:13 -0500 Message-Id: <20190116010922.28250-3-jferlan@redhat.com> In-Reply-To: <20190116010922.28250-1-jferlan@redhat.com> References: <20190116010922.28250-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 v3 02/11] 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: , 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 16 Jan 2019 01:10:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1584663 Add the mountOpts to the generated backend mount command line for the storage pool. Signed-off-by: John Ferlan --- src/storage/storage_util.c | 19 +++++++++++++++++++ .../pool-netfs-mountopts.argv | 1 + tests/storagepoolxml2argvtest.c | 1 + 3 files changed, 21 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..8fe6139682 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -4336,6 +4336,25 @@ 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.mountOpts) { + size_t i; + virBuffer buf =3D VIR_BUFFER_INITIALIZER; + VIR_AUTOFREE(char *) mountOpts =3D NULL; + + for (i =3D 0; i < def->source.nmountOpts; i++) + virBufferAsprintf(&buf, "%s,", def->source.mountOpts[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..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.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 08:30:55 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 1547600982209454.0483874244344; Tue, 15 Jan 2019 17:09:42 -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 CFA9E89AC8; Wed, 16 Jan 2019 01:09:39 +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 7FBB917A72; Wed, 16 Jan 2019 01:09:39 +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 ACAEF3F954; Wed, 16 Jan 2019 01:09:38 +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 x0G19aU3020478 for ; Tue, 15 Jan 2019 20:09:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id 78D1817A6B; Wed, 16 Jan 2019 01:09:36 +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 329E817A65 for ; Wed, 16 Jan 2019 01:09:32 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 15 Jan 2019 20:09:14 -0500 Message-Id: <20190116010922.28250-4-jferlan@redhat.com> In-Reply-To: <20190116010922.28250-1-jferlan@redhat.com> References: <20190116010922.28250-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 v3 03/11] 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.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.26]); Wed, 16 Jan 2019 01:09:40 +0000 (UTC) Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1584663 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 | 35 ++++++++++++++++++++++++++++++++--- tools/virsh.pod | 6 ++++++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index 70ca39bd3d..79b33a8885 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,7 +351,13 @@ 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); @@ -394,6 +406,21 @@ 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"); + } + + virBufferAdjustIndent(&buf, -2); virBufferAddLit(&buf, "\n"); } @@ -409,14 +436,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..718efcb07e 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -3887,6 +3887,7 @@ just I<--build> is provided, then B is ca= lled with no flags. [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>]] +[I<--source-mount-opts mountOpts>] [[I<--adapter-name name>] | [I<--adapter-wwnn> wwnn I<--adapter-wwpn> wwpn] [I<--adapter-parent parent> | I<--adapter-parent-wwnn parent_wwnn> I | @@ -3929,6 +3930,11 @@ the storage pool. The I is either chap for= iscsi I pools or ceph for rbd I pools. Either the secret I or I value may be provided, but not both. =20 +[I<--source-mount-opts mountOpts>] provides a string to be used when creat= ing +the mount command for a netfs type pool. The I must be in a com= ma +separated list format. Valid I that may be provided are "nosuid= ", +"noexec", "nodev", and "ro". + [I<--adapter-name name>] defines the scsi_hostN adapter name to be used for the scsi_host adapter type pool. =20 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 08:30:55 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 1547600981726874.6574408888308; Tue, 15 Jan 2019 17:09:41 -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 3361745F86; Wed, 16 Jan 2019 01:09:39 +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 C539A19E2A; Wed, 16 Jan 2019 01:09:38 +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 B18EE1803390; Wed, 16 Jan 2019 01:09:37 +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 x0G19aX2020483 for ; Tue, 15 Jan 2019 20:09:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id E5F6517A66; Wed, 16 Jan 2019 01:09:36 +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 A2AC417A65 for ; Wed, 16 Jan 2019 01:09:36 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 15 Jan 2019 20:09:15 -0500 Message-Id: <20190116010922.28250-5-jferlan@redhat.com> In-Reply-To: <20190116010922.28250-1-jferlan@redhat.com> References: <20190116010922.28250-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 v3 04/11] conf: Add optional NFS Source Pool option 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.28]); Wed, 16 Jan 2019 01:09:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add an optional way to define which NFS Server version will be used to content the target NFS server. Signed-off-by: John Ferlan --- docs/formatstorage.html.in | 7 ++++++ docs/schemas/storagepool.rng | 7 ++++++ src/conf/storage_conf.c | 22 +++++++++++++++++++ src/conf/storage_conf.h | 3 +++ .../pool-netfs-protocol-ver.xml | 21 ++++++++++++++++++ .../pool-netfs-protocol-ver.xml | 21 ++++++++++++++++++ tests/storagepoolxml2xmltest.c | 1 + 7 files changed, 82 insertions(+) create mode 100644 tests/storagepoolxml2xmlin/pool-netfs-protocol-ver.xml create mode 100644 tests/storagepoolxml2xmlout/pool-netfs-protocol-ver.xml diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in index 97c90f0797..58f5eb2e2e 100644 --- a/docs/formatstorage.html.in +++ b/docs/formatstorage.html.in @@ -127,6 +127,7 @@ <host name=3D'localhost'/> <dir path=3D'/var/lib/libvirt/images'/> <format type=3D'nfs'/> + <protocol ver=3D'3'/> <mount_opts> <option name=3D'nodev'/> <option name=3D'nosuid'/> @@ -399,6 +400,12 @@ LVM metadata type. All drivers are required to have a default value for this, so it is optional. Since 0.4= .1
=20 +
protocol
+
For a netfs Storage Pool provide a mechanism to + define which NFS protocol version number will be used to contact + the server's NFS service. The attribute ver accepts + an unsigned integer as the version number to use. + Since 5.1.0
mount_opts
Provide an optional set of mount options for the netfs pool startup or creation to be provided via the "-o" option. diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng index d52856b556..a32c89b94c 100644 --- a/docs/schemas/storagepool.rng +++ b/docs/schemas/storagepool.rng @@ -531,6 +531,13 @@ + + + + + + + diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index aafb7980e7..8ec360e4a1 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -428,6 +428,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, virStorageAuthDefPtr authdef =3D NULL; char *name =3D NULL; char *port =3D NULL; + char *ver =3D NULL; int n; =20 relnode =3D ctxt->node; @@ -554,6 +555,24 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, authdef =3D NULL; } =20 + /* Option protocol version string (NFSvN) */ + if ((ver =3D virXPathString("string(./protocol/@ver)", ctxt))) { + if ((source->format !=3D VIR_STORAGE_POOL_NETFS_NFS) && + (source->format !=3D VIR_STORAGE_POOL_NETFS_AUTO)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("storage pool protocol ver unsupported for " + "pool type '%s'"), + virStoragePoolFormatFileSystemNetTypeToString(s= ource->format)); + goto cleanup; + } + if (virStrToLong_uip(ver, NULL, 0, &source->protocolVer) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("storage pool protocol ver '%s' is malformaed= "), + ver); + goto cleanup; + } + } + /* Optional, but defined mount ops */ VIR_FREE(nodeset); n =3D virXPathNodeSet("./mount_opts/option", ctxt, &nodeset); @@ -997,6 +1016,9 @@ virStoragePoolSourceFormat(virBufferPtr buf, if (src->auth) virStorageAuthDefFormat(buf, src->auth); =20 + if (src->protocolVer) + virBufferAsprintf(buf, "\n", src->protocolVe= r); + if (src->mountOpts) { virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, 2); diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h index c23e6720ac..f36d4daa3c 100644 --- a/src/conf/storage_conf.h +++ b/src/conf/storage_conf.h @@ -201,6 +201,9 @@ struct _virStoragePoolSource { * or lvm version, etc. */ int format; + + /* Protocol version value for netfs */ + unsigned int protocolVer; }; =20 typedef struct _virStoragePoolTarget virStoragePoolTarget; diff --git a/tests/storagepoolxml2xmlin/pool-netfs-protocol-ver.xml b/tests= /storagepoolxml2xmlin/pool-netfs-protocol-ver.xml new file mode 100644 index 0000000000..40f3f94e41 --- /dev/null +++ b/tests/storagepoolxml2xmlin/pool-netfs-protocol-ver.xml @@ -0,0 +1,21 @@ + + nfsimages + 7641d5a8-af11-f730-a34e-0a7dfcede71f + 0 + 0 + 0 + + + + + + + + /mnt + + 0700 + 0 + 0 + + + diff --git a/tests/storagepoolxml2xmlout/pool-netfs-protocol-ver.xml b/test= s/storagepoolxml2xmlout/pool-netfs-protocol-ver.xml new file mode 100644 index 0000000000..5fcad1305b --- /dev/null +++ b/tests/storagepoolxml2xmlout/pool-netfs-protocol-ver.xml @@ -0,0 +1,21 @@ + + nfsimages + 7641d5a8-af11-f730-a34e-0a7dfcede71f + 0 + 0 + 0 + + + + + + + + /mnt + + 0700 + 0 + 0 + + + diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c index 08d9a08020..ecdc2715b0 100644 --- a/tests/storagepoolxml2xmltest.c +++ b/tests/storagepoolxml2xmltest.c @@ -83,6 +83,7 @@ mymain(void) DO_TEST("pool-iscsi-auth"); DO_TEST("pool-netfs"); DO_TEST("pool-netfs-auto"); + DO_TEST("pool-netfs-protocol-ver"); DO_TEST("pool-netfs-gluster"); DO_TEST("pool-netfs-cifs"); DO_TEST("pool-netfs-mountopts"); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 08:30:55 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 1547600999302540.7811956631712; Tue, 15 Jan 2019 17:09:59 -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 7B525D56EF; Wed, 16 Jan 2019 01:09:56 +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 3AAFA194A8; Wed, 16 Jan 2019 01:09:56 +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 E17CE3F7D5; Wed, 16 Jan 2019 01:09:55 +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 x0G19bIx020488 for ; Tue, 15 Jan 2019 20:09:37 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6172117A65; Wed, 16 Jan 2019 01:09:37 +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 1CA0617A6E for ; Wed, 16 Jan 2019 01:09:37 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 15 Jan 2019 20:09:16 -0500 Message-Id: <20190116010922.28250-6-jferlan@redhat.com> In-Reply-To: <20190116010922.28250-1-jferlan@redhat.com> References: <20190116010922.28250-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 v3 05/11] storage: Add the nfsvers to the 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.38]); Wed, 16 Jan 2019 01:09:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" If protocolVer present, add the -o nfsvers=3D# to the command line for the NFS Storage Pool Signed-off-by: John Ferlan --- src/storage/storage_util.c | 6 +++++- tests/storagepoolxml2argvdata/pool-netfs-protocol-ver.argv | 1 + tests/storagepoolxml2argvtest.c | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 tests/storagepoolxml2argvdata/pool-netfs-protocol-ver.a= rgv diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 8fe6139682..0c52b797fc 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -4337,11 +4337,15 @@ virStorageBackendFileSystemMountCmd(const char *cmd= str, else virStorageBackendFileSystemMountDefaultArgs(cmd, src, def); =20 - if (def->type =3D=3D VIR_STORAGE_POOL_NETFS && def->source.mountOpts) { + if (def->type =3D=3D VIR_STORAGE_POOL_NETFS && + (def->source.mountOpts || (def->source.protocolVer > 0))) { size_t i; virBuffer buf =3D VIR_BUFFER_INITIALIZER; VIR_AUTOFREE(char *) mountOpts =3D NULL; =20 + if (def->source.protocolVer > 0) + virBufferAsprintf(&buf, "nfsvers=3D%u,", def->source.protocolV= er); + for (i =3D 0; i < def->source.nmountOpts; i++) virBufferAsprintf(&buf, "%s,", def->source.mountOpts[i]); =20 diff --git a/tests/storagepoolxml2argvdata/pool-netfs-protocol-ver.argv b/t= ests/storagepoolxml2argvdata/pool-netfs-protocol-ver.argv new file mode 100644 index 0000000000..f26656d5b8 --- /dev/null +++ b/tests/storagepoolxml2argvdata/pool-netfs-protocol-ver.argv @@ -0,0 +1 @@ +mount -t nfs localhost:/var/lib/libvirt/images /mnt -o nfsvers=3D3 diff --git a/tests/storagepoolxml2argvtest.c b/tests/storagepoolxml2argvtes= t.c index 0df97fb390..e8bae9fb8c 100644 --- a/tests/storagepoolxml2argvtest.c +++ b/tests/storagepoolxml2argvtest.c @@ -157,6 +157,7 @@ mymain(void) DO_TEST_FAIL("pool-iscsi-auth"); DO_TEST("pool-netfs"); DO_TEST("pool-netfs-auto"); + DO_TEST("pool-netfs-protocol-ver"); DO_TEST("pool-netfs-gluster"); DO_TEST("pool-netfs-cifs"); DO_TEST("pool-netfs-mountopts"); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 08:30:55 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 1547601011157515.8045395627571; Tue, 15 Jan 2019 17:10:11 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 206AA19E83; Wed, 16 Jan 2019 01:10:08 +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 BEE935E7D3; Wed, 16 Jan 2019 01:10:07 +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 282C4180339A; Wed, 16 Jan 2019 01:10:07 +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 x0G19b4C020493 for ; Tue, 15 Jan 2019 20:09:37 -0500 Received: by smtp.corp.redhat.com (Postfix) id D250717A66; Wed, 16 Jan 2019 01:09:37 +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 8E32E17A65 for ; Wed, 16 Jan 2019 01:09:37 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 15 Jan 2019 20:09:17 -0500 Message-Id: <20190116010922.28250-7-jferlan@redhat.com> In-Reply-To: <20190116010922.28250-1-jferlan@redhat.com> References: <20190116010922.28250-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 v3 06/11] virsh: Add source-protocol-ver 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 16 Jan 2019 01:10:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Allow the addition of the to the provided XML. Signed-off-by: John Ferlan --- tools/virsh-pool.c | 13 +++++++++++-- tools/virsh.pod | 6 +++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index 79b33a8885..581fd06380 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -140,6 +140,10 @@ {.name =3D "source-mount-opts", \ .type =3D VSH_OT_STRING, \ .help =3D N_("comma separated list for NFS pool mount options") \ + }, \ + {.name =3D "source-protocol-ver", \ + .type =3D VSH_OT_STRING, \ + .help =3D N_("nfsvers value for NFS pool mount option") \ } =20 virStoragePoolPtr @@ -323,7 +327,8 @@ 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, *mountOpts =3D NULL; + *adapterParentFabricWwn =3D NULL, *mountOpts =3D NULL, + *protoVer =3D NULL; size_t noptsList =3D 0; char **optsList =3D NULL; virBuffer buf =3D VIR_BUFFER_INITIALIZER; @@ -352,7 +357,8 @@ virshBuildPoolXML(vshControl *ctl, 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, "source-mount-opts", &mountOpts) = < 0) + vshCommandOptStringReq(ctl, cmd, "source-mount-opts", &mountOpts) = < 0 || + vshCommandOptStringReq(ctl, cmd, "source-protocol-ver", &protoVer)= < 0) goto cleanup; =20 if (mountOpts && @@ -406,6 +412,9 @@ virshBuildPoolXML(vshControl *ctl, if (srcName) virBufferAsprintf(&buf, "%s\n", srcName); =20 + if (protoVer) + virBufferAsprintf(&buf, "\n", protoVer); + if (mountOpts) { size_t i; =20 diff --git a/tools/virsh.pod b/tools/virsh.pod index 718efcb07e..95e01a0aa5 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -3887,7 +3887,7 @@ just I<--build> is provided, then B is ca= lled with no flags. [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>]] -[I<--source-mount-opts mountOpts>] +[I<--source-protocol-ver ver>] [I<--source-mount-opts mountOpts>] [[I<--adapter-name name>] | [I<--adapter-wwnn> wwnn I<--adapter-wwpn> wwpn] [I<--adapter-parent parent> | I<--adapter-parent-wwnn parent_wwnn> I | @@ -3930,6 +3930,10 @@ the storage pool. The I is either chap for= iscsi I pools or ceph for rbd I pools. Either the secret I or I value may be provided, but not both. =20 +[I<--source-protocol-ver ver>] provides the NFS protocol version number us= ed +to contact the server's NFS service via nfs mount option 'nfsvers=3Dn'. It= is +expect the I value is an unsigned integer. + [I<--source-mount-opts mountOpts>] provides a string to be used when creat= ing the mount command for a netfs type pool. The I must be in a com= ma separated list format. Valid I that may be provided are "nosuid= ", --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 08:30:55 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 1547601004761440.12588475436564; Tue, 15 Jan 2019 17:10:04 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 275DFC070E11; Wed, 16 Jan 2019 01:10:01 +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 E25A2108BF16; Wed, 16 Jan 2019 01:10:00 +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 6149D1803395; Wed, 16 Jan 2019 01:10:00 +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 x0G19cdq020504 for ; Tue, 15 Jan 2019 20:09:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id 55A7817A75; Wed, 16 Jan 2019 01:09:38 +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 0A2A717A65 for ; Wed, 16 Jan 2019 01:09:37 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 15 Jan 2019 20:09:18 -0500 Message-Id: <20190116010922.28250-8-jferlan@redhat.com> In-Reply-To: <20190116010922.28250-1-jferlan@redhat.com> References: <20190116010922.28250-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 v3 07/11] conf: Introduce virStoragePoolXMLNamespace 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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 16 Jan 2019 01:10:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Introduce the infrastructure necessary to manage a Storage Pool XML Namespace. The general concept is similar to virDomainXMLNamespace, except that for Storage Pools the storage backend specific details can be stored within the _virStoragePoolOptions unlike the domain processing code which manages its xmlopt's via the virDomainXMLOption which is allocated/passed around for each domain. This patch defines the add the parse, format, free, and href methods required to process the XML and callout from the Storage Pool Def parse, format, and free API's to perform the action on the XML data for/from the backend. Signed-off-by: John Ferlan --- src/conf/storage_conf.c | 51 +++++++++++++++++++++++++++++++++++++++- src/conf/storage_conf.h | 24 +++++++++++++++++++ src/libvirt_private.syms | 1 + 3 files changed, 75 insertions(+), 1 deletion(-) diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 8ec360e4a1..a20596e3f1 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -128,6 +128,9 @@ typedef virStoragePoolOptions *virStoragePoolOptionsPtr; struct _virStoragePoolOptions { unsigned int flags; int defaultFormat; + + virStoragePoolXMLNamespace ns; + virStoragePoolFormatToString formatToString; virStoragePoolFormatFromString formatFromString; }; @@ -322,6 +325,34 @@ virStoragePoolOptionsForPoolType(int type) } =20 =20 +/* virStoragePoolOptionsPoolTypeSetXMLNamespace: + * @type: virStoragePoolType + * @ns: xmlopt namespace pointer + * + * Store the @ns in the pool options for the particular backend. + * This allows the parse/format code to then directly call the Namespace + * method space (parse, format, href, free) as needed during processing. + * + * Returns: 0 on success, -1 on failure. + */ +int +virStoragePoolOptionsPoolTypeSetXMLNamespace(int type, + virStoragePoolXMLNamespacePtr= ns) +{ + int ret =3D -1; + virStoragePoolTypeInfoPtr backend =3D virStoragePoolTypeInfoLookup(typ= e); + + if (!backend) + goto cleanup; + + backend->poolOptions.ns =3D *ns; + ret =3D 0; + + cleanup: + return ret; +} + + static virStorageVolOptionsPtr virStorageVolOptionsForPoolType(int type) { @@ -409,6 +440,8 @@ virStoragePoolDefFree(virStoragePoolDefPtr def) =20 VIR_FREE(def->target.path); VIR_FREE(def->target.perms.label); + if (def->namespaceData && def->ns.free) + (def->ns.free)(def->namespaceData); VIR_FREE(def); } =20 @@ -870,6 +903,13 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) goto error; } =20 + /* Make a copy of all the callback pointers here for easier use, + * especially during the virStoragePoolSourceClear method */ + ret->ns =3D options->ns; + if (ret->ns.parse && + (ret->ns.parse)(ctxt, &ret->namespaceData) < 0) + goto error; + cleanup: VIR_FREE(uuid); VIR_FREE(type); @@ -1058,7 +1098,10 @@ virStoragePoolDefFormatBuf(virBufferPtr buf, _("unexpected pool type")); return -1; } - virBufferAsprintf(buf, "\n", type); + virBufferAsprintf(buf, "namespaceData && def->ns.href) + virBufferAsprintf(buf, " %s", (def->ns.href)()); + virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); virBufferEscapeString(buf, "%s\n", def->name); =20 @@ -1111,6 +1154,12 @@ virStoragePoolDefFormatBuf(virBufferPtr buf, virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); } + + if (def->namespaceData && def->ns.format) { + if ((def->ns.format)(buf, def->namespaceData) < 0) + return -1; + } + virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); =20 diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h index f36d4daa3c..09930991aa 100644 --- a/src/conf/storage_conf.h +++ b/src/conf/storage_conf.h @@ -33,6 +33,26 @@ =20 # include =20 +/* Various callbacks needed to parse/create Storage Pool XML's using + * a private namespace */ +typedef int (*virStoragePoolDefNamespaceParse)(xmlXPathContextPtr, void **= ); +typedef void (*virStoragePoolDefNamespaceFree)(void *); +typedef int (*virStoragePoolDefNamespaceXMLFormat)(virBufferPtr, void *); +typedef const char *(*virStoragePoolDefNamespaceHref)(void); + +typedef struct _virStoragePoolXMLNamespace virStoragePoolXMLNamespace; +typedef virStoragePoolXMLNamespace *virStoragePoolXMLNamespacePtr; +struct _virStoragePoolXMLNamespace { + virStoragePoolDefNamespaceParse parse; + virStoragePoolDefNamespaceFree free; + virStoragePoolDefNamespaceXMLFormat format; + virStoragePoolDefNamespaceHref href; +}; + +int +virStoragePoolOptionsPoolTypeSetXMLNamespace(int type, + virStoragePoolXMLNamespacePtr= ns); + /* * How the volume's data is stored on underlying * physical devices - can potentially span many @@ -226,6 +246,10 @@ struct _virStoragePoolDef { =20 virStoragePoolSource source; virStoragePoolTarget target; + + /* Pool backend specific XML namespace data */ + void *namespaceData; + virStoragePoolXMLNamespace ns; }; =20 typedef struct _virStoragePoolSourceList virStoragePoolSourceList; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index c3d6306809..4d82797ee1 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -919,6 +919,7 @@ virStoragePoolFormatDiskTypeToString; virStoragePoolFormatFileSystemNetTypeToString; virStoragePoolFormatFileSystemTypeToString; virStoragePoolFormatLogicalTypeToString; +virStoragePoolOptionsPoolTypeSetXMLNamespace; virStoragePoolSaveConfig; virStoragePoolSaveState; virStoragePoolSourceClear; --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 08:30:55 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 1547601013590777.9547673595221; Tue, 15 Jan 2019 17:10:13 -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 060A687622; Wed, 16 Jan 2019 01:10:10 +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 7866061532; Wed, 16 Jan 2019 01:10:08 +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 E37113F607; Wed, 16 Jan 2019 01:10:07 +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 x0G19cgX020513 for ; Tue, 15 Jan 2019 20:09:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id C3E0717A66; Wed, 16 Jan 2019 01:09:38 +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 7C17F17A65 for ; Wed, 16 Jan 2019 01:09:38 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 15 Jan 2019 20:09:19 -0500 Message-Id: <20190116010922.28250-9-jferlan@redhat.com> In-Reply-To: <20190116010922.28250-1-jferlan@redhat.com> References: <20190116010922.28250-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 v3 08/11] nfs: Add infrastructure to manage XML namespace options 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.26]); Wed, 16 Jan 2019 01:10:12 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Introduce the virStoragePoolNetFSMountOptionsDef to be used to manage the NFS Storage Pool XML Namespace for mount options. Using a new virStorageBackendNamespaceInit function, set the virStoragePoolXMLNamespace into the _virStoragePoolOptions when the storage backend is loaded. Signed-off-by: John Ferlan --- src/storage/storage_backend_fs.c | 128 +++++++++++++++++++++++++++++++ src/storage/storage_util.c | 16 ++++ src/storage/storage_util.h | 14 ++++ 3 files changed, 158 insertions(+) diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend= _fs.c index dc9869417e..b82215fcdb 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -41,6 +41,7 @@ VIR_LOG_INIT("storage.storage_backend_fs"); =20 #if WITH_STORAGE_FS =20 +# include # include =20 struct _virNetfsDiscoverState { @@ -559,6 +560,122 @@ virStorageBackendFileSystemBuild(virStoragePoolObjPtr= pool, } =20 =20 +#if WITH_STORAGE_FS + +# define STORAGE_POOL_NETFS_NAMESPACE_HREF "http://libvirt.org/schemas/sto= ragepool/source/netfs/1.0" + +/* NetFS backend XML Namespace handling for nfs specific mount options to + * be added to the mount -o {options_list} command line. The XML will use + * the format, such as: + * + * + * + * + * + * + * and the is required to have a "xmlns:netfs=3D'%s'" + * attribute using the STORAGE_POOL_NETFS_NAMESPACE_HREF + */ + +static void +virStoragePoolDefNetFSNamespaceFree(void *nsdata) +{ + virStoragePoolNetFSMountOptionsDefPtr cmdopts =3D nsdata; + size_t i; + + if (!cmdopts) + return; + + for (i =3D 0; i < cmdopts->noptions; i++) + VIR_FREE(cmdopts->options[i]); + VIR_FREE(cmdopts->options); + + VIR_FREE(cmdopts); +} + + +static int +virStoragePoolDefNetFSNamespaceParse(xmlXPathContextPtr ctxt, + void **data) +{ + virStoragePoolNetFSMountOptionsDefPtr cmdopts =3D NULL; + xmlNodePtr *nodes =3D NULL; + int nnodes; + size_t i; + int ret =3D -1; + + if (xmlXPathRegisterNs(ctxt, BAD_CAST "netfs", + BAD_CAST STORAGE_POOL_NETFS_NAMESPACE_HREF) < 0= ) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to register xml namespace '%s'"), + STORAGE_POOL_NETFS_NAMESPACE_HREF); + return -1; + } + + nnodes =3D virXPathNodeSet("./netfs:mount_opts/netfs:option", ctxt, &n= odes); + if (nnodes < 0) + return -1; + + if (nnodes =3D=3D 0) + return 0; + + if (VIR_ALLOC(cmdopts) < 0 || + VIR_ALLOC_N(cmdopts->options, nnodes) < 0) + goto cleanup; + + for (i =3D 0; i < nnodes; i++) { + if (!(cmdopts->options[cmdopts->noptions] =3D + virXMLPropString(nodes[i], "name"))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("no netfs mount option name specified")); + goto cleanup; + } + cmdopts->noptions++; + } + + VIR_STEAL_PTR(*data, cmdopts); + ret =3D 0; + + cleanup: + VIR_FREE(nodes); + virStoragePoolDefNetFSNamespaceFree(cmdopts); + return ret; +} + + +static int +virStoragePoolDefNetFSNamespaceFormatXML(virBufferPtr buf, + void *nsdata) +{ + size_t i; + virStoragePoolNetFSMountOptionsDefPtr def =3D nsdata; + + if (!def) + return 0; + + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); + + for (i =3D 0; i < def->noptions; i++) + virBufferEscapeString(buf, "\n", + def->options[i]); + + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + + return 0; +} + + +static const char * +virStoragePoolDefNetFSNamespaceHref(void) +{ + return "xmlns:netfs=3D'" STORAGE_POOL_NETFS_NAMESPACE_HREF "'"; +} + +#endif /* WITH_STORAGE_FS */ + + virStorageBackend virStorageBackendDirectory =3D { .type =3D VIR_STORAGE_POOL_DIR, =20 @@ -617,6 +734,13 @@ virStorageBackend virStorageBackendNetFileSystem =3D { .downloadVol =3D virStorageBackendVolDownloadLocal, .wipeVol =3D virStorageBackendVolWipeLocal, }; + +static virStoragePoolXMLNamespace virStoragePoolNetFSXMLNamespace =3D { + .parse =3D virStoragePoolDefNetFSNamespaceParse, + .free =3D virStoragePoolDefNetFSNamespaceFree, + .format =3D virStoragePoolDefNetFSNamespaceFormatXML, + .href =3D virStoragePoolDefNetFSNamespaceHref, +}; #endif /* WITH_STORAGE_FS */ =20 =20 @@ -632,6 +756,10 @@ virStorageBackendFsRegister(void) =20 if (virStorageBackendRegister(&virStorageBackendNetFileSystem) < 0) return -1; + + if (virStorageBackendNamespaceInit(VIR_STORAGE_POOL_NETFS, + &virStoragePoolNetFSXMLNamespace) <= 0) + return -1; #endif /* WITH_STORAGE_FS */ =20 return 0; diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 0c52b797fc..1c0a8ee5cf 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -77,6 +77,22 @@ =20 VIR_LOG_INIT("storage.storage_util"); =20 + +/* virStorageBackendNamespaceInit: + * @poolType: virStoragePoolType + * @xmlns: Storage Pool specific namespace callback methods + * + * To be called during storage backend registration to configure the + * Storage Pool XML Namespace based on the backend's needs. + */ +int +virStorageBackendNamespaceInit(int poolType, + virStoragePoolXMLNamespacePtr xmlns) +{ + return virStoragePoolOptionsPoolTypeSetXMLNamespace(poolType, xmlns); +} + + #define READ_BLOCK_SIZE_DEFAULT (1024 * 1024) #define WRITE_BLOCK_SIZE_DEFAULT (4 * 1024) =20 diff --git a/src/storage/storage_util.h b/src/storage/storage_util.h index c872468135..b11b1b23f7 100644 --- a/src/storage/storage_util.h +++ b/src/storage/storage_util.h @@ -26,6 +26,20 @@ # include "storage_driver.h" # include "storage_backend.h" =20 +/* NetFS Storage Pool Namespace options to share w/ storage_backend_fs.c a= nd + * the virStorageBackendFileSystemMountCmd method */ +typedef struct _virStoragePoolNetFSMountOptionsDef virStoragePoolNetFSMoun= tOptionsDef; +typedef virStoragePoolNetFSMountOptionsDef *virStoragePoolNetFSMountOption= sDefPtr; +struct _virStoragePoolNetFSMountOptionsDef { + size_t noptions; + char **options; +}; + +int +virStorageBackendNamespaceInit(int poolType, + virStoragePoolXMLNamespacePtr xmlns); + + /* File creation/cloning functions used for cloning between backends */ =20 int --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 08:30:55 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 1547601021701303.66742582116956; Tue, 15 Jan 2019 17:10:21 -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 A6E10C0C7CBE; Wed, 16 Jan 2019 01:10:17 +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 589255C2F4; Wed, 16 Jan 2019 01:10:16 +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 ACFFB18033EC; Wed, 16 Jan 2019 01:10:15 +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 x0G19dEV020518 for ; Tue, 15 Jan 2019 20:09:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id 411B417A66; Wed, 16 Jan 2019 01:09:39 +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 EE29517A65 for ; Wed, 16 Jan 2019 01:09:38 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 15 Jan 2019 20:09:20 -0500 Message-Id: <20190116010922.28250-10-jferlan@redhat.com> In-Reply-To: <20190116010922.28250-1-jferlan@redhat.com> References: <20190116010922.28250-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 v3 09/11] docs, tests: Add schema, description, and tests for NFS namespace 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.31]); Wed, 16 Jan 2019 01:10:20 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Modify the storagepool.rng to allow for the usage of a different XML namespace to parse the netfs_mount_opts to be included with the netfs storage pool definition. Modify the storagepoolxml2xmltest to utilize a properly modified XML file to parse and format the namespace for a netfs storage pool. Signed-off-by: John Ferlan --- docs/formatstorage.html.in | 59 +++++++++++++++++++ docs/schemas/storagepool.rng | 20 +++++++ tests/Makefile.am | 4 +- .../pool-netfs-ns-mountopts.xml | 29 +++++++++ .../pool-netfs-ns-mountopts.xml | 29 +++++++++ tests/storagepoolxml2xmltest.c | 6 ++ 6 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 tests/storagepoolxml2xmlin/pool-netfs-ns-mountopts.xml create mode 100644 tests/storagepoolxml2xmlout/pool-netfs-ns-mountopts.xml diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in index 58f5eb2e2e..525e82552c 100644 --- a/docs/formatstorage.html.in +++ b/docs/formatstorage.html.in @@ -509,6 +509,65 @@ device, measured in bytes. Since 0.4.1

=20 +

Storage Pool Namespaces

+ +

+ Usage of Storage Pool Namespaces provides a mechanism to provide + pool type specific data in a free form or abitrary manner via + XML syntax targeted solely for the needs of the specific pool type + which is not otherwise supportable via XML. For the "netfs" pool + this provides a mechanism to provide additional mount options on the + command line not listed/supported for the mount_opts + element. +

+
+
netfs:mount_opts
+
Provides an XML namespace mechanism to optionally utilize + specifically named options for the mount command via the "-o" + option for the netfs type storage pools. That are + not provided by the mount_opts element. In order + to designate that the Storage Pool will be using the mechanism, + the pool element must be modified to provide the + XML namespace attribute syntax as follows: + +

+ xmlns:netfs=3D'http://libvirt.org/schemas/storagepool/source/netfs= /1.0' +

+ +

+ The netfs:mount_opts defines the mount options by + specifying multiple netfs:option subelements with + the attribute name specifying the mount option to + be added. The value of the named option is not checked since + it's possible options don't exist on all distributions. It is + expected that proper and valid options will be supplied for the + target host. +

+ + The following XML snippet shows the syntax required in order to + utilize +
+<pool type=3D"netfs" xmlns:netfs=3D'http://libvirt.org/schemas/storagep=
ool/source/netfs/1.0'>
+  <name>nfsimages</name>
+...
+  <source>
+...
+  </source>
+...
+  <target>
+...
+  </target>
+  <netfs:mount_opts>
+    <netfs:option name=3D'sync'/>
+    <netfs:option name=3D'lazytime'/>
+  </netfs:mount_opts>
+</pool>
+...
+ + Since 5.1.0.
+ +
+

Storage volume XML

A storage volume will generally be either a file or a device diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng index a32c89b94c..200bd07539 100644 --- a/docs/schemas/storagepool.rng +++ b/docs/schemas/storagepool.rng @@ -64,6 +64,9 @@ + + + =20 @@ -702,4 +705,21 @@ =20 + + + + + + + + + + + + + + diff --git a/tests/Makefile.am b/tests/Makefile.am index f74d8463b6..ab4c716529 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -937,7 +937,9 @@ storagevolxml2xmltest_LDADD =3D $(LDADDS) storagepoolxml2xmltest_SOURCES =3D \ storagepoolxml2xmltest.c \ testutils.c testutils.h -storagepoolxml2xmltest_LDADD =3D $(LDADDS) +storagepoolxml2xmltest_LDADD =3D $(LDADDS) \ + ../src/libvirt_driver_storage_impl.la \ + $(GNULIB_LIBS) =20 nodedevxml2xmltest_SOURCES =3D \ nodedevxml2xmltest.c \ diff --git a/tests/storagepoolxml2xmlin/pool-netfs-ns-mountopts.xml b/tests= /storagepoolxml2xmlin/pool-netfs-ns-mountopts.xml new file mode 100644 index 0000000000..68c51da399 --- /dev/null +++ b/tests/storagepoolxml2xmlin/pool-netfs-ns-mountopts.xml @@ -0,0 +1,29 @@ + + nfsimages + 7641d5a8-af11-f730-a34e-0a7dfcede71f + 0 + 0 + 0 + + +

+ + + + + + + /mnt + + 0700 + 0 + 0 + + + + + + + diff --git a/tests/storagepoolxml2xmlout/pool-netfs-ns-mountopts.xml b/test= s/storagepoolxml2xmlout/pool-netfs-ns-mountopts.xml new file mode 100644 index 0000000000..82df12d646 --- /dev/null +++ b/tests/storagepoolxml2xmlout/pool-netfs-ns-mountopts.xml @@ -0,0 +1,29 @@ + + nfsimages + 7641d5a8-af11-f730-a34e-0a7dfcede71f + 0 + 0 + 0 + + + + + + + + + + /mnt + + 0700 + 0 + 0 + + + + + + + diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c index ecdc2715b0..6b6653dcfe 100644 --- a/tests/storagepoolxml2xmltest.c +++ b/tests/storagepoolxml2xmltest.c @@ -11,6 +11,8 @@ #include "testutilsqemu.h" #include "virstring.h" =20 +#include "storage/storage_util.h" + #define VIR_FROM_THIS VIR_FROM_NONE =20 static int @@ -70,6 +72,9 @@ mymain(void) testCompareXMLToXMLHelper, (name)) < 0) \ ret =3D -1 =20 + if (storageRegisterAll() < 0) + return EXIT_FAILURE; + DO_TEST("pool-dir"); DO_TEST("pool-dir-naming"); DO_TEST("pool-fs"); @@ -87,6 +92,7 @@ mymain(void) DO_TEST("pool-netfs-gluster"); DO_TEST("pool-netfs-cifs"); DO_TEST("pool-netfs-mountopts"); + DO_TEST("pool-netfs-ns-mountopts"); DO_TEST("pool-scsi"); DO_TEST("pool-scsi-type-scsi-host"); DO_TEST("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 From nobody Mon Apr 29 08:30:55 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 1547601023010295.26211863899573; Tue, 15 Jan 2019 17:10:23 -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 7AE7AC0C9A7A; Wed, 16 Jan 2019 01:10:17 +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 2B1E86248E; Wed, 16 Jan 2019 01:10:16 +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 B27343F60B; Wed, 16 Jan 2019 01:10:14 +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 x0G19ddx020523 for ; Tue, 15 Jan 2019 20:09:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id ACFB617A75; Wed, 16 Jan 2019 01:09:39 +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 69D8017A65 for ; Wed, 16 Jan 2019 01:09:39 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 15 Jan 2019 20:09:21 -0500 Message-Id: <20190116010922.28250-11-jferlan@redhat.com> In-Reply-To: <20190116010922.28250-1-jferlan@redhat.com> References: <20190116010922.28250-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 v3 10/11] storage: Add NFS storage pool namespace 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.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.32]); Wed, 16 Jan 2019 01:10:21 +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 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 | 10 +++++++++- .../pool-netfs-ns-mountopts.argv | 2 ++ tests/storagepoolxml2argvtest.c | 4 ++++ 3 files changed, 15 insertions(+), 1 deletion(-) 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 1c0a8ee5cf..8edcd23e2f 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -4354,7 +4354,8 @@ virStorageBackendFileSystemMountCmd(const char *cmdst= r, virStorageBackendFileSystemMountDefaultArgs(cmd, src, def); =20 if (def->type =3D=3D VIR_STORAGE_POOL_NETFS && - (def->source.mountOpts || (def->source.protocolVer > 0))) { + (def->source.mountOpts || (def->source.protocolVer > 0) || + def->namespaceData)) { size_t i; virBuffer buf =3D VIR_BUFFER_INITIALIZER; VIR_AUTOFREE(char *) mountOpts =3D NULL; @@ -4365,6 +4366,13 @@ virStorageBackendFileSystemMountCmd(const char *cmds= tr, for (i =3D 0; i < def->source.nmountOpts; i++) virBufferAsprintf(&buf, "%s,", def->source.mountOpts[i]); =20 + if (def->namespaceData) { + virStoragePoolNetFSMountOptionsDefPtr opts =3D def->namespaceD= ata; + + for (i =3D 0; i < opts->noptions; i++) + virBufferAsprintf(&buf, "%s,", opts->options[i]); + } + virBufferTrim(&buf, ",", -1); =20 if (virBufferCheckError(&buf) < 0) 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..87c5c83c47 --- /dev/null +++ b/tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts.argv @@ -0,0 +1,2 @@ +mount -t nfs localhost:/var/lib/libvirt/images /mnt -o nfsvers=3D3,nodev,n= osuid,\ +sync,lazytime diff --git a/tests/storagepoolxml2argvtest.c b/tests/storagepoolxml2argvtes= t.c index e8bae9fb8c..84a9075c78 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"); @@ -161,6 +164,7 @@ mymain(void) DO_TEST("pool-netfs-gluster"); DO_TEST("pool-netfs-cifs"); DO_TEST("pool-netfs-mountopts"); + DO_TEST("pool-netfs-ns-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 From nobody Mon Apr 29 08:30:55 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 154760102805547.77185280222966; Tue, 15 Jan 2019 17:10:28 -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 E5889C3291; Wed, 16 Jan 2019 01:10:23 +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 362706298C; Wed, 16 Jan 2019 01:10:22 +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 7AE79180339A; Wed, 16 Jan 2019 01:10:21 +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 x0G19ewl020534 for ; Tue, 15 Jan 2019 20:09:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3E43217A66; Wed, 16 Jan 2019 01:09:40 +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 DA64617A65 for ; Wed, 16 Jan 2019 01:09:39 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 15 Jan 2019 20:09:22 -0500 Message-Id: <20190116010922.28250-12-jferlan@redhat.com> In-Reply-To: <20190116010922.28250-1-jferlan@redhat.com> References: <20190116010922.28250-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 v3 11/11] rbd: Utilize storage pool namespace to manage config options 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.26]); Wed, 16 Jan 2019 01:10:25 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Allow for adjustment of RBD configuration options via Storage Pool XML Namespace adjustments. Based off original patch/concept: https://www.redhat.com/archives/libvir-list/2014-May/msg00940.html Signed-off-by: John Ferlan --- docs/formatstorage.html.in | 52 +++++- docs/schemas/storagepool.rng | 23 +++ src/storage/storage_backend_rbd.c | 166 +++++++++++++++++- .../pool-rbd-ns-configopts.xml | 17 ++ .../pool-rbd-ns-configopts.xml | 20 +++ tests/storagepoolxml2xmltest.c | 1 + 6 files changed, 275 insertions(+), 4 deletions(-) create mode 100644 tests/storagepoolxml2xmlin/pool-rbd-ns-configopts.xml create mode 100644 tests/storagepoolxml2xmlout/pool-rbd-ns-configopts.xml diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in index 525e82552c..d34c6f2cc0 100644 --- a/docs/formatstorage.html.in +++ b/docs/formatstorage.html.in @@ -518,7 +518,8 @@ which is not otherwise supportable via XML. For the "netfs" pool this provides a mechanism to provide additional mount options on the command line not listed/supported for the mount_opts - element. + element. For the "rbd" pool this provides a mechanism to override + default settings for RBD configuration options.

netfs:mount_opts
@@ -566,6 +567,55 @@ =20 Since 5.1.0.
=20 +
rbd:config_opts
+
Provides an XML namespace mechanism to optionally utilize + specifically named options for the RBD configuration options + via the rados_conf_set API for the rbd type + storage pools. In order to designate that the Storage Pool + will be using the mechanism, the pool element + must be modified to provide the XML namespace attribute + syntax as follows: + +

+ xmlns:rbd=3D'http://libvirt.org/schemas/storagepool/source/rbd/1.0' +

+ +

+ The rbd:config_opts defines the configuration options + by specifying multiple rbd:option subelements with + the attribute name specifying the configuration option + to be added and value specifying the configuration + option value. The name and value for each option is only checked + to be not empty. The name and value provided are not checked since + it's possible options don't exist on all distributions. It is + expected that proper and valid options will be supplied for the + target host. +

+ + The following XML snippet shows the syntax required in order to + utilize +
+<pool type=3D"rbd" xmlns:rbd=3D'http://libvirt.org/schemas/storagepool/=
source/rbd/1.0'>
+  <name>myrbdpool</name>
+...
+  <source>
+...
+  </source>
+...
+  <target>
+...
+  </target>
+...
+  <rbd:config_opts>
+    <rbd:option name=3D'client_mount_timeout' value=3D'45'/>
+    <rbd:option name=3D'rados_mon_op_timeout' value=3D'20'/>
+    <rbd:option name=3D'rados_osd_op_timeout' value=3D'10'/>
+  </rbd:config_opts>
+</pool>
+
+ + Since 5.1.0.
+
=20

Storage volume XML

diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng index 200bd07539..67efbbc9cf 100644 --- a/docs/schemas/storagepool.rng +++ b/docs/schemas/storagepool.rng @@ -153,6 +153,9 @@ + + + =20 @@ -722,4 +725,24 @@ =20 + + + + + + + + + + + + + + + + + diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backen= d_rbd.c index 24dd1349ae..cc38b76ff2 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -36,6 +36,7 @@ #include "rbd/librbd.h" #include "secret_util.h" #include "storage_util.h" +#include =20 #define VIR_FROM_THIS VIR_FROM_STORAGE =20 @@ -50,6 +51,140 @@ struct _virStorageBackendRBDState { typedef struct _virStorageBackendRBDState virStorageBackendRBDState; typedef virStorageBackendRBDState *virStorageBackendRBDStatePtr; =20 +/* NetFS Storage Pool Namespace options to share w/ storage_backend_fs.c a= nd + * the virStorageBackendFileSystemMountCmd method */ +typedef struct _virStoragePoolRBDMountOptionsDef virStoragePoolRBDMountOpt= ionsDef; +typedef virStoragePoolRBDMountOptionsDef *virStoragePoolRBDMountOptionsDef= Ptr; +struct _virStoragePoolRBDMountOptionsDef { + size_t noptions; + char **names; + char **values; +}; + +#define STORAGE_POOL_RBD_NAMESPACE_HREF "http://libvirt.org/schemas/storag= epool/source/rbd/1.0" + +static void +virStoragePoolDefRBDNamespaceFree(void *nsdata) +{ + virStoragePoolRBDMountOptionsDefPtr cmdopts =3D nsdata; + size_t i; + + if (!cmdopts) + return; + + for (i =3D 0; i < cmdopts->noptions; i++) { + VIR_FREE(cmdopts->names[i]); + VIR_FREE(cmdopts->values[i]); + } + VIR_FREE(cmdopts->names); + VIR_FREE(cmdopts->values); + + VIR_FREE(cmdopts); +} + + +static int +virStoragePoolDefRBDNamespaceParse(xmlXPathContextPtr ctxt, + void **data) +{ + virStoragePoolRBDMountOptionsDefPtr cmdopts =3D NULL; + xmlNodePtr *nodes =3D NULL; + int nnodes; + size_t i; + int ret =3D -1; + + if (xmlXPathRegisterNs(ctxt, BAD_CAST "rbd", + BAD_CAST STORAGE_POOL_RBD_NAMESPACE_HREF) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to register xml namespace '%s'"), + STORAGE_POOL_RBD_NAMESPACE_HREF); + return -1; + } + + nnodes =3D virXPathNodeSet("./rbd:config_opts/rbd:option", ctxt, &node= s); + if (nnodes < 0) + return -1; + + if (nnodes =3D=3D 0) + return 0; + + if (VIR_ALLOC(cmdopts) < 0) + goto cleanup; + + if (VIR_ALLOC_N(cmdopts->names, nnodes) < 0 || + VIR_ALLOC_N(cmdopts->values, nnodes) < 0) + goto cleanup; + + for (i =3D 0; i < nnodes; i++) { + if (!(cmdopts->names[cmdopts->noptions] =3D + virXMLPropString(nodes[i], "name"))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("no rbd option name specified")); + goto cleanup; + } + if (*cmdopts->names[cmdopts->noptions] =3D=3D '\0') { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("empty rbd option name specified")); + goto cleanup; + } + if (!(cmdopts->values[cmdopts->noptions] =3D + virXMLPropString(nodes[i], "value"))) { + virReportError(VIR_ERR_XML_ERROR, + _("no rbd option value specified for name '%s'"= ), + cmdopts->names[cmdopts->noptions]); + goto cleanup; + } + if (*cmdopts->values[cmdopts->noptions] =3D=3D '\0') { + virReportError(VIR_ERR_XML_ERROR, + _("empty rbd option value specified for name '%= s'"), + cmdopts->names[cmdopts->noptions]); + goto cleanup; + } + cmdopts->noptions++; + } + + VIR_STEAL_PTR(*data, cmdopts); + ret =3D 0; + + cleanup: + VIR_FREE(nodes); + virStoragePoolDefRBDNamespaceFree(cmdopts); + return ret; +} + + +static int +virStoragePoolDefRBDNamespaceFormatXML(virBufferPtr buf, + void *nsdata) +{ + size_t i; + virStoragePoolRBDMountOptionsDefPtr def =3D nsdata; + + if (!def) + return 0; + + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); + + for (i =3D 0; i < def->noptions; i++) { + virBufferEscapeString(buf, "names[= i]); + virBufferEscapeString(buf, "value=3D'%s'/>\n", def->values[i]); + } + + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + + return 0; +} + + +static const char * +virStoragePoolDefRBDNamespaceHref(void) +{ + return "xmlns:rbd=3D'" STORAGE_POOL_RBD_NAMESPACE_HREF "'"; +} + + static int virStorageBackendRBDRADOSConfSet(rados_t cluster, const char *option, @@ -69,10 +204,11 @@ virStorageBackendRBDRADOSConfSet(rados_t cluster, =20 static int virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr ptr, - virStoragePoolSourcePtr source) + virStoragePoolDefPtr def) { int ret =3D -1; int r =3D 0; + virStoragePoolSourcePtr source =3D &def->source; virStorageAuthDefPtr authdef =3D source->auth; unsigned char *secret_value =3D NULL; size_t secret_value_size =3D 0; @@ -183,6 +319,17 @@ virStorageBackendRBDOpenRADOSConn(virStorageBackendRBD= StatePtr ptr, rbd_default_format) < 0) goto cleanup; =20 + if (def->namespaceData) { + virStoragePoolRBDMountOptionsDefPtr cmdopts =3D def->namespaceData; + + for (i =3D 0; i < cmdopts->noptions; i++) { + if (virStorageBackendRBDRADOSConfSet(ptr->cluster, + cmdopts->names[i], + cmdopts->values[i]) < 0) + goto cleanup; + } + } + ptr->starttime =3D time(0); if ((r =3D rados_connect(ptr->cluster)) < 0) { virReportSystemError(-r, _("failed to connect to the RADOS monitor= on: %s"), @@ -256,7 +403,7 @@ virStorageBackendRBDNewState(virStoragePoolObjPtr pool) if (VIR_ALLOC(ptr) < 0) return NULL; =20 - if (virStorageBackendRBDOpenRADOSConn(ptr, &def->source) < 0) + if (virStorageBackendRBDOpenRADOSConn(ptr, def) < 0) goto error; =20 if (virStorageBackendRBDOpenIoCTX(ptr, pool) < 0) @@ -1277,6 +1424,7 @@ virStorageBackendRBDVolWipe(virStoragePoolObjPtr pool, return ret; } =20 + virStorageBackend virStorageBackendRBD =3D { .type =3D VIR_STORAGE_POOL_RBD, =20 @@ -1291,8 +1439,20 @@ virStorageBackend virStorageBackendRBD =3D { }; =20 =20 +static virStoragePoolXMLNamespace virStoragePoolRBDXMLNamespace =3D { + .parse =3D virStoragePoolDefRBDNamespaceParse, + .free =3D virStoragePoolDefRBDNamespaceFree, + .format =3D virStoragePoolDefRBDNamespaceFormatXML, + .href =3D virStoragePoolDefRBDNamespaceHref, +}; + + int virStorageBackendRBDRegister(void) { - return virStorageBackendRegister(&virStorageBackendRBD); + if (virStorageBackendRegister(&virStorageBackendRBD) < 0) + return -1; + + return virStorageBackendNamespaceInit(VIR_STORAGE_POOL_RBD, + &virStoragePoolRBDXMLNamespace); } diff --git a/tests/storagepoolxml2xmlin/pool-rbd-ns-configopts.xml b/tests/= storagepoolxml2xmlin/pool-rbd-ns-configopts.xml new file mode 100644 index 0000000000..6b62aa6f7e --- /dev/null +++ b/tests/storagepoolxml2xmlin/pool-rbd-ns-configopts.xml @@ -0,0 +1,17 @@ + + ceph + 47c1faee-0207-e741-f5ae-d9b019b98fe2 + + rbd + + + + + + + + + + + + diff --git a/tests/storagepoolxml2xmlout/pool-rbd-ns-configopts.xml b/tests= /storagepoolxml2xmlout/pool-rbd-ns-configopts.xml new file mode 100644 index 0000000000..342a0ff74a --- /dev/null +++ b/tests/storagepoolxml2xmlout/pool-rbd-ns-configopts.xml @@ -0,0 +1,20 @@ + + ceph + 47c1faee-0207-e741-f5ae-d9b019b98fe2 + 0 + 0 + 0 + + + + rbd + + + + + + + + + + diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c index 6b6653dcfe..16cb032244 100644 --- a/tests/storagepoolxml2xmltest.c +++ b/tests/storagepoolxml2xmltest.c @@ -107,6 +107,7 @@ mymain(void) DO_TEST("pool-zfs"); DO_TEST("pool-zfs-sourcedev"); DO_TEST("pool-rbd"); + DO_TEST("pool-rbd-ns-configopts"); DO_TEST("pool-vstorage"); DO_TEST("pool-iscsi-direct-auth"); DO_TEST("pool-iscsi-direct"); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list