[libvirt] [PATCH 23/41] conf: Introduce virCPUDefCopyWithoutModel

John Ferlan jferlan at redhat.com
Tue Aug 30 14:23:10 UTC 2016



On 08/12/2016 09:33 AM, Jiri Denemark wrote:
> Useful for copying a CPU definition without model related parts (i.e.,
> without model name, feature list, vendor).
> 
> Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
> ---
>  src/conf/cpu_conf.c      | 16 +++++++++++++++-
>  src/conf/cpu_conf.h      |  3 +++
>  src/libvirt_private.syms |  1 +
>  3 files changed, 19 insertions(+), 1 deletion(-)
> '

suggestion - how about "virCPUDefSparseCopy" ?  Especially since nothing
that requires a VIR_STRDUP is copied (e.g. vendor, vendor_id, features).

> diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
> index b71528e..c6e847a 100644
> --- a/src/conf/cpu_conf.c
> +++ b/src/conf/cpu_conf.c
> @@ -114,8 +114,9 @@ virCPUDefCopyModel(virCPUDefPtr dst,
>      return 0;
>  }
>  
> +
>  virCPUDefPtr
> -virCPUDefCopy(const virCPUDef *cpu)
> +virCPUDefCopyWithoutModel(const virCPUDef *cpu)
>  {
>      virCPUDefPtr copy;
>  
> @@ -131,6 +132,18 @@ virCPUDefCopy(const virCPUDef *cpu)
>      copy->threads = cpu->threads;
>      copy->arch = cpu->arch;
>  
> +    return copy;
> +}
> +
> +
> +virCPUDefPtr
> +virCPUDefCopy(const virCPUDef *cpu)
> +{
> +    virCPUDefPtr copy;
> +
> +    if (!(copy = virCPUDefCopyWithoutModel(cpu)))
> +        return NULL;
> +
>      if (virCPUDefCopyModel(copy, cpu, false) < 0)
>          goto error;
>  
> @@ -141,6 +154,7 @@ virCPUDefCopy(const virCPUDef *cpu)
>      return NULL;
>  }
>  
> +
>  virCPUDefPtr
>  virCPUDefParseXML(xmlNodePtr node,
>                    xmlXPathContextPtr ctxt,
> diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h
> index 705ba6d..2bbab9e 100644
> --- a/src/conf/cpu_conf.h
> +++ b/src/conf/cpu_conf.h
> @@ -127,6 +127,9 @@ virCPUDefPtr
>  virCPUDefCopy(const virCPUDef *cpu);
>  
>  virCPUDefPtr
> +virCPUDefCopyWithoutModel(const virCPUDef *cpu);
> +
> +virCPUDefPtr
>  virCPUDefParseXML(xmlNodePtr node,
>                    xmlXPathContextPtr ctxt,
>                    virCPUType mode);
> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index 53d4e7f..26f5bc8 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -66,6 +66,7 @@ virCapabilitiesSetNetPrefix;
>  virCPUDefAddFeature;
>  virCPUDefCopy;
>  virCPUDefCopyModel;
> +virCPUDefCopyWithoutModel;
>  virCPUDefFormat;
>  virCPUDefFormatBuf;
>  virCPUDefFree;
> 




More information about the libvir-list mailing list