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

Re: [libvirt] [PATCH 2/2] esx:Fix esxDomainGetMaxVcpus to return correct vcpus



2018-08-10 5:56 GMT+02:00 Marcos Paulo de Souza <marcos souza org gmail com>:
> Before this change, esxDomainGetMaxVcpus returned -1, which in turn
> fails in libvirt. This commit reimplements esxDomainGetMaxVcpus instead
> of calling esxDomainGetVcpusFlags. The implementation checks for
> capability.maxSupportedVcpus, but as this one can be ommited in ESXi, we
> also check for capability.maxHostSupportedVcpus. With this change,
> virDomainSetVcpus, virDomainGetMaxVcpus and virDomainGetVcpusFlags and
> returning correct values.
>
> Signed-off-by: Marcos Paulo de Souza <marcos souza org gmail com>
> ---
>  src/esx/esx_driver.c | 36 ++++++++++++++++++++++++++++++++++--
>  1 file changed, 34 insertions(+), 2 deletions(-)
>
> diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
> index d5e8a7b4eb..3169314fa4 100644
> --- a/src/esx/esx_driver.c
> +++ b/src/esx/esx_driver.c
> @@ -2581,8 +2581,40 @@ esxDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
>  static int
>  esxDomainGetMaxVcpus(virDomainPtr domain)
>  {
> -    return esxDomainGetVcpusFlags(domain, (VIR_DOMAIN_AFFECT_LIVE |
> -                                           VIR_DOMAIN_VCPU_MAXIMUM));
> +    esxPrivate *priv = domain->conn->privateData;
> +    esxVI_String *propertyNameList = NULL;
> +    esxVI_ObjectContent *hostSystem = NULL;
> +    esxVI_Int *supportedVcpus = NULL;
> +    esxVI_Int *hostVcpus = NULL;
> +
> +    if (esxVI_EnsureSession(priv->primary) < 0)
> +        return -1;
> +
> +    priv->maxVcpus = -1;
> +
> +    if (esxVI_String_AppendValueToList(&propertyNameList,
> +                                           "capability.maxHostSupportedVcpus\0"
> +                                           "capability.maxSupportedVcpus"
> +                                          ) < 0 ||
> +        esxVI_LookupHostSystemProperties(priv->primary, propertyNameList,
> +                                          &hostSystem) < 0 ||
> +        esxVI_GetInt(hostSystem, "capability.maxHostSupportedVcpus",
> +                      &hostVcpus, esxVI_Occurrence_RequiredItem) < 0 ||
> +        esxVI_GetInt(hostSystem, "capability.maxSupportedVcpus",
> +                      &supportedVcpus, esxVI_Occurrence_OptionalItem) < 0)
> +
> +        goto cleanup;
> +
> +    /* as maxSupportedVcpus is optional, check also for maxHostSupportedVcpus */
> +    priv->maxVcpus = supportedVcpus ? supportedVcpus->value : hostVcpus->value;
> +
> + cleanup:
> +    esxVI_String_Free(&propertyNameList);
> +    esxVI_ObjectContent_Free(&hostSystem);
> +    esxVI_Int_Free(&supportedVcpus);
> +    esxVI_Int_Free(&hostVcpus);
> +
> +    return priv->maxVcpus;
>  }

This is the wrong way to fix the situation. The correct way ist to
make esxDomainGetVcpusFlags handle the VIR_DOMAIN_VCPU_MAXIMUM flag
properly.

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


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