[PATCH 24/41] conf: Introduce virCPUDefMoveModel

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

 



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@xxxxxxxxxx>
---
 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..13f3da3 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -115,6 +115,23 @@ virCPUDefCopyModel(virCPUDefPtr dst,
 }
 
 
+void
+virCPUDefMoveModel(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..d866a89 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
+virCPUDefMoveModel(virCPUDefPtr dst,
+                   virCPUDefPtr src);
+
 virCPUDefPtr
 virCPUDefCopy(const virCPUDef *cpu);
 
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 26f5bc8..1cfebd5 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -71,6 +71,7 @@ virCPUDefFormat;
 virCPUDefFormatBuf;
 virCPUDefFree;
 virCPUDefFreeModel;
+virCPUDefMoveModel;
 virCPUDefParseXML;
 virCPUDefUpdateFeature;
 virCPUModeTypeToString;
-- 
2.9.2

--
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]