bcddb9
From 53cf8a5c5e91132ac3d12bbe2e611594272bb30a Mon Sep 17 00:00:00 2001
bcddb9
Message-Id: <53cf8a5c5e91132ac3d12bbe2e611594272bb30a@dist-git>
bcddb9
From: Jiri Denemark <jdenemar@redhat.com>
bcddb9
Date: Mon, 4 Mar 2019 16:18:42 +0100
bcddb9
Subject: [PATCH] cpu_x86: Add x86ModelCopySignatures helper
bcddb9
MIME-Version: 1.0
bcddb9
Content-Type: text/plain; charset=UTF-8
bcddb9
Content-Transfer-Encoding: 8bit
bcddb9
bcddb9
Introduce a helper for copying CPU signature between two CPU models.
bcddb9
bcddb9
It's not very useful until the way we store signatures is changed in the
bcddb9
next patch.
bcddb9
bcddb9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
bcddb9
Reviewed-by: Ján Tomko <jtomko@redhat.com>
bcddb9
(cherry picked from commit 2254c1cfb854dfc52f3b4bfdfca2bd995b0a163c)
bcddb9
bcddb9
https://bugzilla.redhat.com/show_bug.cgi?id=1558558
bcddb9
https://bugzilla.redhat.com/show_bug.cgi?id=1687515
bcddb9
bcddb9
Conflicts:
bcddb9
	src/cpu/cpu_x86.c
bcddb9
            - other patches separating parts of x86ModelParse into
bcddb9
              smaller functions were not backported due to conflicts
bcddb9
              with older refactoring which is missing in RHEL-7
bcddb9
bcddb9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
bcddb9
Reviewed-by: Ján Tomko <jtomko@redhat.com>
bcddb9
---
bcddb9
 src/cpu/cpu_x86.c | 16 +++++++++++++---
bcddb9
 1 file changed, 13 insertions(+), 3 deletions(-)
bcddb9
bcddb9
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
bcddb9
index 668e8aa3f0..e54a3986a1 100644
bcddb9
--- a/src/cpu/cpu_x86.c
bcddb9
+++ b/src/cpu/cpu_x86.c
bcddb9
@@ -1013,6 +1013,16 @@ x86ModelFree(virCPUx86ModelPtr model)
bcddb9
 }
bcddb9
 
bcddb9
 
bcddb9
+static int
bcddb9
+x86ModelCopySignatures(virCPUx86ModelPtr dst,
bcddb9
+                       virCPUx86ModelPtr src)
bcddb9
+{
bcddb9
+    dst->signature = src->signature;
bcddb9
+
bcddb9
+    return 0;
bcddb9
+}
bcddb9
+
bcddb9
+
bcddb9
 static virCPUx86ModelPtr
bcddb9
 x86ModelCopy(virCPUx86ModelPtr model)
bcddb9
 {
bcddb9
@@ -1020,13 +1030,13 @@ x86ModelCopy(virCPUx86ModelPtr model)
bcddb9
 
bcddb9
     if (VIR_ALLOC(copy) < 0 ||
bcddb9
         VIR_STRDUP(copy->name, model->name) < 0 ||
bcddb9
+        x86ModelCopySignatures(copy, model) < 0 ||
bcddb9
         x86DataCopy(&copy->data, &model->data) < 0) {
bcddb9
         x86ModelFree(copy);
bcddb9
         return NULL;
bcddb9
     }
bcddb9
 
bcddb9
     copy->vendor = model->vendor;
bcddb9
-    copy->signature = model->signature;
bcddb9
 
bcddb9
     return copy;
bcddb9
 }
bcddb9
@@ -1260,8 +1270,8 @@ x86ModelParse(xmlXPathContextPtr ctxt,
bcddb9
         VIR_FREE(name);
bcddb9
 
bcddb9
         model->vendor = ancestor->vendor;
bcddb9
-        model->signature = ancestor->signature;
bcddb9
-        if (x86DataCopy(&model->data, &ancestor->data) < 0)
bcddb9
+        if (x86ModelCopySignatures(model, ancestor) < 0 ||
bcddb9
+            x86DataCopy(&model->data, &ancestor->data) < 0)
bcddb9
             goto error;
bcddb9
     }
bcddb9
 
bcddb9
-- 
bcddb9
2.21.0
bcddb9