[libvirt] [PATCH 2/6] use new macro helpers to check exclusive flags

Peter Krempa pkrempa at redhat.com
Tue Mar 24 16:22:44 UTC 2015


On Fri, Mar 20, 2015 at 15:39:00 +0100, Pavel Hrdina wrote:
> Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
> ---
>  src/libvirt-domain-snapshot.c      |  45 ++----
>  src/libvirt-domain.c               | 288 +++++++++++--------------------------
>  src/qemu/qemu_driver.c             |   9 +-
>  src/storage/storage_backend_disk.c |  10 +-
>  src/storage/storage_backend_fs.c   |  11 +-
>  5 files changed, 106 insertions(+), 257 deletions(-)
> 

> @@ -7340,14 +7252,21 @@ virDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus,
>      virCheckDomainReturn(domain, -1);
>      virCheckReadOnlyGoto(domain->conn->flags, error);
>  
> -    if (flags & VIR_DOMAIN_VCPU_GUEST &&
> -        flags & VIR_DOMAIN_VCPU_MAXIMUM) {
> -        virReportInvalidArg(flags,
> -                            _("flags 'VIR_DOMAIN_VCPU_MAXIMUM' and "
> -                              "'VIR_DOMAIN_VCPU_GUEST' in '%s' are mutually "
> -                              "exclusive"), __FUNCTION__);
> -        goto error;
> -    }
> +    VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_AFFECT_CURRENT,
> +                             VIR_DOMAIN_AFFECT_LIVE,
> +                             error);
> +    VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_AFFECT_CURRENT,
> +                             VIR_DOMAIN_AFFECT_CONFIG,
> +                             error);
> +    VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_VCPU_GUEST,
> +                             VIR_DOMAIN_AFFECT_CONFIG,
> +                             error);
> +    VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_VCPU_GUEST,
> +                             VIR_DOMAIN_VCPU_MAXIMUM,
> +                             error);
> +    VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_AFFECT_CONFIG,
> +                             VIR_DOMAIN_VCPU_MAXIMUM,
> +                             error);

By the way, this check here is not enough to check that MAXIMUM is not
actually used with _AFFECT_LIVE.

If you use VIR_DOMAIN_AFFECT_CURRENT and the guest is online, this check
is bypassed as the state of the domain is not known at this point.

This unfortunately needs to be checked after the
virDomainLiveConfigHelperMethod in the actual code.

>  
>      virCheckNonZeroArgGoto(nvcpus, error);
>  

Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150324/72b8834b/attachment-0001.sig>


More information about the libvir-list mailing list