Before this patch, esxDomainGetVcpusFlags was not checking the flags
argument. Current, get and set vcpus was failing in ESX since it was
checking for "maxSupportedVcpus", and this configuration can be ommited
by ESXi[1]. Now, if VIR_DOMAIN_VCPU_MAXIMUM is specified in flags argument
esxDomainGetVcpusFlags the maximum number of vcpus allowed for that VM.
Otherwise, the current number of vcpus is returned.
With this patch calls to virDomainSetVcpus, virDomainGetMaxVcpus and
virDomainGetVcpusFlags to return successfull again.
[
1]:https://pubs.vmware.com/vi-sdk/visdk250/ReferenceGuide/vim.host.Capabi...
Signed-off-by: Marcos Paulo de Souza <marcos.souza.org(a)gmail.com>
---
Changes from v1:
* Now we only have one patch instead of two
* Change esxDomainGetVcpusFlags in order to check the flags argument, instead
* of changing esxDomainGetMaxVcpus.
src/esx/esx_driver.c | 52 ++++++++++++++++++++++++--------------------
1 file changed, 28 insertions(+), 24 deletions(-)
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index c2154799fa..a1ba889326 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -2547,45 +2547,49 @@ esxDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
{
esxPrivate *priv = domain->conn->privateData;
esxVI_String *propertyNameList = NULL;
- esxVI_ObjectContent *hostSystem = NULL;
- esxVI_DynamicProperty *dynamicProperty = NULL;
+ esxVI_ObjectContent *obj = NULL;
+ esxVI_Int *vcpus = NULL;
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
VIR_DOMAIN_VCPU_MAXIMUM, -1);
- if (priv->maxVcpus > 0)
- return priv->maxVcpus;
-
priv->maxVcpus = -1;
if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
- if (esxVI_String_AppendValueToList(&propertyNameList,
- "capability.maxSupportedVcpus") < 0
||
- esxVI_LookupHostSystemProperties(priv->primary, propertyNameList,
- &hostSystem) < 0) {
- goto cleanup;
- }
- for (dynamicProperty = hostSystem->propSet; dynamicProperty;
- dynamicProperty = dynamicProperty->_next) {
- if (STREQ(dynamicProperty->name, "capability.maxSupportedVcpus")) {
- if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_Int) < 0) {
- goto cleanup;
- }
+ if (flags & VIR_DOMAIN_VCPU_MAXIMUM) {
+ if (esxVI_String_AppendValueToList(&propertyNameList,
+
"capability.maxHostSupportedVcpus\0"
+ "capability.maxSupportedVcpus") <
0 ||
+ esxVI_LookupHostSystemProperties(priv->primary,
+ propertyNameList, &obj) < 0 ||
+ esxVI_GetInt(obj, "capability.maxSupportedVcpus", &vcpus,
+ esxVI_Occurrence_OptionalItem) < 0)
+ goto cleanup;
- priv->maxVcpus = dynamicProperty->val->int32;
- break;
- } else {
- VIR_WARN("Unexpected '%s' property",
dynamicProperty->name);
- }
+ if (!vcpus && esxVI_GetInt(obj,
"capability.maxHostSupportedVcpus",
+ &vcpus, esxVI_Occurrence_RequiredItem) < 0)
+ goto cleanup;
+
+ } else {
+ if (esxVI_String_AppendValueToList(&propertyNameList,
+ "config.hardware.numCPU\0") < 0
||
+ esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
+ propertyNameList, &obj,
+ esxVI_Occurrence_RequiredItem) < 0 ||
+ esxVI_GetInt(obj, "config.hardware.numCPU", &vcpus,
+ esxVI_Occurrence_RequiredItem) < 0)
+ goto cleanup;
}
+ priv->maxVcpus = vcpus->value;
+
cleanup:
esxVI_String_Free(&propertyNameList);
- esxVI_ObjectContent_Free(&hostSystem);
+ esxVI_ObjectContent_Free(&obj);
+ esxVI_Int_Free(&vcpus);
return priv->maxVcpus;
}
--
2.17.1