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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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@xxxxxxxxxx>
> ---
>  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;
> 

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]