[PATCH 3/5] esx: split targetToStoragePool helper

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

 



Move the creation of a virStoragePtr object from the
esxVI_HostInternetScsiHbaStaticTarget object of a target 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_iscsi.c | 32 +++++++++++++++++++----------
 1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/src/esx/esx_storage_backend_iscsi.c b/src/esx/esx_storage_backend_iscsi.c
index 61354a6938..72ab0d3cb0 100644
--- a/src/esx/esx_storage_backend_iscsi.c
+++ b/src/esx/esx_storage_backend_iscsi.c
@@ -147,14 +147,32 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names,
 
 
 
+static virStoragePoolPtr
+targetToStoragePool(virConnectPtr conn,
+                    const char *name,
+                    esxVI_HostInternetScsiHbaStaticTarget *target)
+{
+    /* VIR_CRYPTO_HASH_SIZE_MD5 = VIR_UUID_BUFLEN = 16 */
+    unsigned char md5[VIR_CRYPTO_HASH_SIZE_MD5];
+
+    /*
+     * HostInternetScsiHbaStaticTarget does not provide a uuid field,
+     * but iScsiName (or widely known as IQN) is unique across the multiple
+     * hosts, using it to compute key
+     */
+    if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, target->iScsiName, md5) < 0)
+        return NULL;
+
+    return virGetStoragePool(conn, name, md5, &esxStorageBackendISCSI, NULL);
+}
+
+
 static virStoragePoolPtr
 esxStoragePoolLookupByName(virConnectPtr conn,
                            const char *name)
 {
     esxPrivate *priv = conn->privateData;
     esxVI_HostInternetScsiHbaStaticTarget *target = NULL;
-    /* VIR_CRYPTO_HASH_SIZE_MD5 = VIR_UUID_BUFLEN = 16 */
-    unsigned char md5[VIR_CRYPTO_HASH_SIZE_MD5];
     virStoragePoolPtr pool = NULL;
 
     /*
@@ -172,15 +190,7 @@ esxStoragePoolLookupByName(virConnectPtr conn,
         goto cleanup;
     }
 
-    /*
-     * HostInternetScsiHbaStaticTarget does not provide a uuid field,
-     * but iScsiName (or widely known as IQN) is unique across the multiple
-     * hosts, using it to compute key
-     */
-    if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, target->iScsiName, md5) < 0)
-        goto cleanup;
-
-    pool = virGetStoragePool(conn, name, md5, &esxStorageBackendISCSI, NULL);
+    pool = targetToStoragePool(conn, name, target);
 
  cleanup:
     esxVI_HostInternetScsiHbaStaticTarget_Free(&target);
-- 
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