From nobody Mon Apr 29 10:15:52 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.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1491308516708971.5950439227112; Tue, 4 Apr 2017 05:21:56 -0700 (PDT) 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 0FFBFC00108F; Tue, 4 Apr 2017 12:21:55 +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 D56CF96295; Tue, 4 Apr 2017 12:21:54 +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 83D1F18521C8; Tue, 4 Apr 2017 12:21:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v34CK6BN007098 for ; Tue, 4 Apr 2017 08:20:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8450D8473F; Tue, 4 Apr 2017 12:20:06 +0000 (UTC) Received: from angien.brq.redhat.com (dhcp129-47.brq.redhat.com [10.34.129.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5493186169; Tue, 4 Apr 2017 12:20:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0FFBFC00108F Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0FFBFC00108F From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 4 Apr 2017 14:20:55 +0200 Message-Id: <97e73245198bbe503e5bc3ef9eda7c4041c7759e.1491308364.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa , abologna@redhat.com Subject: [libvirt] [PATCH v3 1/5] storage: util: Pass pool type to virStorageBackendFindGlusterPoolSources 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 04 Apr 2017 12:21:55 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The native gluster pool source list data differs from the data used for attaching gluster volumes as netfs pools. Currently the only difference was the format. Since native pools don't use it and later there will be more differences add a more deterministic way to switch between the types instead. --- src/storage/storage_backend_fs.c | 2 +- src/storage/storage_backend_gluster.c | 2 +- src/storage/storage_util.c | 13 +++++++++---- src/storage/storage_util.h | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend= _fs.c index 1fc127a8c..bf1d7de43 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -186,7 +186,7 @@ virStorageBackendFileSystemNetFindPoolSources(virConnec= tPtr conn ATTRIBUTE_UNUSE retNFS =3D virStorageBackendFileSystemNetFindNFSPoolSources(&state); retGluster =3D virStorageBackendFindGlusterPoolSources(state.host, - VIR_STORAGE_POOL_= NETFS_GLUSTERFS, + VIR_STORAGE_POOL_= NETFS, &state.list, fals= e); if (retGluster < 0) diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_ba= ckend_gluster.c index 52c9ee372..30a41369a 100644 --- a/src/storage/storage_backend_gluster.c +++ b/src/storage/storage_backend_gluster.c @@ -513,7 +513,7 @@ virStorageBackendGlusterFindPoolSources(virConnectPtr c= onn ATTRIBUTE_UNUSED, } if ((rc =3D virStorageBackendFindGlusterPoolSources(source->hosts[0].n= ame, - 0, /* currently igno= red */ + VIR_STORAGE_POOL_GLU= STER, &list, true)) < 0) goto cleanup; diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 0ceaab6b9..715361923 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -2839,17 +2839,21 @@ virStorageBackendDeleteLocal(virConnectPtr conn ATT= RIBUTE_UNUSED, /** * virStorageBackendFindGlusterPoolSources: * @host: host to detect volumes on - * @pooltype: src->format is set to this value + * @pooltype: type of the pool * @list: list of storage pool sources to be filled * @report: report error if the 'gluster' cli tool is missing * * Looks up gluster volumes on @host and fills them to @list. * + * @pooltype allows to influence the specific differences between netfs and + * native gluster pools. Users should pass only VIR_STORAGE_POOL_NETFS or + * VIR_STORAGE_POOL_GLUSTER. + * * Returns number of volumes on the host on success, or -1 on error. */ int virStorageBackendFindGlusterPoolSources(const char *host, - int pooltype, + virStoragePoolType pooltype, virStoragePoolSourceListPtr list, bool report) { @@ -2911,14 +2915,15 @@ virStorageBackendFindGlusterPoolSources(const char = *host, goto cleanup; } + if (pooltype =3D=3D VIR_STORAGE_POOL_NETFS) + src->format =3D VIR_STORAGE_POOL_NETFS_GLUSTERFS; + if (VIR_ALLOC_N(src->hosts, 1) < 0) goto cleanup; src->nhost =3D 1; if (VIR_STRDUP(src->hosts[0].name, host) < 0) goto cleanup; - - src->format =3D pooltype; } ret =3D nnodes; diff --git a/src/storage/storage_util.h b/src/storage/storage_util.h index fa3b6522c..1ba259c1e 100644 --- a/src/storage/storage_util.h +++ b/src/storage/storage_util.h @@ -94,7 +94,7 @@ int virStorageBackendRefreshLocal(virConnectPtr conn, virStoragePoolObjPtr pool); int virStorageBackendFindGlusterPoolSources(const char *host, - int pooltype, + virStoragePoolType pooltype, virStoragePoolSourceListPtr li= st, bool report); --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 10:15:52 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.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1491308489705551.0841653160128; Tue, 4 Apr 2017 05:21:29 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EF5CD4E4FC; Tue, 4 Apr 2017 12:21:27 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B44BB7DB23; Tue, 4 Apr 2017 12:21:27 +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 5E71EB3483; Tue, 4 Apr 2017 12:21:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v34CK8aS007111 for ; Tue, 4 Apr 2017 08:20:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0394084735; Tue, 4 Apr 2017 12:20:08 +0000 (UTC) Received: from angien.brq.redhat.com (dhcp129-47.brq.redhat.com [10.34.129.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0686A8400E; Tue, 4 Apr 2017 12:20:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EF5CD4E4FC Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com EF5CD4E4FC From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 4 Apr 2017 14:20:56 +0200 Message-Id: <3b5e17cd1b6d05d47f0cd87d96b58977a2cdcfd9.1491308364.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa , abologna@redhat.com Subject: [libvirt] [PATCH v3 2/5] storage: util: Split out the gluster volume extraction code into new function 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 04 Apr 2017 12:21:28 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" To allow testing of the algorithm, split out the extractor into a separate helper. --- src/storage/storage_util.c | 95 +++++++++++++++++++++++++++---------------= ---- src/storage/storage_util.h | 4 ++ 2 files changed, 59 insertions(+), 40 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 715361923..b7c594da2 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -2836,6 +2836,60 @@ virStorageBackendDeleteLocal(virConnectPtr conn ATTR= IBUTE_UNUSED, } +int +virStorageUtilGlusterExtractPoolSources(const char *host, + const char *xml, + virStoragePoolSourceListPtr list, + virStoragePoolType pooltype) +{ + xmlDocPtr doc =3D NULL; + xmlXPathContextPtr ctxt =3D NULL; + xmlNodePtr *nodes =3D NULL; + virStoragePoolSource *src =3D NULL; + size_t i; + int nnodes; + int ret =3D -1; + + if (!(doc =3D virXMLParseStringCtxt(xml, _("(gluster_cli_output)"), &c= txt))) + goto cleanup; + + if ((nnodes =3D virXPathNodeSet("//volumes/volume", ctxt, &nodes)) < 0) + goto cleanup; + + for (i =3D 0; i < nnodes; i++) { + ctxt->node =3D nodes[i]; + + if (!(src =3D virStoragePoolSourceListNewSource(list))) + goto cleanup; + + if (!(src->dir =3D virXPathString("string(//name)", ctxt))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("failed to extract gluster volume name")); + goto cleanup; + } + + if (pooltype =3D=3D VIR_STORAGE_POOL_NETFS) + src->format =3D VIR_STORAGE_POOL_NETFS_GLUSTERFS; + + if (VIR_ALLOC_N(src->hosts, 1) < 0) + goto cleanup; + src->nhost =3D 1; + + if (VIR_STRDUP(src->hosts[0].name, host) < 0) + goto cleanup; + } + + ret =3D nnodes; + + cleanup: + VIR_FREE(nodes); + xmlXPathFreeContext(ctxt); + xmlFreeDoc(doc); + + return ret; +} + + /** * virStorageBackendFindGlusterPoolSources: * @host: host to detect volumes on @@ -2860,12 +2914,6 @@ virStorageBackendFindGlusterPoolSources(const char *= host, char *glusterpath =3D NULL; char *outbuf =3D NULL; virCommandPtr cmd =3D NULL; - xmlDocPtr doc =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; - xmlNodePtr *nodes =3D NULL; - virStoragePoolSource *src =3D NULL; - size_t i; - int nnodes; int rc; int ret =3D -1; @@ -2896,42 +2944,9 @@ virStorageBackendFindGlusterPoolSources(const char *= host, goto cleanup; } - if (!(doc =3D virXMLParseStringCtxt(outbuf, _("(gluster_cli_output)"), - &ctxt))) - goto cleanup; - - if ((nnodes =3D virXPathNodeSet("//volumes/volume", ctxt, &nodes)) < 0) - goto cleanup; - - for (i =3D 0; i < nnodes; i++) { - ctxt->node =3D nodes[i]; - - if (!(src =3D virStoragePoolSourceListNewSource(list))) - goto cleanup; - - if (!(src->dir =3D virXPathString("string(//name)", ctxt))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("failed to extract gluster volume name")); - goto cleanup; - } - - if (pooltype =3D=3D VIR_STORAGE_POOL_NETFS) - src->format =3D VIR_STORAGE_POOL_NETFS_GLUSTERFS; - - if (VIR_ALLOC_N(src->hosts, 1) < 0) - goto cleanup; - src->nhost =3D 1; - - if (VIR_STRDUP(src->hosts[0].name, host) < 0) - goto cleanup; - } - - ret =3D nnodes; + ret =3D virStorageUtilGlusterExtractPoolSources(host, outbuf, list, po= oltype); cleanup: - VIR_FREE(nodes); - xmlXPathFreeContext(ctxt); - xmlFreeDoc(doc); VIR_FREE(outbuf); virCommandFree(cmd); VIR_FREE(glusterpath); diff --git a/src/storage/storage_util.h b/src/storage/storage_util.h index 1ba259c1e..602d3a069 100644 --- a/src/storage/storage_util.h +++ b/src/storage/storage_util.h @@ -93,6 +93,10 @@ int virStorageBackendDeleteLocal(virConnectPtr conn, int virStorageBackendRefreshLocal(virConnectPtr conn, virStoragePoolObjPtr pool); +int virStorageUtilGlusterExtractPoolSources(const char *host, + const char *xml, + virStoragePoolSourceListPtr li= st, + virStoragePoolType pooltype); int virStorageBackendFindGlusterPoolSources(const char *host, virStoragePoolType pooltype, virStoragePoolSourceListPtr li= st, --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 10:15:52 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.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1491308480714434.45540765589294; Tue, 4 Apr 2017 05:21:20 -0700 (PDT) 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 5EF9A7F40B; Tue, 4 Apr 2017 12:21: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 A142C8D17F; Tue, 4 Apr 2017 12:21: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 A93D918521CA; Tue, 4 Apr 2017 12:21:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v34CK9T1007116 for ; Tue, 4 Apr 2017 08:20:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id AAE598400E; Tue, 4 Apr 2017 12:20:09 +0000 (UTC) Received: from angien.brq.redhat.com (dhcp129-47.brq.redhat.com [10.34.129.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id AABFB8473C; Tue, 4 Apr 2017 12:20:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5EF9A7F40B Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5EF9A7F40B From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 4 Apr 2017 14:20:57 +0200 Message-Id: <5fa4b736e1691368e798e9672f5cef1d6b755404.1491308364.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa , abologna@redhat.com Subject: [libvirt] [PATCH v3 3/5] test: Introduce testing of virStorageUtilGlusterExtractPoolSources 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: , MIME-Version: 1.0 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.25]); Tue, 04 Apr 2017 12:21:19 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add a test program called virstorageutiltest and test the gluster pool detection code. --- tests/Makefile.am | 16 ++- .../gluster-parse-basic-native.xml | 6 ++ .../gluster-parse-basic-netfs.xml | 7 ++ .../virstorageutildata/gluster-parse-basic-src.xml | 47 +++++++++ tests/virstorageutiltest.c | 112 +++++++++++++++++= ++++ 5 files changed, 187 insertions(+), 1 deletion(-) create mode 100644 tests/virstorageutildata/gluster-parse-basic-native.xml create mode 100644 tests/virstorageutildata/gluster-parse-basic-netfs.xml create mode 100644 tests/virstorageutildata/gluster-parse-basic-src.xml create mode 100644 tests/virstorageutiltest.c diff --git a/tests/Makefile.am b/tests/Makefile.am index a6f189b8b..aa9d2eb3a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -160,7 +160,9 @@ EXTRA_DIST =3D \ xlconfigdata \ xmconfigdata \ xml2sexprdata \ - xml2vmxdata + xml2vmxdata \ + virstorageutildata \ + $(NULL) test_helpers =3D commandhelper ssh test_programs =3D virshtest sockettest \ @@ -353,6 +355,7 @@ endif WITH_NWFILTER if WITH_STORAGE test_programs +=3D storagevolxml2argvtest +test_programs +=3D virstorageutiltest endif WITH_STORAGE if WITH_STORAGE_FS @@ -859,6 +862,16 @@ genericxml2xmltest_LDADD =3D $(LDADDS) if WITH_STORAGE +virstorageutiltest_SOURCES =3D \ + virstorageutiltest.c \ + testutils.c \ + testutils.h \ + $(NULL) +virstorageutiltest_LDADD =3D \ + ../src/libvirt_driver_storage_impl.la \ + $(LDADDS) \ + $(NULL) + storagevolxml2argvtest_SOURCES =3D \ storagevolxml2argvtest.c \ testutils.c testutils.h @@ -868,6 +881,7 @@ storagevolxml2argvtest_LDADD =3D \ else ! WITH_STORAGE EXTRA_DIST +=3D storagevolxml2argvtest.c +EXTRA_DIST +=3D virstorageutiltest.c endif ! WITH_STORAGE storagevolxml2xmltest_SOURCES =3D \ diff --git a/tests/virstorageutildata/gluster-parse-basic-native.xml b/test= s/virstorageutildata/gluster-parse-basic-native.xml new file mode 100644 index 000000000..fbde06f3b --- /dev/null +++ b/tests/virstorageutildata/gluster-parse-basic-native.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/virstorageutildata/gluster-parse-basic-netfs.xml b/tests= /virstorageutildata/gluster-parse-basic-netfs.xml new file mode 100644 index 000000000..8aadd50a1 --- /dev/null +++ b/tests/virstorageutildata/gluster-parse-basic-netfs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/tests/virstorageutildata/gluster-parse-basic-src.xml b/tests/v= irstorageutildata/gluster-parse-basic-src.xml new file mode 100644 index 000000000..08f97cb72 --- /dev/null +++ b/tests/virstorageutildata/gluster-parse-basic-src.xml @@ -0,0 +1,47 @@ + + + 0 + 0 + + + + + vol0 + ac14dfa5-0b98-4593-a2aa-9fe2bb9b9ce3 + 1 + Started + 0 + 2 + 2 + 1 + 2 + 0 + 0 + 0 + 2 + Replicate + 0 + + virt-gluste= r-node1:/bricks/brick1/brickvirt-gluster-node1:/bricks/brick1/bricka6f5ddea-bc6a-44db-ae1d-5aa1db7434900<= /isArbiter> + virt-gluste= r-node2:/bricks/brick1/brickvirt-gluster-node2:/bricks/brick1/brickf4ab9fb1-44ec-443b-8783-e5f70ed78da30<= /isArbiter> + + 3 + + + + + + + 1 + + + diff --git a/tests/virstorageutiltest.c b/tests/virstorageutiltest.c new file mode 100644 index 000000000..12597a014 --- /dev/null +++ b/tests/virstorageutiltest.c @@ -0,0 +1,112 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#include + +#include + +#include "testutils.h" +#include "virerror.h" +#include "virfile.h" +#include "virlog.h" +#include "virstring.h" + +#include "storage/storage_util.h" + +#define VIR_FROM_THIS VIR_FROM_NONE + +VIR_LOG_INIT("tests.storageutiltest"); + + +struct testGlusterLookupParseData { + const char *srcxml; + const char *dstxml; + int type; +}; + +static int +testGlusterExtractPoolSources(const void *opaque) +{ + const struct testGlusterLookupParseData *data =3D opaque; + virStoragePoolSourceList list =3D { .type =3D data->type, + .nsources =3D 0, + .sources =3D NULL + }; + size_t i; + char *srcxmldata =3D NULL; + char *actual =3D NULL; + int ret =3D -1; + + if (virTestLoadFile(data->srcxml, &srcxmldata) < 0) + goto cleanup; + + if (virStorageUtilGlusterExtractPoolSources("testhost", srcxmldata, + &list, data->type) < 0) + goto cleanup; + + if (!(actual =3D virStoragePoolSourceListFormat(&list))) + goto cleanup; + + ret =3D virTestCompareToFile(actual, data->dstxml); + + cleanup: + VIR_FREE(srcxmldata); + VIR_FREE(actual); + + for (i =3D 0; i < list.nsources; i++) + virStoragePoolSourceClear(&list.sources[i]); + VIR_FREE(list.sources); + + return ret; +} + + +static int +mymain(void) +{ + int ret =3D 0; + +#define DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_FULL(testname, sffx, pooltype= ) \ + do { = \ + struct testGlusterLookupParseData data; = \ + data.srcxml =3D abs_srcdir "/virstorageutildata/" = \ + "gluster-parse-" testname "-src.xml"; = \ + data.dstxml =3D abs_srcdir "/virstorageutildata/" = \ + "gluster-parse-" testname "-" sffx ".xml"; = \ + data.type =3D pooltype; = \ + if (virTestRun("gluster lookup " sffx " " testname, = \ + testGlusterExtractPoolSources, &data) < 0) = \ + ret =3D -1; = \ + } while (0) + +#define DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NATIVE(testname) = \ + DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_FULL(testname, "native", = \ + VIR_STORAGE_POOL_GLUSTER) +#define DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NETFS(testname) = \ + DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_FULL(testname, "netfs", = \ + VIR_STORAGE_POOL_NETFS) + + DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NATIVE("basic"); + DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NETFS("basic"); + +#undef DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NATIVE +#undef DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NETFS +#undef DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_FULL + + return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; +} + +VIRT_TEST_MAIN(mymain) --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 10:15:52 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.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1491308488805945.4604169740549; Tue, 4 Apr 2017 05:21:28 -0700 (PDT) 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 8452BA89D; Tue, 4 Apr 2017 12:21:25 +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 4CD8A9629D; Tue, 4 Apr 2017 12:21:25 +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 0551F18523CC; Tue, 4 Apr 2017 12:21:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v34CKBYW007127 for ; Tue, 4 Apr 2017 08:20:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id F361B84037; Tue, 4 Apr 2017 12:20:10 +0000 (UTC) Received: from angien.brq.redhat.com (dhcp129-47.brq.redhat.com [10.34.129.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 265328400E; Tue, 4 Apr 2017 12:20:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8452BA89D Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8452BA89D From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 4 Apr 2017 14:20:58 +0200 Message-Id: <536ed7d6f296777323dc4b2c96f5c04802cf3828.1491308364.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa , abologna@redhat.com Subject: [libvirt] [PATCH v3 4/5] storage: Fix XPath for looking up gluster volume name 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: , MIME-Version: 1.0 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.29]); Tue, 04 Apr 2017 12:21:27 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Use the relative lookup specifier rather than the global one. Otherwise only the first name would be looked up. Add a test case to cover the scenario. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1436574 --- src/storage/storage_util.c | 2 +- .../gluster-parse-multivol-native.xml | 14 ++++++++++ .../gluster-parse-multivol-netfs.xml | 17 ++++++++++++ .../gluster-parse-multivol-src.xml | 32 ++++++++++++++++++= ++++ tests/virstorageutiltest.c | 2 ++ 5 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 tests/virstorageutildata/gluster-parse-multivol-native.= xml create mode 100644 tests/virstorageutildata/gluster-parse-multivol-netfs.x= ml create mode 100644 tests/virstorageutildata/gluster-parse-multivol-src.xml diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index b7c594da2..1e44a2da4 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -2862,7 +2862,7 @@ virStorageUtilGlusterExtractPoolSources(const char *h= ost, if (!(src =3D virStoragePoolSourceListNewSource(list))) goto cleanup; - if (!(src->dir =3D virXPathString("string(//name)", ctxt))) { + if (!(src->dir =3D virXPathString("string(./name)", ctxt))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to extract gluster volume name")); goto cleanup; diff --git a/tests/virstorageutildata/gluster-parse-multivol-native.xml b/t= ests/virstorageutildata/gluster-parse-multivol-native.xml new file mode 100644 index 000000000..d2d8fefc6 --- /dev/null +++ b/tests/virstorageutildata/gluster-parse-multivol-native.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/tests/virstorageutildata/gluster-parse-multivol-netfs.xml b/te= sts/virstorageutildata/gluster-parse-multivol-netfs.xml new file mode 100644 index 000000000..3a542999d --- /dev/null +++ b/tests/virstorageutildata/gluster-parse-multivol-netfs.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/tests/virstorageutildata/gluster-parse-multivol-src.xml b/test= s/virstorageutildata/gluster-parse-multivol-src.xml new file mode 100644 index 000000000..0c1f9d10e --- /dev/null +++ b/tests/virstorageutildata/gluster-parse-multivol-src.xml @@ -0,0 +1,32 @@ + + + + 0 + 0 + + + + + aaa + d0b219d4-4169-4907-8994-d2e2434854ed + 0 + Created + 0 + + + test + 32826068-2320-4b62-a825-2554edb7f020 + 1 + Started + 0 + + + test1 + dfa070f4-b12f-4166-8d68-041b73127abc + 0 + Created + + 3 + + + diff --git a/tests/virstorageutiltest.c b/tests/virstorageutiltest.c index 12597a014..932c922f2 100644 --- a/tests/virstorageutiltest.c +++ b/tests/virstorageutiltest.c @@ -101,6 +101,8 @@ mymain(void) DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NATIVE("basic"); DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NETFS("basic"); + DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NATIVE("multivol"); + DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NETFS("multivol"); #undef DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NATIVE #undef DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NETFS --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 10:15:52 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.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 14913084939231001.9787991149016; Tue, 4 Apr 2017 05:21:33 -0700 (PDT) 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 8425B61D24; Tue, 4 Apr 2017 12:21:31 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 570C97E4FF; Tue, 4 Apr 2017 12:21:31 +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 0E94CB3484; Tue, 4 Apr 2017 12:21:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v34CKCTa007137 for ; Tue, 4 Apr 2017 08:20:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 23D6A84739; Tue, 4 Apr 2017 12:20:12 +0000 (UTC) Received: from angien.brq.redhat.com (dhcp129-47.brq.redhat.com [10.34.129.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4CA968400E; Tue, 4 Apr 2017 12:20:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8425B61D24 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8425B61D24 From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 4 Apr 2017 14:20:59 +0200 Message-Id: <367c38394f8164684daf01d5477ede1503ba6d2d.1491308364.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa , abologna@redhat.com Subject: [libvirt] [PATCH v3 5/5] storage: gluster: Use volume name as "" field in the XML 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: , MIME-Version: 1.0 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.39]); Tue, 04 Apr 2017 12:21:33 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" For native gluster pools the field denotes a directory inside the pool. For the actual pool name the field has to be used. --- src/storage/storage_util.c | 16 ++++++++++++= ++-- tests/virstorageutildata/gluster-parse-basic-native.xml | 3 ++- .../virstorageutildata/gluster-parse-multivol-native.xml | 9 ++++++--- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 1e44a2da4..7cc125a38 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -2846,6 +2846,7 @@ virStorageUtilGlusterExtractPoolSources(const char *h= ost, xmlXPathContextPtr ctxt =3D NULL; xmlNodePtr *nodes =3D NULL; virStoragePoolSource *src =3D NULL; + char *volname; size_t i; int nnodes; int ret =3D -1; @@ -2862,14 +2863,25 @@ virStorageUtilGlusterExtractPoolSources(const char = *host, if (!(src =3D virStoragePoolSourceListNewSource(list))) goto cleanup; - if (!(src->dir =3D virXPathString("string(./name)", ctxt))) { + if (!(volname =3D virXPathString("string(./name)", ctxt))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to extract gluster volume name")); goto cleanup; } - if (pooltype =3D=3D VIR_STORAGE_POOL_NETFS) + if (pooltype =3D=3D VIR_STORAGE_POOL_NETFS) { src->format =3D VIR_STORAGE_POOL_NETFS_GLUSTERFS; + src->dir =3D volname; + } else if (pooltype =3D=3D VIR_STORAGE_POOL_GLUSTER) { + src->name =3D volname; + + if (VIR_STRDUP(src->dir, "/") < 0) + goto cleanup; + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("unsupported gluster lookup")); + goto cleanup; + } if (VIR_ALLOC_N(src->hosts, 1) < 0) goto cleanup; diff --git a/tests/virstorageutildata/gluster-parse-basic-native.xml b/test= s/virstorageutildata/gluster-parse-basic-native.xml index fbde06f3b..895d0f3fd 100644 --- a/tests/virstorageutildata/gluster-parse-basic-native.xml +++ b/tests/virstorageutildata/gluster-parse-basic-native.xml @@ -1,6 +1,7 @@ - + + vol0 diff --git a/tests/virstorageutildata/gluster-parse-multivol-native.xml b/t= ests/virstorageutildata/gluster-parse-multivol-native.xml index d2d8fefc6..c758ac5aa 100644 --- a/tests/virstorageutildata/gluster-parse-multivol-native.xml +++ b/tests/virstorageutildata/gluster-parse-multivol-native.xml @@ -1,14 +1,17 @@ - + + aaa - + + test - + + test1 --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list