From nobody Tue Apr 30 05:12:32 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 1547760151517904.4582095039538; Thu, 17 Jan 2019 13:22:31 -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 734B04902D; Thu, 17 Jan 2019 21:22:29 +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 61E48600C9; Thu, 17 Jan 2019 21:22:28 +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 4F3E43F602; Thu, 17 Jan 2019 21:22:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x0HLMMpD004084 for ; Thu, 17 Jan 2019 16:22:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id CFCD060BF1; Thu, 17 Jan 2019 21:22:22 +0000 (UTC) Received: from unknown0050b6a41c42.attlocal.net.com (ovpn-116-60.phx2.redhat.com [10.3.116.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8963360BE8 for ; Thu, 17 Jan 2019 21:22:22 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Thu, 17 Jan 2019 16:22:07 -0500 Message-Id: <20190117212216.28316-2-jferlan@redhat.com> In-Reply-To: <20190117212216.28316-1-jferlan@redhat.com> References: <20190117212216.28316-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 v4 01/10] storage: Add default mount options for NFS Storage Pools 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.38]); Thu, 17 Jan 2019 21:22:30 +0000 (UTC) Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1584663 Modify the command generation to add some default options to an NFS Storage Pool based on the OS type. For Linux, it'll be the "nodev, nosuid, noexec". For FreeBSD, it'll be "nosuid, noexec". For others, just leave the options alone. Modify the storagepoolxml2argvtest to handle the fact that the same input XML could generate different output XML based on whether Linux, FreeBSD, or other was being built. Signed-off-by: John Ferlan --- src/storage/storage_util.c | 16 ++++++++ .../pool-netfs-auto-freebsd.argv | 1 + .../pool-netfs-auto-linux.argv | 1 + .../pool-netfs-freebsd.argv | 1 + .../pool-netfs-linux.argv | 1 + tests/storagepoolxml2argvtest.c | 40 +++++++++++++++---- 6 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 tests/storagepoolxml2argvdata/pool-netfs-auto-freebsd.a= rgv create mode 100644 tests/storagepoolxml2argvdata/pool-netfs-auto-linux.argv create mode 100644 tests/storagepoolxml2argvdata/pool-netfs-freebsd.argv create mode 100644 tests/storagepoolxml2argvdata/pool-netfs-linux.argv diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index a84ee5b600..44a95d9fab 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -34,6 +34,11 @@ # ifndef FS_NOCOW_FL # define FS_NOCOW_FL 0x00800000 /* Do not cow file */ # endif +# define default_nfs_mount_opts "nodev,nosuid,noexec" +#elif defined(__FreeBSD__) +# define default_nfs_mount_opts "nosuid,noexec" +#else +# define default_nfs_mount_opts "" #endif =20 #if WITH_BLKID @@ -4261,12 +4266,21 @@ virStorageBackendFileSystemGetPoolSource(virStorage= PoolObjPtr pool) } =20 =20 +static void +virStorageBackendFileSystemMountNFSAddOptions(virCommandPtr cmd) +{ + if (*default_nfs_mount_opts !=3D '\0') + virCommandAddArgList(cmd, "-o", default_nfs_mount_opts, NULL); +} + + static void virStorageBackendFileSystemMountNFSArgs(virCommandPtr cmd, const char *src, virStoragePoolDefPtr def) { virCommandAddArgList(cmd, src, def->target.path, NULL); + virStorageBackendFileSystemMountNFSAddOptions(cmd); } =20 =20 @@ -4308,6 +4322,8 @@ virStorageBackendFileSystemMountDefaultArgs(virComman= dPtr cmd, else fmt =3D virStoragePoolFormatFileSystemNetTypeToString(def->source.= format); virCommandAddArgList(cmd, "-t", fmt, src, def->target.path, NULL); + if (def->type =3D=3D VIR_STORAGE_POOL_NETFS) + virStorageBackendFileSystemMountNFSAddOptions(cmd); } =20 =20 diff --git a/tests/storagepoolxml2argvdata/pool-netfs-auto-freebsd.argv b/t= ests/storagepoolxml2argvdata/pool-netfs-auto-freebsd.argv new file mode 100644 index 0000000000..39e5c97aed --- /dev/null +++ b/tests/storagepoolxml2argvdata/pool-netfs-auto-freebsd.argv @@ -0,0 +1 @@ +mount localhost:/var/lib/libvirt/images /mnt -o nosuid,noexec diff --git a/tests/storagepoolxml2argvdata/pool-netfs-auto-linux.argv b/tes= ts/storagepoolxml2argvdata/pool-netfs-auto-linux.argv new file mode 100644 index 0000000000..1f82d3d29c --- /dev/null +++ b/tests/storagepoolxml2argvdata/pool-netfs-auto-linux.argv @@ -0,0 +1 @@ +mount localhost:/var/lib/libvirt/images /mnt -o nodev,nosuid,noexec diff --git a/tests/storagepoolxml2argvdata/pool-netfs-freebsd.argv b/tests/= storagepoolxml2argvdata/pool-netfs-freebsd.argv new file mode 100644 index 0000000000..05c1951f32 --- /dev/null +++ b/tests/storagepoolxml2argvdata/pool-netfs-freebsd.argv @@ -0,0 +1 @@ +mount -t nfs localhost:/var/lib/libvirt/images /mnt -o nosuid,noexec diff --git a/tests/storagepoolxml2argvdata/pool-netfs-linux.argv b/tests/st= oragepoolxml2argvdata/pool-netfs-linux.argv new file mode 100644 index 0000000000..22fafd7b32 --- /dev/null +++ b/tests/storagepoolxml2argvdata/pool-netfs-linux.argv @@ -0,0 +1 @@ +mount -t nfs localhost:/var/lib/libvirt/images /mnt -o nodev,nosuid,noexec diff --git a/tests/storagepoolxml2argvtest.c b/tests/storagepoolxml2argvtes= t.c index 2f2d40e027..c114fecbcf 100644 --- a/tests/storagepoolxml2argvtest.c +++ b/tests/storagepoolxml2argvtest.c @@ -96,6 +96,8 @@ testCompareXMLToArgvFiles(bool shouldFail, struct testInfo { bool shouldFail; const char *pool; + bool linuxOut; + bool freebsdOut; }; =20 static int @@ -110,9 +112,19 @@ testCompareXMLToArgvHelper(const void *data) abs_srcdir, info->pool) < 0) goto cleanup; =20 - if (virAsprintf(&cmdline, "%s/storagepoolxml2argvdata/%s.argv", - abs_srcdir, info->pool) < 0 && !info->shouldFail) - goto cleanup; + if (info->linuxOut) { + if (virAsprintf(&cmdline, "%s/storagepoolxml2argvdata/%s-linux.arg= v", + abs_srcdir, info->pool) < 0 && !info->shouldFail) + goto cleanup; + } else if (info->freebsdOut) { + if (virAsprintf(&cmdline, "%s/storagepoolxml2argvdata/%s-freebsd.a= rgv", + abs_srcdir, info->pool) < 0 && !info->shouldFail) + goto cleanup; + } else { + if (virAsprintf(&cmdline, "%s/storagepoolxml2argvdata/%s.argv", + abs_srcdir, info->pool) < 0 && !info->shouldFail) + goto cleanup; + } =20 result =3D testCompareXMLToArgvFiles(info->shouldFail, poolxml, cmdlin= e); =20 @@ -129,9 +141,9 @@ mymain(void) { int ret =3D 0; =20 -#define DO_TEST_FULL(shouldFail, pool) \ +#define DO_TEST_FULL(shouldFail, pool, linuxOut, freebsdOut) \ do { \ - struct testInfo info =3D { shouldFail, pool }; \ + struct testInfo info =3D { shouldFail, pool, linuxOut, freebsdOut = }; \ if (virTestRun("Storage Pool XML-2-argv " pool, \ testCompareXMLToArgvHelper, &info) < 0) \ ret =3D -1; \ @@ -139,10 +151,16 @@ mymain(void) while (0); =20 #define DO_TEST(pool, ...) \ - DO_TEST_FULL(false, pool) + DO_TEST_FULL(false, pool, false, false) =20 #define DO_TEST_FAIL(pool, ...) \ - DO_TEST_FULL(true, pool) + DO_TEST_FULL(true, pool, false, false) + +#define DO_TEST_LINUX(pool, ...) \ + DO_TEST_FULL(false, pool, true, false) + +#define DO_TEST_FREEBSD(pool, ...) \ + DO_TEST_FULL(false, pool, false, true) =20 DO_TEST_FAIL("pool-dir"); DO_TEST_FAIL("pool-dir-naming"); @@ -155,8 +173,16 @@ mymain(void) DO_TEST_FAIL("pool-disk-device-nopartsep"); DO_TEST_FAIL("pool-iscsi"); DO_TEST_FAIL("pool-iscsi-auth"); +#ifdef __linux__ + DO_TEST_LINUX("pool-netfs"); + DO_TEST_LINUX("pool-netfs-auto"); +#elif defined(__FreeBSD__) + DO_TEST_FREEBSD("pool-netfs"); + DO_TEST_FREEBSD("pool-netfs-auto"); +#else DO_TEST("pool-netfs"); DO_TEST("pool-netfs-auto"); +#endif DO_TEST("pool-netfs-gluster"); DO_TEST("pool-netfs-cifs"); DO_TEST_FAIL("pool-scsi"); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 05:12:32 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 1547760170586819.9429306972091; Thu, 17 Jan 2019 13:22:50 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BCA27C002968; Thu, 17 Jan 2019 21:22:48 +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 8895060BE5; Thu, 17 Jan 2019 21:22:48 +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 29EBC3F605; Thu, 17 Jan 2019 21:22:48 +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 x0HLMNlE004089 for ; Thu, 17 Jan 2019 16:22:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4C41160BF1; Thu, 17 Jan 2019 21:22:23 +0000 (UTC) Received: from unknown0050b6a41c42.attlocal.net.com (ovpn-116-60.phx2.redhat.com [10.3.116.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 05FA060BE8 for ; Thu, 17 Jan 2019 21:22:22 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Thu, 17 Jan 2019 16:22:08 -0500 Message-Id: <20190117212216.28316-3-jferlan@redhat.com> In-Reply-To: <20190117212216.28316-1-jferlan@redhat.com> References: <20190117212216.28316-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 v4 02/10] docs: Add news mention of 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 17 Jan 2019 21:22:49 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: John Ferlan --- docs/news.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/news.xml b/docs/news.xml index bc11791d03..12bff206c1 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -39,6 +39,17 @@
+ + + storage: Add default mount options for NFS Storage Pools + + + Altered the command line generation for NFS Storage Pools to + add some default options. For Linux based systems, the options + added are "nodev, nosuid, noexec". For FreeBSD based systems, + the options added are "nosuid, noexec". + +
--=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 05:12:32 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 1547760170502273.1297203439361; Thu, 17 Jan 2019 13:22:50 -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 96170AB436; Thu, 17 Jan 2019 21:22:48 +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 57E4161B66; Thu, 17 Jan 2019 21:22:48 +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 F21AB3F606; Thu, 17 Jan 2019 21:22:47 +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 x0HLMN26004094 for ; Thu, 17 Jan 2019 16:22:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id BF9B160BE8; Thu, 17 Jan 2019 21:22:23 +0000 (UTC) Received: from unknown0050b6a41c42.attlocal.net.com (ovpn-116-60.phx2.redhat.com [10.3.116.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 78E4560BE5 for ; Thu, 17 Jan 2019 21:22:23 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Thu, 17 Jan 2019 16:22:09 -0500 Message-Id: <20190117212216.28316-4-jferlan@redhat.com> In-Reply-To: <20190117212216.28316-1-jferlan@redhat.com> References: <20190117212216.28316-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 v4 03/10] 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 17 Jan 2019 21:22:49 +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 Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/formatstorage.html.in | 16 ++++++++++++++ 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, 91 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 b6bf3edbd2..b1b76a1dda 100644 --- a/docs/formatstorage.html.in +++ b/docs/formatstorage.html.in @@ -121,6 +121,16 @@ </source> ... =20 +
+...
+  <source>
+    <host name=3D'localhost'/>
+    <dir path=3D'/var/lib/libvirt/images'/>
+    <format type=3D'nfs'/>
+    <protocol ver=3D'3'/>
+  </source>
+...
+
device
Provides the source for pools backed by physical devices @@ -386,6 +396,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
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..f9a16422cc 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 55db7a96f5..76e0bb987b 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -420,6 +420,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; @@ -546,6 +547,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; + } + } + source->vendor =3D virXPathString("string(./vendor/@name)", ctxt); source->product =3D virXPathString("string(./product/@name)", ctxt); =20 @@ -962,6 +981,9 @@ virStoragePoolSourceFormat(virBufferPtr buf, if (src->auth) virStorageAuthDefFormat(buf, src->auth); =20 + if (src->protocolVer) + virBufferAsprintf(buf, "\n", src->protocolVe= r); + 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..a6763447a7 100644 --- a/src/conf/storage_conf.h +++ b/src/conf/storage_conf.h @@ -197,6 +197,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 707d09f5c2..d18390034f 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-scsi"); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 05:12:32 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 1547760175865938.7727430720697; Thu, 17 Jan 2019 13:22:55 -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 33BE938EC7; Thu, 17 Jan 2019 21:22:53 +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 F0EEA1048117; Thu, 17 Jan 2019 21:22:52 +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 8DBC83F60C; Thu, 17 Jan 2019 21:22:52 +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 x0HLMOul004099 for ; Thu, 17 Jan 2019 16:22:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3C82460BE8; Thu, 17 Jan 2019 21:22:24 +0000 (UTC) Received: from unknown0050b6a41c42.attlocal.net.com (ovpn-116-60.phx2.redhat.com [10.3.116.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id E9EE760BE5 for ; Thu, 17 Jan 2019 21:22:23 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Thu, 17 Jan 2019 16:22:10 -0500 Message-Id: <20190117212216.28316-5-jferlan@redhat.com> In-Reply-To: <20190117212216.28316-1-jferlan@redhat.com> References: <20190117212216.28316-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 v4 04/10] 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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 17 Jan 2019 21:22:54 +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 Reviewed-by: Daniel P. Berrang=C3=A9 --- src/storage/storage_util.c | 20 +++++++++++++++---- .../pool-netfs-protocol-ver-freebsd.argv | 1 + .../pool-netfs-protocol-ver-linux.argv | 2 ++ .../pool-netfs-protocol-ver.argv | 1 + tests/storagepoolxml2argvtest.c | 3 +++ 5 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 tests/storagepoolxml2argvdata/pool-netfs-protocol-ver-f= reebsd.argv create mode 100644 tests/storagepoolxml2argvdata/pool-netfs-protocol-ver-l= inux.argv 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 44a95d9fab..b82bef2904 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -4267,10 +4267,22 @@ virStorageBackendFileSystemGetPoolSource(virStorage= PoolObjPtr pool) =20 =20 static void -virStorageBackendFileSystemMountNFSAddOptions(virCommandPtr cmd) +virStorageBackendFileSystemMountNFSAddOptions(virCommandPtr cmd, + virStoragePoolDefPtr def) { + VIR_AUTOFREE(char *) mountOpts =3D NULL; + virBuffer buf =3D VIR_BUFFER_INITIALIZER; + + if (def->source.protocolVer > 0) + virBufferAsprintf(&buf, "nfsvers=3D%u,", def->source.protocolVer); + if (*default_nfs_mount_opts !=3D '\0') - virCommandAddArgList(cmd, "-o", default_nfs_mount_opts, NULL); + virBufferAddLit(&buf, default_nfs_mount_opts); + + virBufferTrim(&buf, ",", -1); + mountOpts =3D virBufferContentAndReset(&buf); + if (mountOpts) + virCommandAddArgList(cmd, "-o", mountOpts, NULL); } =20 =20 @@ -4280,7 +4292,7 @@ virStorageBackendFileSystemMountNFSArgs(virCommandPtr= cmd, virStoragePoolDefPtr def) { virCommandAddArgList(cmd, src, def->target.path, NULL); - virStorageBackendFileSystemMountNFSAddOptions(cmd); + virStorageBackendFileSystemMountNFSAddOptions(cmd, def); } =20 =20 @@ -4323,7 +4335,7 @@ virStorageBackendFileSystemMountDefaultArgs(virComman= dPtr cmd, fmt =3D virStoragePoolFormatFileSystemNetTypeToString(def->source.= format); virCommandAddArgList(cmd, "-t", fmt, src, def->target.path, NULL); if (def->type =3D=3D VIR_STORAGE_POOL_NETFS) - virStorageBackendFileSystemMountNFSAddOptions(cmd); + virStorageBackendFileSystemMountNFSAddOptions(cmd, def); } =20 =20 diff --git a/tests/storagepoolxml2argvdata/pool-netfs-protocol-ver-freebsd.= argv b/tests/storagepoolxml2argvdata/pool-netfs-protocol-ver-freebsd.argv new file mode 100644 index 0000000000..3384a8a8dd --- /dev/null +++ b/tests/storagepoolxml2argvdata/pool-netfs-protocol-ver-freebsd.argv @@ -0,0 +1 @@ +mount -t nfs localhost:/var/lib/libvirt/images /mnt -o nfsvers=3D3,nosuid,= noexec diff --git a/tests/storagepoolxml2argvdata/pool-netfs-protocol-ver-linux.ar= gv b/tests/storagepoolxml2argvdata/pool-netfs-protocol-ver-linux.argv new file mode 100644 index 0000000000..7508046340 --- /dev/null +++ b/tests/storagepoolxml2argvdata/pool-netfs-protocol-ver-linux.argv @@ -0,0 +1,2 @@ +mount -t nfs localhost:/var/lib/libvirt/images /mnt -o nfsvers=3D3,nodev,n= osuid,\ +noexec 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 c114fecbcf..b6a46280cd 100644 --- a/tests/storagepoolxml2argvtest.c +++ b/tests/storagepoolxml2argvtest.c @@ -176,12 +176,15 @@ mymain(void) #ifdef __linux__ DO_TEST_LINUX("pool-netfs"); DO_TEST_LINUX("pool-netfs-auto"); + DO_TEST_LINUX("pool-netfs-protocol-ver"); #elif defined(__FreeBSD__) DO_TEST_FREEBSD("pool-netfs"); DO_TEST_FREEBSD("pool-netfs-auto"); + DO_TEST_FREEBSD("pool-netfs-protocol-ver"); #else DO_TEST("pool-netfs"); DO_TEST("pool-netfs-auto"); + DO_TEST("pool-netfs-protocol-ver"); #endif DO_TEST("pool-netfs-gluster"); DO_TEST("pool-netfs-cifs"); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 05:12:32 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 1547760151066352.9339891800222; Thu, 17 Jan 2019 13:22:31 -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 CA453394D3F; Thu, 17 Jan 2019 21:22:28 +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 4A8E15D9CA; Thu, 17 Jan 2019 21:22:28 +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 7A5F118005B1; Thu, 17 Jan 2019 21:22:26 +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 x0HLMO91004107 for ; Thu, 17 Jan 2019 16:22:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id AD13160BE8; Thu, 17 Jan 2019 21:22:24 +0000 (UTC) Received: from unknown0050b6a41c42.attlocal.net.com (ovpn-116-60.phx2.redhat.com [10.3.116.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 66B5460BE5 for ; Thu, 17 Jan 2019 21:22:24 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Thu, 17 Jan 2019 16:22:11 -0500 Message-Id: <20190117212216.28316-6-jferlan@redhat.com> In-Reply-To: <20190117212216.28316-1-jferlan@redhat.com> References: <20190117212216.28316-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 v4 05/10] 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]); Thu, 17 Jan 2019 21:22:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Allow the addition of the to the provided XML. Signed-off-by: John Ferlan Reviewed-by: Daniel P. Berrang=C3=A9 --- tools/virsh-pool.c | 12 ++++++++++-- tools/virsh.pod | 5 +++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index 70ca39bd3d..9514570468 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-protocol-ver", \ + .type =3D VSH_OT_STRING, \ + .help =3D N_("nfsvers value for NFS pool mount option") \ } =20 virStoragePoolPtr @@ -319,7 +323,7 @@ virshBuildPoolXML(vshControl *ctl, *secretUsage =3D NULL, *adapterName =3D NULL, *adapterParen= t =3D NULL, *adapterWwnn =3D NULL, *adapterWwpn =3D NULL, *secretUUID = =3D NULL, *adapterParentWwnn =3D NULL, *adapterParentWwpn =3D NULL, - *adapterParentFabricWwn =3D NULL; + *adapterParentFabricWwn =3D NULL, *protoVer =3D NULL; virBuffer buf =3D VIR_BUFFER_INITIALIZER; =20 VSH_EXCLUSIVE_OPTIONS("secret-usage", "secret-uuid"); @@ -345,7 +349,8 @@ 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-protocol-ver", &protoVer)= < 0) goto cleanup; =20 virBufferAsprintf(&buf, "\n", type); @@ -394,6 +399,9 @@ virshBuildPoolXML(vshControl *ctl, if (srcName) virBufferAsprintf(&buf, "%s\n", srcName); =20 + if (protoVer) + virBufferAsprintf(&buf, "\n", protoVer); + virBufferAdjustIndent(&buf, -2); virBufferAddLit(&buf, "\n"); } diff --git a/tools/virsh.pod b/tools/virsh.pod index 86a4996cae..59a5900162 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-protocol-ver ver>] [[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,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<--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 Tue Apr 30 05:12:32 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 1547760176421585.291266171912; Thu, 17 Jan 2019 13:22:56 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DF15DC0C6C34; Thu, 17 Jan 2019 21:22:53 +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 A5303608E8; Thu, 17 Jan 2019 21:22:53 +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 45F8A18033CB; Thu, 17 Jan 2019 21:22:53 +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 x0HLMPqC004118 for ; Thu, 17 Jan 2019 16:22:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id 29AF560BE8; Thu, 17 Jan 2019 21:22:25 +0000 (UTC) Received: from unknown0050b6a41c42.attlocal.net.com (ovpn-116-60.phx2.redhat.com [10.3.116.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id D8C3A60BE5 for ; Thu, 17 Jan 2019 21:22:24 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Thu, 17 Jan 2019 16:22:12 -0500 Message-Id: <20190117212216.28316-7-jferlan@redhat.com> In-Reply-To: <20190117212216.28316-1-jferlan@redhat.com> References: <20190117212216.28316-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 v4 06/10] 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.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 17 Jan 2019 21:22:54 +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 Reviewed-by: Daniel P. Berrang=C3=A9 --- 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 76e0bb987b..a7298381ef 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -124,6 +124,9 @@ typedef virStoragePoolOptions *virStoragePoolOptionsPtr; struct _virStoragePoolOptions { unsigned int flags; int defaultFormat; + + virStoragePoolXMLNamespace ns; + virStoragePoolFormatToString formatToString; virStoragePoolFormatFromString formatFromString; }; @@ -318,6 +321,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) { @@ -401,6 +432,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 @@ -835,6 +868,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); @@ -1011,7 +1051,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 @@ -1064,6 +1107,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 a6763447a7..24217eb401 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 @@ -222,6 +242,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 Tue Apr 30 05:12:32 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 154776018098750.3243476236911; Thu, 17 Jan 2019 13:23:00 -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 0413B18DF7C; Thu, 17 Jan 2019 21:22:59 +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 BFE3719741; Thu, 17 Jan 2019 21:22:58 +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 7AFAF3F608; Thu, 17 Jan 2019 21:22:58 +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 x0HLMQUL004130 for ; Thu, 17 Jan 2019 16:22:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id A664B60BE8; Thu, 17 Jan 2019 21:22:26 +0000 (UTC) Received: from unknown0050b6a41c42.attlocal.net.com (ovpn-116-60.phx2.redhat.com [10.3.116.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6003260BE5 for ; Thu, 17 Jan 2019 21:22:25 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Thu, 17 Jan 2019 16:22:13 -0500 Message-Id: <20190117212216.28316-8-jferlan@redhat.com> In-Reply-To: <20190117212216.28316-1-jferlan@redhat.com> References: <20190117212216.28316-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 v4 07/10] 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.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.29]); Thu, 17 Jan 2019 21:22:59 +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 Reviewed-by: Daniel P. Berrang=C3=A9 --- 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 b82bef2904..2e753f4501 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -82,6 +82,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 Tue Apr 30 05:12:32 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 1547760179587612.8891985843669; Thu, 17 Jan 2019 13:22:59 -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 58417461F8; Thu, 17 Jan 2019 21:22:57 +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 2AA23600C9; Thu, 17 Jan 2019 21:22:57 +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 E2F041803399; Thu, 17 Jan 2019 21:22:56 +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 x0HLMRNN004140 for ; Thu, 17 Jan 2019 16:22:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2459460BE8; Thu, 17 Jan 2019 21:22:27 +0000 (UTC) Received: from unknown0050b6a41c42.attlocal.net.com (ovpn-116-60.phx2.redhat.com [10.3.116.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id D2A9060BE5 for ; Thu, 17 Jan 2019 21:22:26 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Thu, 17 Jan 2019 16:22:14 -0500 Message-Id: <20190117212216.28316-9-jferlan@redhat.com> In-Reply-To: <20190117212216.28316-1-jferlan@redhat.com> References: <20190117212216.28316-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 v4 08/10] 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.29]); Thu, 17 Jan 2019 21:22:57 +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 | 57 +++++++++++++++++++ docs/schemas/storagepool.rng | 20 +++++++ tests/Makefile.am | 4 +- .../pool-netfs-ns-mountopts.xml | 25 ++++++++ .../pool-netfs-ns-mountopts.xml | 25 ++++++++ tests/storagepoolxml2xmltest.c | 6 ++ 6 files changed, 136 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 b1b76a1dda..7a5a38de9e 100644 --- a/docs/formatstorage.html.in +++ b/docs/formatstorage.html.in @@ -497,6 +497,63 @@ 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. +

+
+
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. 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 f9a16422cc..cea4bb474a 100644 --- a/docs/schemas/storagepool.rng +++ b/docs/schemas/storagepool.rng @@ -64,6 +64,9 @@ + + + =20 @@ -682,4 +685,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..6295edd6ee --- /dev/null +++ b/tests/storagepoolxml2xmlin/pool-netfs-ns-mountopts.xml @@ -0,0 +1,25 @@ + + 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..efa7b07f31 --- /dev/null +++ b/tests/storagepoolxml2xmlout/pool-netfs-ns-mountopts.xml @@ -0,0 +1,25 @@ + + nfsimages + 7641d5a8-af11-f730-a34e-0a7dfcede71f + 0 + 0 + 0 + + + + + + + + /mnt + + 0700 + 0 + 0 + + + + + + + diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c index d18390034f..aff9ff160c 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"); @@ -86,6 +91,7 @@ mymain(void) DO_TEST("pool-netfs-protocol-ver"); DO_TEST("pool-netfs-gluster"); DO_TEST("pool-netfs-cifs"); + 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 Tue Apr 30 05:12:32 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 1547760173963366.80390501200236; Thu, 17 Jan 2019 13:22:53 -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 B7F2F7AEB3; Thu, 17 Jan 2019 21:22:51 +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 7B4FB5D717; Thu, 17 Jan 2019 21:22:51 +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 2CDBC3F608; Thu, 17 Jan 2019 21:22:51 +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 x0HLMR34004150 for ; Thu, 17 Jan 2019 16:22:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9548060BE8; Thu, 17 Jan 2019 21:22:27 +0000 (UTC) Received: from unknown0050b6a41c42.attlocal.net.com (ovpn-116-60.phx2.redhat.com [10.3.116.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4FB6E60BE5 for ; Thu, 17 Jan 2019 21:22:27 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Thu, 17 Jan 2019 16:22:15 -0500 Message-Id: <20190117212216.28316-10-jferlan@redhat.com> In-Reply-To: <20190117212216.28316-1-jferlan@redhat.com> References: <20190117212216.28316-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 v4 09/10] 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.25]); Thu, 17 Jan 2019 21:22:52 +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 Reviewed-by: Daniel P. Berrang=C3=A9 --- src/storage/storage_util.c | 10 +++++++++- .../pool-netfs-ns-mountopts-freebsd.argv | 2 ++ .../pool-netfs-ns-mountopts-linux.argv | 2 ++ .../pool-netfs-ns-mountopts.argv | 1 + tests/storagepoolxml2argvtest.c | 6 ++++++ 5 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts-f= reebsd.argv create mode 100644 tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts-l= inux.argv create mode 100644 tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts.a= rgv diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 2e753f4501..1fdaf54059 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -4293,7 +4293,15 @@ virStorageBackendFileSystemMountNFSAddOptions(virCom= mandPtr cmd, virBufferAsprintf(&buf, "nfsvers=3D%u,", def->source.protocolVer); =20 if (*default_nfs_mount_opts !=3D '\0') - virBufferAddLit(&buf, default_nfs_mount_opts); + virBufferAsprintf(&buf, "%s,", default_nfs_mount_opts); + + if (def->namespaceData) { + size_t i; + virStoragePoolNetFSMountOptionsDefPtr opts =3D def->namespaceData; + + for (i =3D 0; i < opts->noptions; i++) + virBufferAsprintf(&buf, "%s,", opts->options[i]); + } =20 virBufferTrim(&buf, ",", -1); mountOpts =3D virBufferContentAndReset(&buf); diff --git a/tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts-freebsd.= argv b/tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts-freebsd.argv new file mode 100644 index 0000000000..d8bd7e378e --- /dev/null +++ b/tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts-freebsd.argv @@ -0,0 +1,2 @@ +mount -t nfs localhost:/var/lib/libvirt/images /mnt -o nfsvers=3D3,nosuid,= noexec,\ +sync,lazytime diff --git a/tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts-linux.ar= gv b/tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts-linux.argv new file mode 100644 index 0000000000..486b2183b7 --- /dev/null +++ b/tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts-linux.argv @@ -0,0 +1,2 @@ +mount -t nfs localhost:/var/lib/libvirt/images /mnt -o nfsvers=3D3,nodev,n= osuid,\ +noexec,sync,lazytime diff --git a/tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts.argv b/t= ests/storagepoolxml2argvdata/pool-netfs-ns-mountopts.argv new file mode 100644 index 0000000000..a63d6da456 --- /dev/null +++ b/tests/storagepoolxml2argvdata/pool-netfs-ns-mountopts.argv @@ -0,0 +1 @@ +mount -t nfs localhost:/var/lib/libvirt/images /mnt -o nfsvers=3D3,sync,la= zytime diff --git a/tests/storagepoolxml2argvtest.c b/tests/storagepoolxml2argvtes= t.c index b6a46280cd..b6bc838f7b 100644 --- a/tests/storagepoolxml2argvtest.c +++ b/tests/storagepoolxml2argvtest.c @@ -162,6 +162,9 @@ mymain(void) #define DO_TEST_FREEBSD(pool, ...) \ DO_TEST_FULL(false, pool, false, true) =20 + if (storageRegisterAll() < 0) + return EXIT_FAILURE; + DO_TEST_FAIL("pool-dir"); DO_TEST_FAIL("pool-dir-naming"); DO_TEST("pool-fs"); @@ -177,14 +180,17 @@ mymain(void) DO_TEST_LINUX("pool-netfs"); DO_TEST_LINUX("pool-netfs-auto"); DO_TEST_LINUX("pool-netfs-protocol-ver"); + DO_TEST_LINUX("pool-netfs-ns-mountopts"); #elif defined(__FreeBSD__) DO_TEST_FREEBSD("pool-netfs"); DO_TEST_FREEBSD("pool-netfs-auto"); DO_TEST_FREEBSD("pool-netfs-protocol-ver"); + DO_TEST_FREEBSD("pool-netfs-ns-mountopts"); #else DO_TEST("pool-netfs"); DO_TEST("pool-netfs-auto"); DO_TEST("pool-netfs-protocol-ver"); + DO_TEST("pool-netfs-ns-mountopts"); #endif DO_TEST("pool-netfs-gluster"); DO_TEST("pool-netfs-cifs"); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 05:12:32 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 1547760187383630.8935245248083; Thu, 17 Jan 2019 13:23:07 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F02192DE439; Thu, 17 Jan 2019 21:23: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 918BC1822B; Thu, 17 Jan 2019 21:23:03 +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 2B0C43F611; Thu, 17 Jan 2019 21:23:03 +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 x0HLMS2k004160 for ; Thu, 17 Jan 2019 16:22:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id 27A4360BE8; Thu, 17 Jan 2019 21:22:28 +0000 (UTC) Received: from unknown0050b6a41c42.attlocal.net.com (ovpn-116-60.phx2.redhat.com [10.3.116.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id C139360BE5 for ; Thu, 17 Jan 2019 21:22:27 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Thu, 17 Jan 2019 16:22:16 -0500 Message-Id: <20190117212216.28316-11-jferlan@redhat.com> In-Reply-To: <20190117212216.28316-1-jferlan@redhat.com> References: <20190117212216.28316-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 v4 10/10] 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 17 Jan 2019 21:23:05 +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 Reviewed-by: Daniel P. Berrang=C3=A9 --- 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 7a5a38de9e..0e2cfae247 100644 --- a/docs/formatstorage.html.in +++ b/docs/formatstorage.html.in @@ -505,7 +505,8 @@ 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. + command line. For the "rbd" pool this provides a mechanism to overri= de + default settings for RBD configuration options.

netfs:mount_opts
@@ -552,6 +553,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 cea4bb474a..8ad95246f4 100644 --- a/docs/schemas/storagepool.rng +++ b/docs/schemas/storagepool.rng @@ -153,6 +153,9 @@ + + + =20 @@ -702,4 +705,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 aff9ff160c..90d00a8d9e 100644 --- a/tests/storagepoolxml2xmltest.c +++ b/tests/storagepoolxml2xmltest.c @@ -106,6 +106,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