[RFC REPOST 1/7] conf: extract appid validation to virDomainDefResourceAppidValidate

Michal Prívozník mprivozn at redhat.com
Fri Sep 10 11:49:24 UTC 2021


On 9/9/21 6:13 PM, Pavel Hrdina wrote:
> This will be needed by future patches adding appid API to allow changing
> it for running VMs.
> 
> Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
> ---
>  src/conf/domain_validate.c | 42 +++++++++++++++++++++++---------------
>  src/conf/domain_validate.h |  2 ++
>  src/libvirt_private.syms   |  1 +
>  3 files changed, 28 insertions(+), 17 deletions(-)
> 
> diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
> index 1bc62c364d..3ab864bbeb 100644
> --- a/src/conf/domain_validate.c
> +++ b/src/conf/domain_validate.c


> +    if (def->resource->appid)
> +        return virDomainDefResourceAppidValidate(def->resource->appid);
>  

I'd write this as:

  if (def->resource->appid &&
      virDomainDefResourceAppidValidate() < 0)
      return -1;

so that this line doesn't have to be changed when something new is added
to this function. Moreover, you can have
virDomainDefResourceAppidValidate() to be NOP if appid == NULL and write
this check as:

  if (virDomainDefResourceAppidValidate() < 0)
    return -1;

Michal




More information about the libvir-list mailing list