Provides the source for pools backed by physical devices
@@ -397,6 +407,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 ba5b1f1783..bb666af3ec 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
@@ -961,6 +980,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 Sun May 5 10:58:58 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 1548786142240209.8184519612389;
Tue, 29 Jan 2019 10:22:22 -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 A0FFCC087321;
Tue, 29 Jan 2019 18:22: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 4762B18E33;
Tue, 29 Jan 2019 18:22:17 +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 BA15B3F604;
Tue, 29 Jan 2019 18:22:16 +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 x0TIMDvc001959 for ;
Tue, 29 Jan 2019 13:22:13 -0500
Received: by smtp.corp.redhat.com (Postfix)
id 9EA8919745; Tue, 29 Jan 2019 18:22:13 +0000 (UTC)
Received: from unknown0050b6a41c42.attlocal.net.com
(ovpn-116-45.phx2.redhat.com [10.3.116.45])
by smtp.corp.redhat.com (Postfix) with ESMTP id 5C06817B36
for ; Tue, 29 Jan 2019 18:22:13 +0000 (UTC)
From: John Ferlan
To: libvir-list@redhat.com
Date: Tue, 29 Jan 2019 13:22:03 -0500
Message-Id: <20190129182208.23788-5-jferlan@redhat.com>
In-Reply-To: <20190129182208.23788-1-jferlan@redhat.com>
References: <20190129182208.23788-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 v5 4/9] 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.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.31]);
Tue, 29 Jan 2019 18:22:19 +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 | 19 +++++++++++++------
.../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, 20 insertions(+), 6 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 d63237ce8f..a5cb47b4d0 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -4290,10 +4290,11 @@ virStorageBackendFileSystemMountAddOptions(virComma=
ndPtr cmd,
static void
virStorageBackendFileSystemMountNFSArgs(virCommandPtr cmd,
const char *src,
- virStoragePoolDefPtr def)
+ virStoragePoolDefPtr def,
+ const char *nfsVers)
{
virCommandAddArgList(cmd, src, def->target.path, NULL);
- virStorageBackendFileSystemMountAddOptions(cmd, NULL);
+ virStorageBackendFileSystemMountAddOptions(cmd, nfsVers);
}
=20
=20
@@ -4326,7 +4327,8 @@ virStorageBackendFileSystemMountCIFSArgs(virCommandPt=
r cmd,
static void
virStorageBackendFileSystemMountDefaultArgs(virCommandPtr cmd,
const char *src,
- virStoragePoolDefPtr def)
+ virStoragePoolDefPtr def,
+ const char *nfsVers)
{
const char *fmt;
=20
@@ -4335,7 +4337,7 @@ virStorageBackendFileSystemMountDefaultArgs(virComman=
dPtr cmd,
else
fmt =3D virStoragePoolFormatFileSystemNetTypeToString(def->source.=
format);
virCommandAddArgList(cmd, "-t", fmt, src, def->target.path, NULL);
- virStorageBackendFileSystemMountAddOptions(cmd, NULL);
+ virStorageBackendFileSystemMountAddOptions(cmd, nfsVers);
}
=20
=20
@@ -4354,16 +4356,21 @@ virStorageBackendFileSystemMountCmd(const char *cmd=
str,
bool cifsfs =3D (def->type =3D=3D VIR_STORAGE_POOL_NETFS &&
def->source.format =3D=3D VIR_STORAGE_POOL_NETFS_CIFS);
virCommandPtr cmd =3D NULL;
+ VIR_AUTOFREE(char *) nfsVers =3D NULL;
+
+ if (def->type =3D=3D VIR_STORAGE_POOL_NETFS && def->source.protocolVer=
> 0 &&
+ virAsprintf(&nfsVers, "nfsvers=3D%u", def->source.protocolVer) < 0)
+ return NULL;
=20
cmd =3D virCommandNew(cmdstr);
if (netauto)
- virStorageBackendFileSystemMountNFSArgs(cmd, src, def);
+ virStorageBackendFileSystemMountNFSArgs(cmd, src, def, nfsVers);
else if (glusterfs)
virStorageBackendFileSystemMountGlusterArgs(cmd, src, def);
else if (cifsfs)
virStorageBackendFileSystemMountCIFSArgs(cmd, src, def);
else
- virStorageBackendFileSystemMountDefaultArgs(cmd, src, def);
+ virStorageBackendFileSystemMountDefaultArgs(cmd, src, def, nfsVers=
);
return cmd;
}
=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..59d09d2e5d
--- /dev/null
+++ b/tests/storagepoolxml2argvdata/pool-netfs-protocol-ver-freebsd.argv
@@ -0,0 +1 @@
+mount -t nfs localhost:/var/lib/libvirt/images /mnt -o nosuid,noexec,nfsve=
rs=3D3
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..c819a089d2
--- /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 nodev,nosuid,noexec=
,\
+nfsvers=3D3
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 0331d3497b..88059cbdfc 100644
--- a/tests/storagepoolxml2argvtest.c
+++ b/tests/storagepoolxml2argvtest.c
@@ -176,18 +176,21 @@ mymain(void)
DO_TEST_LINUX("pool-fs");
DO_TEST_LINUX("pool-netfs");
DO_TEST_LINUX("pool-netfs-auto");
+ DO_TEST_LINUX("pool-netfs-protocol-ver");
DO_TEST_LINUX("pool-netfs-gluster");
DO_TEST_LINUX("pool-netfs-cifs");
#elif defined(__FreeBSD__)
DO_TEST_FREEBSD("pool-fs");
DO_TEST_FREEBSD("pool-netfs");
DO_TEST_FREEBSD("pool-netfs-auto");
+ DO_TEST_FREEBSD("pool-netfs-protocol-ver");
DO_TEST_FREEBSD("pool-netfs-gluster");
DO_TEST_FREEBSD("pool-netfs-cifs");
#else
DO_TEST("pool-fs");
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");
#endif
--=20
2.20.1
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Sun May 5 10:58:58 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 1548786156747982.5247069604626;
Tue, 29 Jan 2019 10:22:36 -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 8E17512F91A;
Tue, 29 Jan 2019 18:22:32 +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 4814393E83;
Tue, 29 Jan 2019 18:22:32 +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 D820A3F605;
Tue, 29 Jan 2019 18:22:31 +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 x0TIME8F002010 for ;
Tue, 29 Jan 2019 13:22:14 -0500
Received: by smtp.corp.redhat.com (Postfix)
id 2D8D819745; Tue, 29 Jan 2019 18:22:14 +0000 (UTC)
Received: from unknown0050b6a41c42.attlocal.net.com
(ovpn-116-45.phx2.redhat.com [10.3.116.45])
by smtp.corp.redhat.com (Postfix) with ESMTP id C8DBB2B585;
Tue, 29 Jan 2019 18:22:13 +0000 (UTC)
From: John Ferlan
To: libvir-list@redhat.com
Date: Tue, 29 Jan 2019 13:22:04 -0500
Message-Id: <20190129182208.23788-6-jferlan@redhat.com>
In-Reply-To: <20190129182208.23788-1-jferlan@redhat.com>
References: <20190129182208.23788-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 v5 5/9] 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-Type: text/plain; charset="utf-8"
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.38]);
Tue, 29 Jan 2019 18:22:33 +0000 (UTC)
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 Sun May 5 10:58:58 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 1548786156852735.3896632037894;
Tue, 29 Jan 2019 10:22:36 -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 3C626C0A1B1F;
Tue, 29 Jan 2019 18:22:33 +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 1FCD25D985;
Tue, 29 Jan 2019 18:22:32 +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 BFEDB18033A6;
Tue, 29 Jan 2019 18:22:31 +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 x0TIMECD002116 for ;
Tue, 29 Jan 2019 13:22:14 -0500
Received: by smtp.corp.redhat.com (Postfix)
id B136916E31; Tue, 29 Jan 2019 18:22:14 +0000 (UTC)
Received: from unknown0050b6a41c42.attlocal.net.com
(ovpn-116-45.phx2.redhat.com [10.3.116.45])
by smtp.corp.redhat.com (Postfix) with ESMTP id 574B916E25;
Tue, 29 Jan 2019 18:22:14 +0000 (UTC)
From: John Ferlan
To: libvir-list@redhat.com
Date: Tue, 29 Jan 2019 13:22:05 -0500
Message-Id: <20190129182208.23788-7-jferlan@redhat.com>
In-Reply-To: <20190129182208.23788-1-jferlan@redhat.com>
References: <20190129182208.23788-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 v5 6/9] 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-Type: text/plain; charset="utf-8"
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.31]);
Tue, 29 Jan 2019 18:22:34 +0000 (UTC)
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 bb666af3ec..7b9f429cba 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
@@ -834,6 +867,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);
@@ -1010,7 +1050,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
@@ -1063,6 +1106,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 e53ae0dbeb..be52eaedb7 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -921,6 +921,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 Sun May 5 10:58:58 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 15487861605031015.2776217799557;
Tue, 29 Jan 2019 10:22:40 -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 3C82023E6F4;
Tue, 29 Jan 2019 18:22:37 +0000 (UTC)
Received: from colo-mx.corp.redhat.com
(colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21])
by smtp.corp.redhat.com (Postfix) with ESMTPS id D781C112C1B1;
Tue, 29 Jan 2019 18:22:36 +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 848943F608;
Tue, 29 Jan 2019 18:22:36 +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 x0TIMF7S002136 for ;
Tue, 29 Jan 2019 13:22:15 -0500
Received: by smtp.corp.redhat.com (Postfix)
id 40C3B28D28; Tue, 29 Jan 2019 18:22:15 +0000 (UTC)
Received: from unknown0050b6a41c42.attlocal.net.com
(ovpn-116-45.phx2.redhat.com [10.3.116.45])
by smtp.corp.redhat.com (Postfix) with ESMTP id DCB4B177AB
for ; Tue, 29 Jan 2019 18:22:14 +0000 (UTC)
From: John Ferlan
To: libvir-list@redhat.com
Date: Tue, 29 Jan 2019 13:22:06 -0500
Message-Id: <20190129182208.23788-8-jferlan@redhat.com>
In-Reply-To: <20190129182208.23788-1-jferlan@redhat.com>
References: <20190129182208.23788-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 v5 7/9] storage: 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.22
X-Greylist: Sender IP whitelisted,
not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]);
Tue, 29 Jan 2019 18:22:38 +0000 (UTC)
Content-Type: text/plain; charset="utf-8"
Introduce the virStoragePoolFSMountOptionsDef to be used to
manage the Storage Pool XML Namespace for mount options.
Using a new virStorageBackendNamespaceInit function, set the
virStoragePoolXMLNamespace into the _virStoragePoolOptions when
the storage backend is loaded.
Modify the storagepool.rng to allow for the usage of a different
XML namespace to parse the fs_mount_opts to be included with
the fs and netfs storage pool definitions.
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
Reviewed-by: Daniel P. Berrang=C3=A9
---
docs/formatstorage.html.in | 63 +++++++++
docs/schemas/storagepool.rng | 23 +++
src/storage/storage_backend_fs.c | 132 ++++++++++++++++++
src/storage/storage_util.c | 16 +++
src/storage/storage_util.h | 14 ++
tests/Makefile.am | 4 +-
.../pool-netfs-ns-mountopts.xml | 25 ++++
.../pool-netfs-ns-mountopts.xml | 25 ++++
tests/storagepoolxml2xmltest.c | 6 +
9 files changed, 307 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 85107c85ae..7a79ec82d8 100644
--- a/docs/formatstorage.html.in
+++ b/docs/formatstorage.html.in
@@ -508,6 +508,69 @@
device, measured in bytes. Since 0.4.1
+ Usage of Storage Pool Namespaces provides a mechanism to provide
+ pool type specific data in a free form or arbitrary manner via
+ XML syntax targeted solely for the needs of the specific pool type
+ which is not otherwise supported in standard XML. For the "fs" and
+ "netfs" pool types this provides a mechanism to provide additional
+ mount options on the command line.
+
+
+ Usage of namespaces comes with no support guarantees. It is intended
+ for developers testing out a concept prior to requesting an explicit=
ly
+ supported XML option in libvirt, and thus should never be used in
+ production.
+
+
+
fs:mount_opts
+
Provides an XML namespace mechanism to optionally utilize
+ specifically named options for the mount command via the "-o"
+ option for the fs or 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:
+
+
+ The fs:mount_opts defines the mount options by
+ specifying multiple fs: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 for a netfs pool:
+
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..0b359669af 100644
--- a/docs/schemas/storagepool.rng
+++ b/docs/schemas/storagepool.rng
@@ -52,6 +52,9 @@
+
+
+
=20
@@ -64,6 +67,9 @@
+
+
+
=20
@@ -682,4 +688,21 @@
=20
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend=
_fs.c
index dc9869417e..0ec99c60ed 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_FS_NAMESPACE_HREF "http://libvirt.org/schemas/storag=
epool/source/fs/1.0"
+
+/* Backend XML Namespace handling for fs or netfs specific mount options to
+ * be added to the mount -o {options_list} command line that are not other=
wise
+ * supplied by supported XML. The XML will use the format, such as:
+ *
+ *
+ *
+ *
+ *
+ *
+ * and the or is required to have=
a
+ * "xmlns:fs=3D'%s'" attribute using the STORAGE_POOL_FS_NAMESPACE_HREF
+ */
+
+static void
+virStoragePoolDefFSNamespaceFree(void *nsdata)
+{
+ virStoragePoolFSMountOptionsDefPtr 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
+virStoragePoolDefFSNamespaceParse(xmlXPathContextPtr ctxt,
+ void **data)
+{
+ virStoragePoolFSMountOptionsDefPtr cmdopts =3D NULL;
+ xmlNodePtr *nodes =3D NULL;
+ int nnodes;
+ size_t i;
+ int ret =3D -1;
+
+ if (xmlXPathRegisterNs(ctxt, BAD_CAST "fs",
+ BAD_CAST STORAGE_POOL_FS_NAMESPACE_HREF) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to register xml namespace '%s'"),
+ STORAGE_POOL_FS_NAMESPACE_HREF);
+ return -1;
+ }
+
+ nnodes =3D virXPathNodeSet("./fs:mount_opts/fs:option", ctxt, &nodes);
+ 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 fs mount option name specified"));
+ goto cleanup;
+ }
+ cmdopts->noptions++;
+ }
+
+ VIR_STEAL_PTR(*data, cmdopts);
+ ret =3D 0;
+
+ cleanup:
+ VIR_FREE(nodes);
+ virStoragePoolDefFSNamespaceFree(cmdopts);
+ return ret;
+}
+
+
+static int
+virStoragePoolDefFSNamespaceFormatXML(virBufferPtr buf,
+ void *nsdata)
+{
+ size_t i;
+ virStoragePoolFSMountOptionsDefPtr 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 *
+virStoragePoolDefFSNamespaceHref(void)
+{
+ return "xmlns:fs=3D'" STORAGE_POOL_FS_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 virStoragePoolFSXMLNamespace =3D {
+ .parse =3D virStoragePoolDefFSNamespaceParse,
+ .free =3D virStoragePoolDefFSNamespaceFree,
+ .format =3D virStoragePoolDefFSNamespaceFormatXML,
+ .href =3D virStoragePoolDefFSNamespaceHref,
+};
#endif /* WITH_STORAGE_FS */
=20
=20
@@ -630,8 +754,16 @@ virStorageBackendFsRegister(void)
if (virStorageBackendRegister(&virStorageBackendFileSystem) < 0)
return -1;
=20
+ if (virStorageBackendNamespaceInit(VIR_STORAGE_POOL_FS,
+ &virStoragePoolFSXMLNamespace) < 0)
+ return -1;
+
if (virStorageBackendRegister(&virStorageBackendNetFileSystem) < 0)
return -1;
+
+ if (virStorageBackendNamespaceInit(VIR_STORAGE_POOL_NETFS,
+ &virStoragePoolFSXMLNamespace) < 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 a5cb47b4d0..4596cd4518 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..8b44b54a3b 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
+/* Storage Pool Namespace options to share w/ storage_backend_fs.c and
+ * the virStorageBackendFileSystemMountCmd method */
+typedef struct _virStoragePoolFSMountOptionsDef virStoragePoolFSMountOptio=
nsDef;
+typedef virStoragePoolFSMountOptionsDef *virStoragePoolFSMountOptionsDefPt=
r;
+struct _virStoragePoolFSMountOptionsDef {
+ size_t noptions;
+ char **options;
+};
+
+int
+virStorageBackendNamespaceInit(int poolType,
+ virStoragePoolXMLNamespacePtr xmlns);
+
+
/* File creation/cloning functions used for cloning between backends */
=20
int
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..0434b16eb7
--- /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..4bd164f220
--- /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 Sun May 5 10:58:58 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 1548786167049283.68748236121553;
Tue, 29 Jan 2019 10:22:47 -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 C547874EEC;
Tue, 29 Jan 2019 18:22:41 +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 8194717C30;
Tue, 29 Jan 2019 18:22:41 +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 339E618033EC;
Tue, 29 Jan 2019 18:22:41 +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 x0TIMFxY002145 for ;
Tue, 29 Jan 2019 13:22:15 -0500
Received: by smtp.corp.redhat.com (Postfix)
id BB1A32E167; Tue, 29 Jan 2019 18:22:15 +0000 (UTC)
Received: from unknown0050b6a41c42.attlocal.net.com
(ovpn-116-45.phx2.redhat.com [10.3.116.45])
by smtp.corp.redhat.com (Postfix) with ESMTP id 6BE6F177AB
for ; Tue, 29 Jan 2019 18:22:15 +0000 (UTC)
From: John Ferlan
To: libvir-list@redhat.com
Date: Tue, 29 Jan 2019 13:22:07 -0500
Message-Id: <20190129182208.23788-9-jferlan@redhat.com>
In-Reply-To: <20190129182208.23788-1-jferlan@redhat.com>
References: <20190129182208.23788-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 v5 8/9] storage: Add storage pool namespace
options to fs and netfs command lines
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.39]);
Tue, 29 Jan 2019 18:22:43 +0000 (UTC)
Content-Type: text/plain; charset="utf-8"
If the Storage Pool Namespace XML data exists, format the mount
options on the MOUNT command line and issue a VIR_WARN to indicate
that the storage pool was tainted by custom mount_opts.
When the pool is started, the options will be generated on the
command line along with the options already defined.
Signed-off-by: John Ferlan
Reviewed-by: Daniel P. Berrang=C3=A9
---
src/storage/storage_util.c | 22 +++++++++++++++----
.../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, 29 insertions(+), 4 deletions(-)
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 4596cd4518..37b3d58667 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -4284,6 +4284,7 @@ virStorageBackendFileSystemGetPoolSource(virStoragePo=
olObjPtr pool)
=20
static void
virStorageBackendFileSystemMountAddOptions(virCommandPtr cmd,
+ virStoragePoolDefPtr def,
const char *providedOpts)
{
VIR_AUTOFREE(char *) mountOpts =3D NULL;
@@ -4295,6 +4296,19 @@ virStorageBackendFileSystemMountAddOptions(virComman=
dPtr cmd,
if (providedOpts)
virBufferAsprintf(&buf, "%s,", providedOpts);
=20
+ if (def->namespaceData) {
+ size_t i;
+ virStoragePoolFSMountOptionsDefPtr opts =3D def->namespaceData;
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+
+ for (i =3D 0; i < opts->noptions; i++)
+ virBufferAsprintf(&buf, "%s,", opts->options[i]);
+
+ virUUIDFormat(def->uuid, uuidstr);
+ VIR_WARN("Storage Pool name=3D'%s' uuid=3D'%s' is tainted by custo=
m "
+ "mount_opts from XML", def->name, uuidstr);
+ }
+
virBufferTrim(&buf, ",", -1);
mountOpts =3D virBufferContentAndReset(&buf);
=20
@@ -4310,7 +4324,7 @@ virStorageBackendFileSystemMountNFSArgs(virCommandPtr=
cmd,
const char *nfsVers)
{
virCommandAddArgList(cmd, src, def->target.path, NULL);
- virStorageBackendFileSystemMountAddOptions(cmd, nfsVers);
+ virStorageBackendFileSystemMountAddOptions(cmd, def, nfsVers);
}
=20
=20
@@ -4323,7 +4337,7 @@ virStorageBackendFileSystemMountGlusterArgs(virComman=
dPtr cmd,
=20
fmt =3D virStoragePoolFormatFileSystemNetTypeToString(def->source.form=
at);
virCommandAddArgList(cmd, "-t", fmt, src, def->target.path, NULL);
- virStorageBackendFileSystemMountAddOptions(cmd, "direct-io-mode=3D1");
+ virStorageBackendFileSystemMountAddOptions(cmd, def, "direct-io-mode=
=3D1");
}
=20
=20
@@ -4336,7 +4350,7 @@ virStorageBackendFileSystemMountCIFSArgs(virCommandPt=
r cmd,
=20
fmt =3D virStoragePoolFormatFileSystemNetTypeToString(def->source.form=
at);
virCommandAddArgList(cmd, "-t", fmt, src, def->target.path, NULL);
- virStorageBackendFileSystemMountAddOptions(cmd, "guest");
+ virStorageBackendFileSystemMountAddOptions(cmd, def, "guest");
}
=20
=20
@@ -4353,7 +4367,7 @@ virStorageBackendFileSystemMountDefaultArgs(virComman=
dPtr cmd,
else
fmt =3D virStoragePoolFormatFileSystemNetTypeToString(def->source.=
format);
virCommandAddArgList(cmd, "-t", fmt, src, def->target.path, NULL);
- virStorageBackendFileSystemMountAddOptions(cmd, nfsVers);
+ virStorageBackendFileSystemMountAddOptions(cmd, def, nfsVers);
}
=20
=20
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..ac5c0acd00
--- /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 nosuid,noexec,nfsve=
rs=3D3,\
+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..8e10379c04
--- /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 nodev,nosuid,noexec=
,\
+nfsvers=3D3,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 88059cbdfc..786fb26402 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-logical");
@@ -177,6 +180,7 @@ 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");
DO_TEST_LINUX("pool-netfs-gluster");
DO_TEST_LINUX("pool-netfs-cifs");
#elif defined(__FreeBSD__)
@@ -184,6 +188,7 @@ mymain(void)
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");
DO_TEST_FREEBSD("pool-netfs-gluster");
DO_TEST_FREEBSD("pool-netfs-cifs");
#else
@@ -191,6 +196,7 @@ mymain(void)
DO_TEST("pool-netfs");
DO_TEST("pool-netfs-auto");
DO_TEST("pool-netfs-protocol-ver");
+ DO_TEST("pool-netfs-ns-mountopts");
DO_TEST("pool-netfs-gluster");
DO_TEST("pool-netfs-cifs");
#endif
--=20
2.20.1
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
From nobody Sun May 5 10:58:58 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 154878616199719.397899914663753;
Tue, 29 Jan 2019 10:22:41 -0800 (PST)
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
[10.5.11.12])
(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
(No client certificate requested)
by mx1.redhat.com (Postfix) with ESMTPS id 17FB319D39B;
Tue, 29 Jan 2019 18:22:40 +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 C3E7C84EF;
Tue, 29 Jan 2019 18:22: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 6608818033CB;
Tue, 29 Jan 2019 18:22:39 +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 x0TIMGD1002159 for ;
Tue, 29 Jan 2019 13:22:16 -0500
Received: by smtp.corp.redhat.com (Postfix)
id 323B019745; Tue, 29 Jan 2019 18:22:16 +0000 (UTC)
Received: from unknown0050b6a41c42.attlocal.net.com
(ovpn-116-45.phx2.redhat.com [10.3.116.45])
by smtp.corp.redhat.com (Postfix) with ESMTP id DD7F116E25
for ; Tue, 29 Jan 2019 18:22:15 +0000 (UTC)
From: John Ferlan
To: libvir-list@redhat.com
Date: Tue, 29 Jan 2019 13:22:08 -0500
Message-Id: <20190129182208.23788-10-jferlan@redhat.com>
In-Reply-To: <20190129182208.23788-1-jferlan@redhat.com>
References: <20190129182208.23788-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 v5 9/9] 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.12
X-Greylist: Sender IP whitelisted,
not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]);
Tue, 29 Jan 2019 18:22:40 +0000 (UTC)
Content-Type: text/plain; charset="utf-8"
Allow for adjustment of RBD configuration options via Storage
Pool XML Namespace adjustments. When namespace arguments are
used to start the pool, add a VIR_WARN to indicate that the
startup was tainted by custom config_opts.
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 | 169 +++++++++++++++++-
.../pool-rbd-ns-configopts.xml | 17 ++
.../pool-rbd-ns-configopts.xml | 20 +++
tests/storagepoolxml2xmltest.c | 1 +
6 files changed, 278 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 7a79ec82d8..d19bc579a4 100644
--- a/docs/formatstorage.html.in
+++ b/docs/formatstorage.html.in
@@ -516,7 +516,8 @@
XML syntax targeted solely for the needs of the specific pool type
which is not otherwise supported in standard XML. For the "fs" and
"netfs" pool types this provides a mechanism to provide additional
- mount options on the command line.
+ mount options on the command line. For the "rbd" pool this provides
+ a mechanism to override default settings for RBD configuration optio=
ns.
Usage of namespaces comes with no support guarantees. It is intended
@@ -569,6 +570,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:
+
+
+ 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
+