mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
ESX: Check if a datastore is accessible first
An inaccessible datastore has no valid URL property so don't access its URI property. * src/esx/esx_vi.c: esxVI_LookupDatastoreByName(): check if datastore is accessible before accessing its URL property * src/esx/esx_vmx.c: update to changed datastore properties
This commit is contained in:
parent
23b2497292
commit
b167672c74
@ -1833,7 +1833,9 @@ esxVI_LookupDatastoreByName(virConnectPtr conn, esxVI_Context *ctx,
|
|||||||
esxVI_ObjectContent *datastoreList = NULL;
|
esxVI_ObjectContent *datastoreList = NULL;
|
||||||
esxVI_ObjectContent *candidate = NULL;
|
esxVI_ObjectContent *candidate = NULL;
|
||||||
esxVI_DynamicProperty *dynamicProperty = NULL;
|
esxVI_DynamicProperty *dynamicProperty = NULL;
|
||||||
|
esxVI_Boolean accessible = esxVI_Boolean_Undefined;
|
||||||
size_t offset = strlen("/vmfs/volumes/");
|
size_t offset = strlen("/vmfs/volumes/");
|
||||||
|
int numInaccessibleDatastores = 0;
|
||||||
|
|
||||||
if (datastore == NULL || *datastore != NULL) {
|
if (datastore == NULL || *datastore != NULL) {
|
||||||
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, "Invalid argument");
|
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, "Invalid argument");
|
||||||
@ -1844,8 +1846,9 @@ esxVI_LookupDatastoreByName(virConnectPtr conn, esxVI_Context *ctx,
|
|||||||
if (esxVI_String_DeepCopyList(conn, &completePropertyNameList,
|
if (esxVI_String_DeepCopyList(conn, &completePropertyNameList,
|
||||||
propertyNameList) < 0 ||
|
propertyNameList) < 0 ||
|
||||||
esxVI_String_AppendValueListToList(conn, &completePropertyNameList,
|
esxVI_String_AppendValueListToList(conn, &completePropertyNameList,
|
||||||
"info.name\0"
|
"summary.accessible\0"
|
||||||
"info.url\0") < 0) {
|
"summary.name\0"
|
||||||
|
"summary.url\0") < 0) {
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1868,9 +1871,37 @@ esxVI_LookupDatastoreByName(virConnectPtr conn, esxVI_Context *ctx,
|
|||||||
/* Search for a matching datastore */
|
/* Search for a matching datastore */
|
||||||
for (candidate = datastoreList; candidate != NULL;
|
for (candidate = datastoreList; candidate != NULL;
|
||||||
candidate = candidate->_next) {
|
candidate = candidate->_next) {
|
||||||
|
accessible = esxVI_Boolean_Undefined;
|
||||||
|
|
||||||
for (dynamicProperty = candidate->propSet; dynamicProperty != NULL;
|
for (dynamicProperty = candidate->propSet; dynamicProperty != NULL;
|
||||||
dynamicProperty = dynamicProperty->_next) {
|
dynamicProperty = dynamicProperty->_next) {
|
||||||
if (STREQ(dynamicProperty->name, "info.name")) {
|
if (STREQ(dynamicProperty->name, "summary.accessible")) {
|
||||||
|
if (esxVI_AnyType_ExpectType(conn, dynamicProperty->val,
|
||||||
|
esxVI_Type_Boolean) < 0) {
|
||||||
|
goto failure;
|
||||||
|
}
|
||||||
|
|
||||||
|
accessible = dynamicProperty->val->boolean;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (accessible == esxVI_Boolean_Undefined) {
|
||||||
|
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
|
||||||
|
"Got incomplete response while querying for the "
|
||||||
|
"datastore 'summary.accessible' property");
|
||||||
|
goto failure;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (accessible == esxVI_Boolean_False) {
|
||||||
|
++numInaccessibleDatastores;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (dynamicProperty = candidate->propSet; dynamicProperty != NULL;
|
||||||
|
dynamicProperty = dynamicProperty->_next) {
|
||||||
|
if (STREQ(dynamicProperty->name, "summary.accessible")) {
|
||||||
|
/* Ignore it */
|
||||||
|
} else if (STREQ(dynamicProperty->name, "summary.name")) {
|
||||||
if (esxVI_AnyType_ExpectType(conn, dynamicProperty->val,
|
if (esxVI_AnyType_ExpectType(conn, dynamicProperty->val,
|
||||||
esxVI_Type_String) < 0) {
|
esxVI_Type_String) < 0) {
|
||||||
goto failure;
|
goto failure;
|
||||||
@ -1885,7 +1916,15 @@ esxVI_LookupDatastoreByName(virConnectPtr conn, esxVI_Context *ctx,
|
|||||||
/* Found datastore with matching name */
|
/* Found datastore with matching name */
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
} else if (STREQ(dynamicProperty->name, "info.url")) {
|
} else if (STREQ(dynamicProperty->name, "summary.url")) {
|
||||||
|
if (accessible == esxVI_Boolean_False) {
|
||||||
|
/*
|
||||||
|
* The 'summary.url' property of an inaccessible datastore
|
||||||
|
* is invalid and cannot be used to identify the datastore.
|
||||||
|
*/
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (esxVI_AnyType_ExpectType(conn, dynamicProperty->val,
|
if (esxVI_AnyType_ExpectType(conn, dynamicProperty->val,
|
||||||
esxVI_Type_String) < 0) {
|
esxVI_Type_String) < 0) {
|
||||||
goto failure;
|
goto failure;
|
||||||
@ -1916,8 +1955,15 @@ esxVI_LookupDatastoreByName(virConnectPtr conn, esxVI_Context *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (occurence != esxVI_Occurence_OptionalItem) {
|
if (occurence != esxVI_Occurence_OptionalItem) {
|
||||||
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
|
if (numInaccessibleDatastores > 0) {
|
||||||
"Could not find datastore with name '%s'", name);
|
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
|
||||||
|
"Could not find datastore '%s', maybe it's "
|
||||||
|
"inaccessible", name);
|
||||||
|
} else {
|
||||||
|
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
|
||||||
|
"Could not find datastore '%s'", name);
|
||||||
|
}
|
||||||
|
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -612,7 +612,9 @@ esxVMX_AbsolutePathToDatastoreRelatedPath(virConnectPtr conn,
|
|||||||
|
|
||||||
for (dynamicProperty = datastore->propSet; dynamicProperty != NULL;
|
for (dynamicProperty = datastore->propSet; dynamicProperty != NULL;
|
||||||
dynamicProperty = dynamicProperty->_next) {
|
dynamicProperty = dynamicProperty->_next) {
|
||||||
if (STREQ(dynamicProperty->name, "info.name")) {
|
if (STREQ(dynamicProperty->name, "summary.accessible")) {
|
||||||
|
/* Ignore it */
|
||||||
|
} else if (STREQ(dynamicProperty->name, "summary.name")) {
|
||||||
if (esxVI_AnyType_ExpectType(conn, dynamicProperty->val,
|
if (esxVI_AnyType_ExpectType(conn, dynamicProperty->val,
|
||||||
esxVI_Type_String) < 0) {
|
esxVI_Type_String) < 0) {
|
||||||
goto failure;
|
goto failure;
|
||||||
@ -620,7 +622,7 @@ esxVMX_AbsolutePathToDatastoreRelatedPath(virConnectPtr conn,
|
|||||||
|
|
||||||
datastoreName = dynamicProperty->val->string;
|
datastoreName = dynamicProperty->val->string;
|
||||||
break;
|
break;
|
||||||
} else if (STREQ(dynamicProperty->name, "info.url")) {
|
} else if (STREQ(dynamicProperty->name, "summary.url")) {
|
||||||
/* Ignore it */
|
/* Ignore it */
|
||||||
} else {
|
} else {
|
||||||
VIR_WARN("Unexpected '%s' property", dynamicProperty->name);
|
VIR_WARN("Unexpected '%s' property", dynamicProperty->name);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user