# include "storage_conf.h"
+# include "capabilities.h"
+
typedef struct _virStoragePoolObj virStoragePoolObj;
typedef virStoragePoolObj *virStoragePoolObjPtr;
/* Immutable pointer, self-locking APIs */
virObjectEventStatePtr storageEventState;
+
+ /* Immutable pointer, read only after initialized */
+ virCapsPtr caps;
};
typedef bool
type, NULLSTR(virStoragePoolTypeToString(type)));
return NULL;
}
+
+
+virCapsPtr
+virStorageBackendGetCapabilities(void)
+{
+ virCapsPtr caps;
+ size_t i;
+
+ if (!(caps = virCapabilitiesNew(VIR_ARCH_NONE, false, false)))
+ return NULL;
+
+ for (i = 0; i < virStorageBackendsCount; i++)
+ virCapabilitiesAddStoragePool(caps, virStorageBackends[i]->type);
+
+ return caps;
+}
driver->storageEventState = virObjectEventStateNew();
+ /* 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 = virStorageBackendGetCapabilities()))
+ goto error;
+
storageDriverUnlock();
return 0;
storageDriverLock();
+ virObjectUnref(driver->caps);
virObjectUnref(driver->storageEventState);
/* free inactive pools */
names, maxnames);
}
+
+static char *
+storageConnectGetCapabilities(virConnectPtr conn)
+{
+
+ if (virConnectGetCapabilitiesEnsureACL(conn) < 0)
+ return NULL;
+
+ return virCapabilitiesFormatXML(driver->caps);
+}
+
+
static int
storageConnectNumOfDefinedStoragePools(virConnectPtr conn)
{
.connectIsEncrypted = storageConnectIsEncrypted, /* 4.1.0 */
.connectIsSecure = storageConnectIsSecure, /* 4.1.0 */
.connectIsAlive = storageConnectIsAlive, /* 4.1.0 */
+ .connectGetCapabilities = storageConnectGetCapabilities, /* 5.2.0 */
};
static virConnectDriver storageConnectDriver = {