diff --git a/include/libvirt/libvirt-storage.h b/include/libvirt/libvirt-storage.h index 4bf2b5f1dd..5a95b2b139 100644 --- a/include/libvirt/libvirt-storage.h +++ b/include/libvirt/libvirt-storage.h @@ -193,6 +193,10 @@ typedef enum { */ virConnectPtr virStoragePoolGetConnect (virStoragePoolPtr pool); +/* Storage Pool capabilities */ +char *virConnectGetStoragePoolCapabilities(virConnectPtr conn, + unsigned int flags); + /* * List active storage pools */ diff --git a/src/driver-storage.h b/src/driver-storage.h index 35bd99a20c..2a855c34d8 100644 --- a/src/driver-storage.h +++ b/src/driver-storage.h @@ -52,6 +52,10 @@ typedef char * const char *srcSpec, unsigned int flags); +typedef char * +(*virDrvConnectGetStoragePoolCapabilities)(virConnectPtr conn, + unsigned int flags); + typedef virStoragePoolPtr (*virDrvStoragePoolLookupByName)(virConnectPtr conn, const char *name); @@ -237,6 +241,7 @@ struct _virStorageDriver { virDrvConnectFindStoragePoolSources connectFindStoragePoolSources; virDrvConnectStoragePoolEventRegisterAny connectStoragePoolEventRegisterAny; virDrvConnectStoragePoolEventDeregisterAny connectStoragePoolEventDeregisterAny; + virDrvConnectGetStoragePoolCapabilities connectGetStoragePoolCapabilities; virDrvStoragePoolLookupByName storagePoolLookupByName; virDrvStoragePoolLookupByUUID storagePoolLookupByUUID; virDrvStoragePoolLookupByVolume storagePoolLookupByVolume; diff --git a/src/libvirt-storage.c b/src/libvirt-storage.c index 2ea3e94e45..3bd61dc986 100644 --- a/src/libvirt-storage.c +++ b/src/libvirt-storage.c @@ -2351,3 +2351,43 @@ virConnectStoragePoolEventDeregisterAny(virConnectPtr conn, virDispatchError(conn); return -1; } + + +/** + * virConnectGetStoragePoolCapabilities: + * @conn: pointer to the hypervisor connection + * @flags: extra flags; not used yet, so callers should always pass 0 + * + * Prior creating a storage pool (for instance via virStoragePoolCreateXML + * or virStoragePoolDefineXML) it may be suitable to know what pool types + * are supported along with the file/disk formats for each pool. + * + * Returns NULL in case of error or an XML string defining the capabilities. + */ +char * +virConnectGetStoragePoolCapabilities(virConnectPtr conn, + unsigned int flags) +{ + VIR_DEBUG("conn=%p, flags=0x%x", conn, flags); + + virResetLastError(); + + virCheckConnectReturn(conn, NULL); + + if (conn->storageDriver && + conn->storageDriver->connectGetStoragePoolCapabilities) { + char *ret; + ret = conn->storageDriver->connectGetStoragePoolCapabilities(conn, + flags); + if (!ret) + goto error; + VIR_DEBUG("conn=%p, ret=%s", conn, ret); + return ret; + } + + virReportUnsupportedError(); + + error: + virDispatchError(conn); + return NULL; +} diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 042b4df043..dbce3336d5 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -814,4 +814,9 @@ LIBVIRT_4.10.0 { virDomainSetIOThreadParams; } LIBVIRT_4.5.0; +LIBVIRT_5.2.0 { + global: + virConnectGetStoragePoolCapabilities; +} LIBVIRT_4.10.0; + # .... define new API here using predicted next version number .... diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 2861ee68e2..eabe7a3823 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8572,6 +8572,7 @@ static virStorageDriver storage_driver = { .connectFindStoragePoolSources = remoteConnectFindStoragePoolSources, /* 0.4.5 */ .connectStoragePoolEventDeregisterAny = remoteConnectStoragePoolEventDeregisterAny, /* 2.0.0 */ .connectStoragePoolEventRegisterAny = remoteConnectStoragePoolEventRegisterAny, /* 2.0.0 */ + .connectGetStoragePoolCapabilities = remoteConnectGetStoragePoolCapabilities, /* 5.2.0 */ .storagePoolLookupByName = remoteStoragePoolLookupByName, /* 0.4.1 */ .storagePoolLookupByUUID = remoteStoragePoolLookupByUUID, /* 0.4.1 */ .storagePoolLookupByVolume = remoteStoragePoolLookupByVolume, /* 0.4.1 */ diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 60cc40e04a..74be4b37d0 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -3565,6 +3565,14 @@ struct remote_connect_list_all_nwfilter_bindings_ret { /* insert@1 */ unsigned int ret; }; +struct remote_connect_get_storage_pool_capabilities_args { + unsigned int flags; +}; + +struct remote_connect_get_storage_pool_capabilities_ret { + remote_nonnull_string capabilities; +}; + /*----- Protocol. -----*/ /* Define the program number, protocol version and procedure numbers here. */ @@ -6328,6 +6336,11 @@ enum remote_procedure { * @acl: domain:save:!VIR_DOMAIN_AFFECT_CONFIG|VIR_DOMAIN_AFFECT_LIVE * @acl: domain:save:VIR_DOMAIN_AFFECT_CONFIG */ - REMOTE_PROC_DOMAIN_SET_IOTHREAD_PARAMS = 402 + REMOTE_PROC_DOMAIN_SET_IOTHREAD_PARAMS = 402, + /** + * @generate: both + * @acl: connect:read + */ + REMOTE_PROC_CONNECT_GET_STORAGE_POOL_CAPABILITIES = 403 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 7c27c63542..768189c573 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -2975,6 +2975,12 @@ struct remote_connect_list_all_nwfilter_bindings_ret { } bindings; u_int ret; }; +struct remote_connect_get_storage_pool_capabilities_args { + u_int flags; +}; +struct remote_connect_get_storage_pool_capabilities_ret { + remote_nonnull_string capabilities; +}; enum remote_procedure { REMOTE_PROC_CONNECT_OPEN = 1, REMOTE_PROC_CONNECT_CLOSE = 2, @@ -3378,4 +3384,5 @@ enum remote_procedure { REMOTE_PROC_NWFILTER_BINDING_DELETE = 400, REMOTE_PROC_CONNECT_LIST_ALL_NWFILTER_BINDINGS = 401, REMOTE_PROC_DOMAIN_SET_IOTHREAD_PARAMS = 402, + REMOTE_PROC_CONNECT_GET_STORAGE_POOL_CAPABILITIES = 403, };