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

2018-08-13 Thread Matthias Bolte
2018-08-10 5:56 GMT+02:00 Marcos Paulo de Souza :
> 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 
> ---
>  src/esx/esx_driver.c | 36 +++-
>  1 file changed, 11 insertions(+), 25 deletions(-)


Before and after this commit the function did not properly handle the
VIR_DOMAIN_VCPU_MAXIMUM flag. If the flag is present then the function
should return the maximum vCPU Count. If the flag is absent then it
should return the current vCPU count.

-- 
Matthias Bolte
http://photron.blogspot.com

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


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

2018-08-09 Thread Marcos Paulo de Souza
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 
---
 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(,
-   "capability.maxSupportedVcpus") < 0 ||
-esxVI_LookupHostSystemProperties(priv->primary, propertyNameList,
- ) < 0) {
+   "config.hardware.numCPU\0") < 0 ||
+esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
+ propertyNameList, ,
+ esxVI_Occurrence_RequiredItem) < 0 ||
+   esxVI_GetInt(virtualMachine, "config.hardware.numCPU",
+  , 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();
-esxVI_ObjectContent_Free();
+esxVI_ObjectContent_Free();
+esxVI_Int_Free();
 
 return priv->maxVcpus;
 }
-- 
2.17.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list