mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
esx: split targetToStoragePool helper
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@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
818bc30a71
commit
1652ce6680
@ -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
|
static virStoragePoolPtr
|
||||||
esxStoragePoolLookupByName(virConnectPtr conn,
|
esxStoragePoolLookupByName(virConnectPtr conn,
|
||||||
const char *name)
|
const char *name)
|
||||||
{
|
{
|
||||||
esxPrivate *priv = conn->privateData;
|
esxPrivate *priv = conn->privateData;
|
||||||
esxVI_HostInternetScsiHbaStaticTarget *target = NULL;
|
esxVI_HostInternetScsiHbaStaticTarget *target = NULL;
|
||||||
/* VIR_CRYPTO_HASH_SIZE_MD5 = VIR_UUID_BUFLEN = 16 */
|
|
||||||
unsigned char md5[VIR_CRYPTO_HASH_SIZE_MD5];
|
|
||||||
virStoragePoolPtr pool = NULL;
|
virStoragePoolPtr pool = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -172,15 +190,7 @@ esxStoragePoolLookupByName(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
pool = targetToStoragePool(conn, name, target);
|
||||||
* 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);
|
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
esxVI_HostInternetScsiHbaStaticTarget_Free(&target);
|
esxVI_HostInternetScsiHbaStaticTarget_Free(&target);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user