The function moves CPU model related parts from one CPU definition to
another. It can be used to avoid unnecessary copies from a temporary CPU
definitions which will be freed anyway.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
Notes:
Version 2:
- s/virCPUDefMoveModel/virCPUDefStealModel/
src/conf/cpu_conf.c | 17 +++++++++++++++++
src/conf/cpu_conf.h | 4 ++++
src/libvirt_private.syms | 1 +
3 files changed, 22 insertions(+)
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index c6e847a..2e78b76 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -115,6 +115,23 @@ virCPUDefCopyModel(virCPUDefPtr dst,
}
+void
+virCPUDefStealModel(virCPUDefPtr dst,
+ virCPUDefPtr src)
+{
+ virCPUDefFreeModel(dst);
+
+ VIR_STEAL_PTR(dst->model, src->model);
+ VIR_STEAL_PTR(dst->vendor, src->vendor);
+ VIR_STEAL_PTR(dst->vendor_id, src->vendor_id);
+ VIR_STEAL_PTR(dst->features, src->features);
+ dst->nfeatures_max = src->nfeatures_max;
+ src->nfeatures_max = 0;
+ dst->nfeatures = src->nfeatures;
+ src->nfeatures = 0;
+}
+
+
virCPUDefPtr
virCPUDefCopyWithoutModel(const virCPUDef *cpu)
{
diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h
index 2bbab9e..a5dd208 100644
--- a/src/conf/cpu_conf.h
+++ b/src/conf/cpu_conf.h
@@ -123,6 +123,10 @@ virCPUDefCopyModel(virCPUDefPtr dst,
const virCPUDef *src,
bool resetPolicy);
+void
+virCPUDefStealModel(virCPUDefPtr dst,
+ virCPUDefPtr src);
+
virCPUDefPtr
virCPUDefCopy(const virCPUDef *cpu);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index d4ae5af..adf330a 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -72,6 +72,7 @@ virCPUDefFormatBuf;
virCPUDefFree;
virCPUDefFreeModel;
virCPUDefParseXML;
+virCPUDefStealModel;
virCPUDefUpdateFeature;
virCPUModeTypeToString;
--
2.10.0