[PATCH v2 01/12] esx: split datastoreToStoragePoolPtr helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Move the creation of a virStoragePtr object from the esxVI_ObjectContent
object of a datastore out of esxStoragePoolLookupByName in an own
helper. This way it can be used also in other functions.

Signed-off-by: Pino Toscano <ptoscano@xxxxxxxxxx>
---
 src/esx/esx_storage_backend_vmfs.c | 45 ++++++++++++++++++++----------
 1 file changed, 31 insertions(+), 14 deletions(-)

diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backend_vmfs.c
index 5f25f80072..78fe2b598d 100644
--- a/src/esx/esx_storage_backend_vmfs.c
+++ b/src/esx/esx_storage_backend_vmfs.c
@@ -195,26 +195,16 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names,
 
 
 static virStoragePoolPtr
-esxStoragePoolLookupByName(virConnectPtr conn,
-                           const char *name)
+datastoreToStoragePoolPtr(virConnectPtr conn,
+                          const char *name,
+                          esxVI_ObjectContent *datastore)
 {
     esxPrivate *priv = conn->privateData;
-    esxVI_ObjectContent *datastore = NULL;
     esxVI_DatastoreHostMount *hostMount = NULL;
     /* VIR_CRYPTO_HASH_SIZE_MD5 = VIR_UUID_BUFLEN = 16 */
     unsigned char md5[VIR_CRYPTO_HASH_SIZE_MD5];
     virStoragePoolPtr pool = NULL;
 
-    if (esxVI_LookupDatastoreByName(priv->primary, name, NULL, &datastore,
-                                    esxVI_Occurrence_OptionalItem) < 0) {
-        goto cleanup;
-    }
-
-    if (!datastore) {
-        /* Not found, let the base storage driver handle error reporting */
-        goto cleanup;
-    }
-
     /*
      * Datastores don't have a UUID, but we can use the 'host.mountInfo.path'
      * property as source for a UUID. The mount path is unique per host and
@@ -239,7 +229,6 @@ esxStoragePoolLookupByName(virConnectPtr conn,
     pool = virGetStoragePool(conn, name, md5, &esxStorageBackendVMFS, NULL);
 
  cleanup:
-    esxVI_ObjectContent_Free(&datastore);
     esxVI_DatastoreHostMount_Free(&hostMount);
 
     return pool;
@@ -247,6 +236,34 @@ esxStoragePoolLookupByName(virConnectPtr conn,
 
 
 
+static virStoragePoolPtr
+esxStoragePoolLookupByName(virConnectPtr conn,
+                           const char *name)
+{
+    esxPrivate *priv = conn->privateData;
+    esxVI_ObjectContent *datastore = NULL;
+    virStoragePoolPtr pool = NULL;
+
+    if (esxVI_LookupDatastoreByName(priv->primary, name, NULL, &datastore,
+                                    esxVI_Occurrence_OptionalItem) < 0) {
+        goto cleanup;
+    }
+
+    if (!datastore) {
+        /* Not found, let the base storage driver handle error reporting */
+        goto cleanup;
+    }
+
+    pool = datastoreToStoragePoolPtr(conn, name, datastore);
+
+ cleanup:
+    esxVI_ObjectContent_Free(&datastore);
+
+    return pool;
+}
+
+
+
 static virStoragePoolPtr
 esxStoragePoolLookupByUUID(virConnectPtr conn,
                            const unsigned char *uuid)
-- 
2.21.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux