mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
esx: split datastoreToStoragePoolPtr helper
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@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
8e681cdab9
commit
730a5bcf9f
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user