[libvirt] [PATCH v2 12/30] cpu_x86: Add x86ModelCopySignatures helper

Jiri Denemark posted 30 patches 6 years, 11 months ago
[libvirt] [PATCH v2 12/30] cpu_x86: Add x86ModelCopySignatures helper
Posted by Jiri Denemark 6 years, 11 months ago
Introduce a helper for copying CPU signature between two CPU models.

It's not very useful until the way we store signatures is changed in the
next patch.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---

Notes:
    Version 2:
    - separated from 11/26 cpu_x86: Allow multiple signatures for a CPU model

 src/cpu/cpu_x86.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 4dd10fb561..0be1b12cdb 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -979,6 +979,16 @@ x86ModelFree(virCPUx86ModelPtr model)
 }
 
 
+static int
+x86ModelCopySignatures(virCPUx86ModelPtr dst,
+                       virCPUx86ModelPtr src)
+{
+    dst->signature = src->signature;
+
+    return 0;
+}
+
+
 static virCPUx86ModelPtr
 x86ModelCopy(virCPUx86ModelPtr model)
 {
@@ -986,13 +996,13 @@ x86ModelCopy(virCPUx86ModelPtr model)
 
     if (VIR_ALLOC(copy) < 0 ||
         VIR_STRDUP(copy->name, model->name) < 0 ||
+        x86ModelCopySignatures(copy, model) < 0 ||
         x86DataCopy(&copy->data, &model->data) < 0) {
         x86ModelFree(copy);
         return NULL;
     }
 
     copy->vendor = model->vendor;
-    copy->signature = model->signature;
 
     return copy;
 }
@@ -1178,8 +1188,8 @@ x86ModelParseAncestor(virCPUx86ModelPtr model,
     }
 
     model->vendor = ancestor->vendor;
-    model->signature = ancestor->signature;
-    if (x86DataCopy(&model->data, &ancestor->data) < 0)
+    if (x86ModelCopySignatures(model, ancestor) < 0 ||
+        x86DataCopy(&model->data, &ancestor->data) < 0)
         return -1;
 
     return 0;
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 12/30] cpu_x86: Add x86ModelCopySignatures helper
Posted by Ján Tomko 6 years, 11 months ago
On Tue, Mar 05, 2019 at 10:40:28AM +0100, Jiri Denemark wrote:
>Introduce a helper for copying CPU signature between two CPU models.
>
>It's not very useful until the way we store signatures is changed in the
>next patch.
>
>Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
>---
>
>Notes:
>    Version 2:
>    - separated from 11/26 cpu_x86: Allow multiple signatures for a CPU model
>
> src/cpu/cpu_x86.c | 16 +++++++++++++---
> 1 file changed, 13 insertions(+), 3 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

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