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

2016-09-14 Thread Jiri Denemark
On Tue, Aug 30, 2016 at 10:23:10 -0400, John Ferlan wrote:
> 
> 
> 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 
> > ---
> >  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).

The API copies everything but the CPU model stuff (which can be copied
separately with virCPUDefCopyModel). I think virCPUDefCopyWithoutModel
is more explicit about what it does than virCPUDefSparseCopy or
something similarly generic.

Jirka

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


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

2016-08-30 Thread John Ferlan


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 
> ---
>  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@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


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

2016-08-12 Thread Jiri Denemark
Useful for copying a CPU definition without model related parts (i.e.,
without model name, feature list, vendor).

Signed-off-by: Jiri Denemark 
---
 src/conf/cpu_conf.c  | 16 +++-
 src/conf/cpu_conf.h  |  3 +++
 src/libvirt_private.syms |  1 +
 3 files changed, 19 insertions(+), 1 deletion(-)

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;
-- 
2.9.2

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