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 1548786141402347.71045488461425; Tue, 29 Jan 2019 10:22:21 -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 DE562C0C6C21; Tue, 29 Jan 2019 18:22:15 +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 7203B2C6C0; Tue, 29 Jan 2019 18:22:14 +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 8D147180339A; Tue, 29 Jan 2019 18:22:13 +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 x0TIMC6T001792 for ; Tue, 29 Jan 2019 13:22:12 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1F3342B592; Tue, 29 Jan 2019 18:22:12 +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 BCF7616E31 for ; Tue, 29 Jan 2019 18:22:11 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 29 Jan 2019 13:22:00 -0500 Message-Id: <20190129182208.23788-2-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 1/9] storage: Add default mount options for fs/netfs 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 29 Jan 2019 18:22:18 +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 the fs/netfs storage pools 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 Reviewed-by: Daniel P. Berrang=C3=A9 --- src/storage/storage_util.c | 36 ++++++++++++-- .../pool-fs-freebsd.argv | 1 + .../pool-fs-linux.argv | 1 + .../pool-netfs-auto-freebsd.argv | 1 + .../pool-netfs-auto-linux.argv | 1 + .../pool-netfs-cifs-freebsd.argv | 1 + .../pool-netfs-cifs-linux.argv | 1 + .../pool-netfs-freebsd.argv | 1 + .../pool-netfs-gluster-freebsd.argv | 2 + .../pool-netfs-gluster-linux.argv | 2 + .../pool-netfs-linux.argv | 1 + tests/storagepoolxml2argvtest.c | 48 +++++++++++++++---- 12 files changed, 84 insertions(+), 12 deletions(-) create mode 100644 tests/storagepoolxml2argvdata/pool-fs-freebsd.argv create mode 100644 tests/storagepoolxml2argvdata/pool-fs-linux.argv 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-cifs-freebsd.a= rgv create mode 100644 tests/storagepoolxml2argvdata/pool-netfs-cifs-linux.argv create mode 100644 tests/storagepoolxml2argvdata/pool-netfs-freebsd.argv create mode 100644 tests/storagepoolxml2argvdata/pool-netfs-gluster-freebs= d.argv create mode 100644 tests/storagepoolxml2argvdata/pool-netfs-gluster-linux.= 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..d63237ce8f 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_mount_opts "nodev,nosuid,noexec" +#elif defined(__FreeBSD__) +# define default_mount_opts "nosuid,noexec" +#else +# define default_mount_opts "" #endif =20 #if WITH_BLKID @@ -4261,12 +4266,34 @@ virStorageBackendFileSystemGetPoolSource(virStorage= PoolObjPtr pool) } =20 =20 +static void +virStorageBackendFileSystemMountAddOptions(virCommandPtr cmd, + const char *providedOpts) +{ + VIR_AUTOFREE(char *) mountOpts =3D NULL; + virBuffer buf =3D VIR_BUFFER_INITIALIZER; + + if (*default_mount_opts !=3D '\0') + virBufferAsprintf(&buf, "%s,", default_mount_opts); + + if (providedOpts) + virBufferAsprintf(&buf, "%s,", providedOpts); + + virBufferTrim(&buf, ",", -1); + mountOpts =3D virBufferContentAndReset(&buf); + + if (mountOpts) + virCommandAddArgList(cmd, "-o", mountOpts, NULL); +} + + static void virStorageBackendFileSystemMountNFSArgs(virCommandPtr cmd, const char *src, virStoragePoolDefPtr def) { virCommandAddArgList(cmd, src, def->target.path, NULL); + virStorageBackendFileSystemMountAddOptions(cmd, NULL); } =20 =20 @@ -4278,8 +4305,8 @@ virStorageBackendFileSystemMountGlusterArgs(virComman= dPtr cmd, const char *fmt; =20 fmt =3D virStoragePoolFormatFileSystemNetTypeToString(def->source.form= at); - virCommandAddArgList(cmd, "-t", fmt, src, "-o", "direct-io-mode=3D1", - def->target.path, NULL); + virCommandAddArgList(cmd, "-t", fmt, src, def->target.path, NULL); + virStorageBackendFileSystemMountAddOptions(cmd, "direct-io-mode=3D1"); } =20 =20 @@ -4291,8 +4318,8 @@ virStorageBackendFileSystemMountCIFSArgs(virCommandPt= r cmd, const char *fmt; =20 fmt =3D virStoragePoolFormatFileSystemNetTypeToString(def->source.form= at); - virCommandAddArgList(cmd, "-t", fmt, src, def->target.path, - "-o", "guest", NULL); + virCommandAddArgList(cmd, "-t", fmt, src, def->target.path, NULL); + virStorageBackendFileSystemMountAddOptions(cmd, "guest"); } =20 =20 @@ -4308,6 +4335,7 @@ virStorageBackendFileSystemMountDefaultArgs(virComman= dPtr cmd, else fmt =3D virStoragePoolFormatFileSystemNetTypeToString(def->source.= format); virCommandAddArgList(cmd, "-t", fmt, src, def->target.path, NULL); + virStorageBackendFileSystemMountAddOptions(cmd, NULL); } =20 =20 diff --git a/tests/storagepoolxml2argvdata/pool-fs-freebsd.argv b/tests/sto= ragepoolxml2argvdata/pool-fs-freebsd.argv new file mode 100644 index 0000000000..a35d73e254 --- /dev/null +++ b/tests/storagepoolxml2argvdata/pool-fs-freebsd.argv @@ -0,0 +1 @@ +mount -t ext3 /dev/sda6 /mnt -o nosuid,noexec diff --git a/tests/storagepoolxml2argvdata/pool-fs-linux.argv b/tests/stora= gepoolxml2argvdata/pool-fs-linux.argv new file mode 100644 index 0000000000..19543f442d --- /dev/null +++ b/tests/storagepoolxml2argvdata/pool-fs-linux.argv @@ -0,0 +1 @@ +mount -t ext3 /dev/sda6 /mnt -o nodev,nosuid,noexec 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-cifs-freebsd.argv b/t= ests/storagepoolxml2argvdata/pool-netfs-cifs-freebsd.argv new file mode 100644 index 0000000000..d72749a032 --- /dev/null +++ b/tests/storagepoolxml2argvdata/pool-netfs-cifs-freebsd.argv @@ -0,0 +1 @@ +mount -t cifs //example.com/samba_share /mnt/cifs -o nosuid,noexec,guest diff --git a/tests/storagepoolxml2argvdata/pool-netfs-cifs-linux.argv b/tes= ts/storagepoolxml2argvdata/pool-netfs-cifs-linux.argv new file mode 100644 index 0000000000..85aa9cf23f --- /dev/null +++ b/tests/storagepoolxml2argvdata/pool-netfs-cifs-linux.argv @@ -0,0 +1 @@ +mount -t cifs //example.com/samba_share /mnt/cifs -o nodev,nosuid,noexec,g= uest 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-gluster-freebsd.argv = b/tests/storagepoolxml2argvdata/pool-netfs-gluster-freebsd.argv new file mode 100644 index 0000000000..700107d78e --- /dev/null +++ b/tests/storagepoolxml2argvdata/pool-netfs-gluster-freebsd.argv @@ -0,0 +1,2 @@ +mount -t glusterfs example.com:/volume /mnt/gluster -o nosuid,noexec,\ +direct-io-mode=3D1 diff --git a/tests/storagepoolxml2argvdata/pool-netfs-gluster-linux.argv b/= tests/storagepoolxml2argvdata/pool-netfs-gluster-linux.argv new file mode 100644 index 0000000000..9535c8a1b9 --- /dev/null +++ b/tests/storagepoolxml2argvdata/pool-netfs-gluster-linux.argv @@ -0,0 +1,2 @@ +mount -t glusterfs example.com:/volume /mnt/gluster -o nodev,nosuid,noexec= ,\ +direct-io-mode=3D1 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..0331d3497b 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,14 +151,19 @@ 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"); - DO_TEST("pool-fs"); DO_TEST("pool-logical"); DO_TEST("pool-logical-nopath"); DO_TEST("pool-logical-create"); @@ -155,10 +172,25 @@ 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-fs"); + DO_TEST_LINUX("pool-netfs"); + DO_TEST_LINUX("pool-netfs-auto"); + 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-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-gluster"); DO_TEST("pool-netfs-cifs"); +#endif DO_TEST_FAIL("pool-scsi"); DO_TEST_FAIL("pool-scsi-type-scsi-host"); DO_TEST_FAIL("pool-scsi-type-fc-host"); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody 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 1548786151549407.6834776629951; Tue, 29 Jan 2019 10: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 2AFC0804F1; Tue, 29 Jan 2019 18:22:27 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AEE9D5D985; Tue, 29 Jan 2019 18:22:26 +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 5A29418033A2; Tue, 29 Jan 2019 18:22:26 +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 x0TIMCeF001845 for ; Tue, 29 Jan 2019 13:22:12 -0500 Received: by smtp.corp.redhat.com (Postfix) id A24E12B592; Tue, 29 Jan 2019 18:22:12 +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 49F4D2DE8E; Tue, 29 Jan 2019 18:22:12 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 29 Jan 2019 13:22:01 -0500 Message-Id: <20190129182208.23788-3-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 2/9] docs: Add news mention of default fs/netfs 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-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.27]); Tue, 29 Jan 2019 18:22:29 +0000 (UTC) Signed-off-by: John Ferlan Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/news.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/news.xml b/docs/news.xml index 5759a9e178..2aa4ed25d6 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -50,6 +50,17 @@
+ + + storage: Add default mount options for fs/netfs storage pools + + + Altered the command line generation for fs/netfs 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 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 1548786152617267.44576189513873; Tue, 29 Jan 2019 10:22:32 -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 216C6445C9; Tue, 29 Jan 2019 18: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 9FB6A16E25; Tue, 29 Jan 2019 18:22:26 +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 45CFB18033A4; Tue, 29 Jan 2019 18:22:26 +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 x0TIMDR8001936 for ; Tue, 29 Jan 2019 13:22:13 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2FD7B2B585; 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 CDDE819745; Tue, 29 Jan 2019 18:22:12 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 29 Jan 2019 13:22:02 -0500 Message-Id: <20190129182208.23788-4-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 3/9] 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-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.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.30]); Tue, 29 Jan 2019 18:22:29 +0000 (UTC) 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 be4aa26105..85107c85ae 100644 --- a/docs/formatstorage.html.in +++ b/docs/formatstorage.html.in @@ -122,6 +122,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 @@ -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

=20 +

Storage Pool Namespaces

+ +

+ 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: + +

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

+ +

+ 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: +
+<pool type=3D"netfs" xmlns:fs=3D'http://libvirt.org/schemas/storagepool=
/source/fs/1.0'>
+  <name>nfsimages</name>
+...
+  <source>
+...
+  </source>
+...
+  <target>
+...
+  </target>
+  <fs:mount_opts>
+    <fs:option name=3D'sync'/>
+    <fs:option name=3D'lazytime'/>
+  </fs: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..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: + +

+ 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 0b359669af..e1944ff8e1 100644 --- a/docs/schemas/storagepool.rng +++ b/docs/schemas/storagepool.rng @@ -156,6 +156,9 @@ + + + =20 @@ -705,4 +708,24 @@ =20 + + + + + + + + + + + + + + + + + diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backen= d_rbd.c index 24dd1349ae..2348f80146 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,138 @@ struct _virStorageBackendRBDState { typedef struct _virStorageBackendRBDState virStorageBackendRBDState; typedef virStorageBackendRBDState *virStorageBackendRBDStatePtr; =20 +typedef struct _virStoragePoolRBDConfigOptionsDef virStoragePoolRBDConfigO= ptionsDef; +typedef virStoragePoolRBDConfigOptionsDef *virStoragePoolRBDConfigOptionsD= efPtr; +struct _virStoragePoolRBDConfigOptionsDef { + 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) +{ + virStoragePoolRBDConfigOptionsDefPtr 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) +{ + virStoragePoolRBDConfigOptionsDefPtr 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; + virStoragePoolRBDConfigOptionsDefPtr 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 +202,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 +317,22 @@ virStorageBackendRBDOpenRADOSConn(virStorageBackendRBD= StatePtr ptr, rbd_default_format) < 0) goto cleanup; =20 + if (def->namespaceData) { + virStoragePoolRBDConfigOptionsDefPtr cmdopts =3D def->namespaceDat= a; + char uuidstr[VIR_UUID_STRING_BUFLEN]; + + for (i =3D 0; i < cmdopts->noptions; i++) { + if (virStorageBackendRBDRADOSConfSet(ptr->cluster, + cmdopts->names[i], + cmdopts->values[i]) < 0) + goto cleanup; + } + + virUUIDFormat(def->uuid, uuidstr); + VIR_WARN("Storage Pool name=3D'%s' uuid=3D'%s' is tainted by custo= m " + "config_opts from XML", def->name, uuidstr); + } + 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 +406,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 +1427,7 @@ virStorageBackendRBDVolWipe(virStoragePoolObjPtr pool, return ret; } =20 + virStorageBackend virStorageBackendRBD =3D { .type =3D VIR_STORAGE_POOL_RBD, =20 @@ -1291,8 +1442,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