[libvirt] [PATCH 15/24] conf: numa: Always allocate the NUMA config

John Ferlan jferlan at redhat.com
Thu Feb 19 23:16:01 UTC 2015



On 02/16/2015 01:52 PM, Peter Krempa wrote:
> Since our formatter now handles well if the config is allocated and not
> filled and the parser always frees the definition before parsing we can
> safely always-allocate the NUMA config.
> 
> This will help in later patches as the parser will be refactored to just
> fill the data.
> ---
>  src/conf/domain_conf.c   | 10 +++++++++-
>  src/conf/numa_conf.c     | 11 +++++++++++
>  src/conf/numa_conf.h     |  1 +
>  src/libvirt_private.syms |  1 +
>  4 files changed, 22 insertions(+), 1 deletion(-)
> 

Hmm... well this one was interesting, but it seems from the following
patch and the number of places that call into the numa* API's that one
was pretty much allocated all the time before, right?

It wasn't clear and I'm inclined to suggest this and the following patch
be combined just to make it clearer...

ACK -

John
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 6dea109..83c5fd9 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -2319,9 +2319,17 @@ virDomainDefNew(void)
>  {
>      virDomainDefPtr ret;
> 
> -    ignore_value(VIR_ALLOC(ret));
> +    if (VIR_ALLOC(ret) < 0)
> +        return NULL;
> +
> +    if (!(ret->numa = virDomainNumaNew()))
> +        goto error;
> 
>      return ret;
> +
> + error:
> +    virDomainDefFree(ret);
> +    return NULL;
>  }
> 
> 
> diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c
> index 359bdff..2a5fb3c 100644
> --- a/src/conf/numa_conf.c
> +++ b/src/conf/numa_conf.c
> @@ -827,3 +827,14 @@ virDomainNumaGetCPUCountTotal(virCPUDefPtr numa)
> 
>      return ret;
>  }
> +
> +
> +virDomainNumaPtr
> +virDomainNumaNew(void)
> +{
> +    virDomainNumaPtr ret = NULL;
> +
> +    ignore_value(VIR_ALLOC(ret));
> +
> +    return ret;
> +}
> diff --git a/src/conf/numa_conf.h b/src/conf/numa_conf.h
> index fa6b89b..e69489d 100644
> --- a/src/conf/numa_conf.h
> +++ b/src/conf/numa_conf.h
> @@ -56,6 +56,7 @@ typedef enum {
> 
>  VIR_ENUM_DECL(virNumaMemAccess)
> 
> +virDomainNumaPtr virDomainNumaNew(void);
>  void virDomainNumaFree(virDomainNumaPtr numa);
> 
>  /*
> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index 4ba2142..6a746cf 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -629,6 +629,7 @@ virNodeDeviceObjUnlock;
>  # conf/numa_conf.h
>  virDomainNumaEquals;
>  virDomainNumaFree;
> +virDomainNumaNew;
>  virDomainNumatuneFormatNodeset;
>  virDomainNumatuneFormatXML;
>  virDomainNumatuneGetMode;
> 




More information about the libvir-list mailing list