From nobody Sun Feb 8 17:21:48 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 1549985338705121.65312116658379; Tue, 12 Feb 2019 07:28:58 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1FCE8C01DDE5; Tue, 12 Feb 2019 15:28:56 +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 CFC8A97B0C; Tue, 12 Feb 2019 15:28:55 +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 8B2E21819AF8; Tue, 12 Feb 2019 15:28:55 +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 x1CFSn9p024112 for ; Tue, 12 Feb 2019 10:28:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9346E608DC; Tue, 12 Feb 2019 15:28:49 +0000 (UTC) Received: from unknown0050b6a41c42.attlocal.net.com (ovpn-117-20.phx2.redhat.com [10.3.117.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4CBA117A66 for ; Tue, 12 Feb 2019 15:28:46 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 12 Feb 2019 10:28:08 -0500 Message-Id: <20190212152816.3454-10-jferlan@redhat.com> In-Reply-To: <20190212152816.3454-1-jferlan@redhat.com> References: <20190212152816.3454-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 09/17] storage: Process storage pool capabilities X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 12 Feb 2019 15:28:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1581670 During storage driver backend initialization, let's save which backends are available in the storage pool capabilities. In order to format those, we need add a connectGetCapabilities processor to the storageHypervisorDriver. This allows a storage connection, such as "storage:///system" to find the API and format the results, such as: virsh -c storage:///system capabilities dir fs netfs logical iscsi iscsi-direct scsi mpath disk rbd sheepdog gluster zfs Signed-off-by: John Ferlan --- src/conf/virstorageobj.h | 5 +++++ src/storage/storage_backend.c | 16 ++++++++++++++++ src/storage/storage_backend.h | 3 +++ src/storage/storage_driver.c | 20 ++++++++++++++++++++ 4 files changed, 44 insertions(+) diff --git a/src/conf/virstorageobj.h b/src/conf/virstorageobj.h index 1106aa71bd..c41d4c16ad 100644 --- a/src/conf/virstorageobj.h +++ b/src/conf/virstorageobj.h @@ -24,6 +24,8 @@ =20 # include "storage_conf.h" =20 +# include "capabilities.h" + typedef struct _virStoragePoolObj virStoragePoolObj; typedef virStoragePoolObj *virStoragePoolObjPtr; =20 @@ -45,6 +47,9 @@ struct _virStorageDriverState { =20 /* Immutable pointer, self-locking APIs */ virObjectEventStatePtr storageEventState; + + /* Immutable pointer, read only after initialized */ + virCapsPtr caps; }; =20 typedef bool diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index a54c338cf0..df37d94831 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -187,3 +187,19 @@ virStorageBackendForType(int type) type, NULLSTR(virStoragePoolTypeToString(type))); return NULL; } + + +virCapsPtr +virStorageBackendGetCapabilities(void) +{ + virCapsPtr caps; + size_t i; + + if (!(caps =3D virCapabilitiesNew(VIR_ARCH_NONE, false, false))) + return NULL; + + for (i =3D 0; i < virStorageBackendsCount; i++) + virCapabilitiesAddStoragePool(caps, virStorageBackends[i]->type); + + return caps; +} diff --git a/src/storage/storage_backend.h b/src/storage/storage_backend.h index 2b178494ae..c670c66287 100644 --- a/src/storage/storage_backend.h +++ b/src/storage/storage_backend.h @@ -126,4 +126,7 @@ int virStorageBackendDriversRegister(bool allmodules); =20 int virStorageBackendRegister(virStorageBackendPtr backend); =20 +virCapsPtr +virStorageBackendGetCapabilities(void); + #endif /* LIBVIRT_STORAGE_BACKEND_H */ diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 34634e97d9..f2bc24370d 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -296,6 +296,12 @@ storageStateInitialize(bool privileged, =20 driver->storageEventState =3D virObjectEventStateNew(); =20 + /* Only one load of storage driver plus backends exists. Unlike + * domains where new binaries could change the capabilities. A + * new/changed backend requires a reinitialization. */ + if (!(driver->caps =3D virStorageBackendGetCapabilities())) + goto error; + storageDriverUnlock(); =20 return 0; @@ -360,6 +366,7 @@ storageStateCleanup(void) =20 storageDriverLock(); =20 + virObjectUnref(driver->caps); virObjectUnref(driver->storageEventState); =20 /* free inactive pools */ @@ -569,6 +576,18 @@ storageConnectListStoragePools(virConnectPtr conn, names, maxnames); } =20 + +static char * +storageConnectGetCapabilities(virConnectPtr conn) +{ + + if (virConnectGetCapabilitiesEnsureACL(conn) < 0) + return NULL; + + return virCapabilitiesFormatXML(driver->caps); +} + + static int storageConnectNumOfDefinedStoragePools(virConnectPtr conn) { @@ -2819,6 +2838,7 @@ static virHypervisorDriver storageHypervisorDriver = =3D { .connectIsEncrypted =3D storageConnectIsEncrypted, /* 4.1.0 */ .connectIsSecure =3D storageConnectIsSecure, /* 4.1.0 */ .connectIsAlive =3D storageConnectIsAlive, /* 4.1.0 */ + .connectGetCapabilities =3D storageConnectGetCapabilities, /* 5.1.0 */ }; =20 static virConnectDriver storageConnectDriver =3D { --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list