[PATCH 1/2] esx: Make esxDomainGetVcpusFlags return vcpus again

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

 



Before this patch, esxDomainGetVcpusFlags was returning -1 since
"maxSupportedVcpus" can be NULL in ESXi[1]. In order to make it work,
replicate the same behavior than esxDomainGetInfo that used
config.hardware.numCPU to return the correct number of vcpus of a VM.

This patch, together with the next one, makes the calls
virDomainSetVcpus, virDomainGetMaxVcpus and virDomainGetVcpusFlags to
return successfull again.

[1]:https://pubs.vmware.com/vi-sdk/visdk250/ReferenceGuide/vim.host.Capability.html

Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@xxxxxxxxx>
---
 src/esx/esx_driver.c | 36 +++++++++++-------------------------
 1 file changed, 11 insertions(+), 25 deletions(-)

diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index c2154799fa..d5e8a7b4eb 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -2547,45 +2547,31 @@ 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 *virtualMachine = 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) {
+                                           "config.hardware.numCPU\0") < 0 ||
+        esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
+                                         propertyNameList, &virtualMachine,
+                                         esxVI_Occurrence_RequiredItem) < 0 ||
+	esxVI_GetInt(virtualMachine, "config.hardware.numCPU",
+                      &vcpus, esxVI_Occurrence_RequiredItem) < 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;
-            }
-
-            priv->maxVcpus = dynamicProperty->val->int32;
-            break;
-        } else {
-            VIR_WARN("Unexpected '%s' property", dynamicProperty->name);
-        }
-    }
 
+    priv->maxVcpus = vcpus->value;
  cleanup:
     esxVI_String_Free(&propertyNameList);
-    esxVI_ObjectContent_Free(&hostSystem);
+    esxVI_ObjectContent_Free(&virtualMachine);
+    esxVI_Int_Free(&vcpus);
 
     return priv->maxVcpus;
 }
-- 
2.17.1

--
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