---
src/conf/cpu_conf.c | 37 +++++++++++++++++++++++++++++++++++++
src/conf/cpu_conf.h | 3 +++
src/libvirt_private.syms | 1 +
3 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index 612e376..cf91930 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -67,6 +67,43 @@ virCPUDefFree(virCPUDefPtr def)
}
+virCPUDefPtr
+virCPUDefCopy(const virCPUDefPtr cpu)
+{
+ virCPUDefPtr copy;
+ unsigned int i;
+
+ if (!cpu)
+ return NULL;
+
+ if (VIR_ALLOC(copy) < 0
+ || (cpu->arch && !(copy->arch = strdup(cpu->arch)))
+ || (cpu->model && !(copy->model = strdup(cpu->model)))
+ || VIR_ALLOC_N(copy->features, cpu->nfeatures) < 0)
+ goto no_memory;
+
+ copy->type = cpu->type;
+ copy->match = cpu->match;
+ copy->sockets = cpu->sockets;
+ copy->cores = cpu->cores;
+ copy->threads = cpu->threads;
+ copy->nfeatures = cpu->nfeatures;
+
+ for (i = 0; i < copy->nfeatures; i++) {
+ copy->features[i].policy = cpu->features[i].policy;
+ if (!(copy->features[i].name = strdup(cpu->features[i].name)))
+ goto no_memory;
+ }
+
+ return copy;
+
+no_memory:
+ virReportOOMError();
+ virCPUDefFree(copy);
+ return NULL;
+}
+
+
#ifndef PROXY
virCPUDefPtr
virCPUDefParseXML(const xmlNodePtr node,
diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h
index bb8a844..a30991d 100644
--- a/src/conf/cpu_conf.h
+++ b/src/conf/cpu_conf.h
@@ -83,6 +83,9 @@ struct _virCPUDef {
void
virCPUDefFree(virCPUDefPtr def);
+virCPUDefPtr
+virCPUDefCopy(const virCPUDefPtr cpu);
+
# ifndef PROXY
virCPUDefPtr
virCPUDefParseXML(const xmlNodePtr node,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 9c16a6d..0ae143c 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -90,6 +90,7 @@ virCPUDefParseXML;
virCPUDefFormat;
virCPUDefFormatBuf;
virCPUDefAddFeature;
+virCPUDefCopy;
# datatypes.h
--
1.7.0.3