From nobody Sun Feb 8 22:49:02 2026 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 1547601370334380.377491151409; Tue, 15 Jan 2019 17:16:10 -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 5D93081F13; Wed, 16 Jan 2019 01:16:08 +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 03D3F5C553; Wed, 16 Jan 2019 01:16:08 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7177C3F7CD; Wed, 16 Jan 2019 01:16:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x0G1FwDB022762 for ; Tue, 15 Jan 2019 20:15:58 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5D1EA19940; Wed, 16 Jan 2019 01:15:58 +0000 (UTC) Received: from unknown0050b6a41c42.attlocal.net.com (ovpn-116-153.phx2.redhat.com [10.3.116.153]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1732D19C7C for ; Wed, 16 Jan 2019 01:15:57 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 15 Jan 2019 20:15:49 -0500 Message-Id: <20190116011549.16309-8-jferlan@redhat.com> In-Reply-To: <20190116011549.16309-1-jferlan@redhat.com> References: <20190116011549.16309-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 7/7] storage: Add storage backend pool/vol API's to capability output 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.25]); Wed, 16 Jan 2019 01:16:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1581670 Add the Storage Pool and Volume API's defined for each generated capability output, such as: dir ... iscsi Signed-off-by: John Ferlan --- src/conf/capabilities.c | 49 ++++++++++++++++++++++++++++++-- src/conf/capabilities.h | 6 +++- src/storage/storage_backend.c | 53 +++++++++++++++++++++++++++++++++-- 3 files changed, 103 insertions(+), 5 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index c60743a38d..f7e9873f64 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -188,6 +188,8 @@ virCapabilitiesFreeStoragePool(virCapsStoragePoolPtr po= ol) if (!pool) return; =20 + VIR_FREE(pool->poolapis); + VIR_FREE(pool->volapis); VIR_FREE(pool); } =20 @@ -811,7 +813,9 @@ virCapabilitiesDomainDataLookup(virCapsPtr caps, =20 int virCapabilitiesAddStoragePool(virCapsPtr caps, - int poolType) + int poolType, + const char *poolstr, + const char *volstr) { virCapsStoragePoolPtr pool; =20 @@ -823,7 +827,10 @@ virCapabilitiesAddStoragePool(virCapsPtr caps, if (VIR_RESIZE_N(caps->pools, caps->npools_max, caps->npools, 1) < 0) goto error; caps->pools[caps->npools++] =3D pool; - + if (VIR_STRDUP(pool->poolapis, poolstr) < 0) + goto error; + if (VIR_STRDUP(pool->volapis, volstr) < 0) + goto error; return 0; =20 error: @@ -1322,15 +1329,53 @@ virCapabilitiesFormatStoragePoolXML(virCapsStorageP= oolPtr *pools, virBufferPtr buf) { size_t i; + char **poolapis =3D NULL; + size_t npoolapis =3D 0; + char **volapis =3D NULL; + size_t nvolapis =3D 0; =20 for (i =3D 0; i < npools; i++) { + size_t j; + + if (!(poolapis =3D virStringSplitCount(pools[i]->poolapis, ",", + 0, &npoolapis)) || + !(volapis =3D virStringSplitCount(pools[i]->volapis, ",", + 0, &nvolapis))) + goto cleanup; + virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, 2); virBufferAsprintf(buf, "%s\n", virStoragePoolTypeToString(pools[i]->type)); + + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); + for (j =3D 0; j < npoolapis; j++) + virBufferAsprintf(buf, "<%s/>\n", poolapis[j]); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); + for (j =3D 0; j < nvolapis; j++) + virBufferAsprintf(buf, "<%s/>\n", volapis[j]); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n\n"); + + virStringListFree(poolapis); + poolapis =3D NULL; + npoolapis =3D 0; + virStringListFree(volapis); + volapis =3D NULL; + nvolapis =3D 0; } + + cleanup: + virStringListFree(poolapis); + virStringListFree(volapis); } =20 =20 diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index cca1a20949..525f19f195 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -215,6 +215,8 @@ typedef struct _virCapsStoragePool virCapsStoragePool; typedef virCapsStoragePool *virCapsStoragePoolPtr; struct _virCapsStoragePool { int type; + char *poolapis; + char *volapis; }; =20 =20 @@ -331,7 +333,9 @@ virCapabilitiesAddGuestFeature(virCapsGuestPtr guest, =20 int virCapabilitiesAddStoragePool(virCapsPtr caps, - int poolType); + int poolType, + const char *poolstr, + const char *volstr); =20 int virCapabilitiesHostSecModelAddBaseLabel(virCapsHostSecModelPtr secmodel, diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index 0ccc616db4..95873c151f 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -193,13 +193,62 @@ virCapsPtr virStorageBackendGetCapabilities(void) { virCapsPtr caps; + virBuffer poolbuf =3D VIR_BUFFER_INITIALIZER; + virBuffer volbuf =3D VIR_BUFFER_INITIALIZER; size_t i; =20 if (!(caps =3D virCapabilitiesNew(virArchFromHost(), false, false))) return NULL; =20 - for (i =3D 0; i < virStorageBackendsCount; i++) - virCapabilitiesAddStoragePool(caps, virStorageBackends[i]->type); +#define BUF_POOL_BACKEND(field) \ + if (backend->field) \ + virBufferAsprintf(&poolbuf, "%s,", #field); + +#define BUF_VOL_BACKEND(field) \ + if (backend->field) \ + virBufferAsprintf(&volbuf, "%s,", #field); + + for (i =3D 0; i < virStorageBackendsCount; i++) { + char *poolstr =3D NULL; + char *volstr =3D NULL; + virStorageBackendPtr backend =3D virStorageBackends[i]; + + /* NB: checkPool is an internal only mechanism each pool has */ + BUF_POOL_BACKEND(findPoolSources); + BUF_POOL_BACKEND(startPool); + BUF_POOL_BACKEND(buildPool); + BUF_POOL_BACKEND(refreshPool); + BUF_POOL_BACKEND(stopPool); + BUF_POOL_BACKEND(deletePool); + virBufferTrim(&poolbuf, ",", -1); + + BUF_VOL_BACKEND(buildVol); + BUF_VOL_BACKEND(buildVolFrom); + BUF_VOL_BACKEND(createVol); + BUF_VOL_BACKEND(refreshVol); + BUF_VOL_BACKEND(deleteVol); + BUF_VOL_BACKEND(resizeVol); + BUF_VOL_BACKEND(uploadVol); + BUF_VOL_BACKEND(downloadVol); + BUF_VOL_BACKEND(wipeVol); + virBufferTrim(&volbuf, ",", -1); + + if (virBufferCheckError(&poolbuf) < 0 || + virBufferCheckError(&volbuf) < 0) + goto error; + + poolstr =3D virBufferContentAndReset(&poolbuf); + volstr =3D virBufferContentAndReset(&volbuf); + virCapabilitiesAddStoragePool(caps, backend->type, poolstr, volstr= ); + VIR_FREE(poolstr); + VIR_FREE(volstr); + } =20 return caps; + + error: + virBufferFreeAndReset(&poolbuf); + virBufferFreeAndReset(&volbuf); + virObjectUnref(caps); + return NULL; } --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list