]> xenbits.xensource.com Git - libvirt.git/commitdiff
libvirt: Introduce virConnectGetStoragePoolCapabilities
authorJohn Ferlan <jferlan@redhat.com>
Thu, 7 Feb 2019 17:02:25 +0000 (12:02 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 6 Mar 2019 16:12:48 +0000 (11:12 -0500)
Introduce the API to expose the storage pool capabilities along
with all the remote munglement required to hook up the client.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
include/libvirt/libvirt-storage.h
src/driver-storage.h
src/libvirt-storage.c
src/libvirt_public.syms
src/remote/remote_driver.c
src/remote/remote_protocol.x
src/remote_protocol-structs

index 4bf2b5f1dd8c74ca63076b0ce153f05fd667a888..5a95b2b139f3ef708d9d2d99893f687e310aa017 100644 (file)
@@ -193,6 +193,10 @@ typedef enum {
  */
 virConnectPtr           virStoragePoolGetConnect        (virStoragePoolPtr pool);
 
+/* Storage Pool capabilities */
+char *virConnectGetStoragePoolCapabilities(virConnectPtr conn,
+                                           unsigned int flags);
+
 /*
  * List active storage pools
  */
index 35bd99a20c6a0d15f1b476969b564af61809c426..2a855c34d8bfbda04491dc52ede41cd4b9e4cc4f 100644 (file)
@@ -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;
index 2ea3e94e4527bdc108728af22409b8f5fa06d398..3bd61dc98650503f744e09d063fb89c78ab708cd 100644 (file)
@@ -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;
+}
index 042b4df043f520f3508b28f640031d601a3245e2..dbce3336d55de277713c32ce34111498caecf736 100644 (file)
@@ -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 ....
index 2861ee68e20946a8ed543a8c78ece296e003e64b..eabe7a38239de9ef1fc3a09d84e7bd2f7906fd1e 100644 (file)
@@ -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 */
index 60cc40e04ab4cb272785f9638fa9c74e8663022a..74be4b37d0a6b7926481ccaa2845318c0ff7779b 100644 (file)
@@ -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
 };
index 7c27c63542b3a1fd5c774191a9216da4dddb73ec..768189c573b4ba0822152def0e5399bff436b709 100644 (file)
@@ -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,
 };