[libvirt] [PATCH] esx: Accept VIR_DOMAIN_AFFECT_CURRENT in addition to VIR_DOMAIN_AFFECT_LIVE

Eric Blake eblake at redhat.com
Mon May 20 16:19:40 UTC 2013


On 05/18/2013 04:02 PM, Matthias Bolte wrote:
> Basically autotranslate VIR_DOMAIN_AFFECT_CURRENT to VIR_DOMAIN_AFFECT_LIVE.
> 
> Modification impact is handled lax anyway. There is no distinction between
> a live and a stored config in the VMware world. A strict modification impact
> handling would require to check the virtual machine state each time and enforce
> VIR_DOMAIN_AFFECT_LIVE-only for running and VIR_DOMAIN_AFFECT_CONFIG-only
> for inactive domains. But that would be useless overhead.
> ---
>  src/esx/esx_driver.c |    7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
> index f53b9c4..85640ce 100644
> --- a/src/esx/esx_driver.c
> +++ b/src/esx/esx_driver.c
> @@ -2531,7 +2531,7 @@ esxDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus,
>      esxVI_TaskInfoState taskInfoState;
>      char *taskInfoErrorMessage = NULL;
>  
> -    if (flags != VIR_DOMAIN_AFFECT_LIVE) {
> +    if (flags != VIR_DOMAIN_AFFECT_CURRENT && flags != VIR_DOMAIN_AFFECT_LIVE) {
>          virReportError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags);
>          return -1;
>      }

Simpler to write this whole if as:

virCheckFlags(VIR_DOMAIN_AFFECT_LIVE, -1);

> @@ -2615,7 +2615,8 @@ esxDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
>      esxVI_ObjectContent *hostSystem = NULL;
>      esxVI_DynamicProperty *dynamicProperty = NULL;
>  
> -    if (flags != (VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) {
> +    if (flags != (VIR_DOMAIN_AFFECT_CURRENT | VIR_DOMAIN_VCPU_MAXIMUM) &&
> +        flags != (VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) {
>          virReportError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags);
>          return -1;
>      }

Might be simpler to write as:

virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_VCPU_MAXIMUM, -1);
if (!(flags & VIR_DOMAIN_VCPU_MAXIMUM))
    error...

> @@ -5222,7 +5223,7 @@ esxDomainGetMetadata(virDomainPtr domain, int type,
>      esxVI_String *propertyNameList = NULL;
>      esxVI_ObjectContent *virtualMachine = NULL;
>  
> -    if (flags != VIR_DOMAIN_AFFECT_LIVE) {
> +    if (flags != VIR_DOMAIN_AFFECT_CURRENT && flags != VIR_DOMAIN_AFFECT_LIVE) {
>          virReportError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags);
>          return NULL;
>      }

Simpler to write this whole if as:

virCheckFlags(VIR_DOMAIN_AFFECT_LIVE, -1);

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130520/cbd4e5a0/attachment-0001.sig>


More information about the libvir-list mailing list