7a3408
From 9dcd200a892eb8880baff291e42a630252c15a3d Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <9dcd200a892eb8880baff291e42a630252c15a3d@dist-git>
7a3408
From: Andrea Bolognani <abologna@redhat.com>
7a3408
Date: Tue, 11 Aug 2015 17:16:02 +0200
7a3408
Subject: [PATCH] cpu: Use ppc64Compute() to implement ppc64DriverCompare()
7a3408
7a3408
This ensures comparison of two CPU definitions will be consistent
7a3408
regardless of the fact that it is performed using cpuCompare() or
7a3408
cpuGuestData(). The x86 driver uses the same exact code.
7a3408
7a3408
(cherry picked from commit d574094d309eee5fdfcea3de4f06aed154975d83)
7a3408
7a3408
Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1250977
7a3408
7a3408
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7a3408
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7a3408
---
7a3408
 src/cpu/cpu_ppc64.c | 22 ++++++++++++++--------
7a3408
 1 file changed, 14 insertions(+), 8 deletions(-)
7a3408
7a3408
diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c
7a3408
index 0769956..efac739 100644
7a3408
--- a/src/cpu/cpu_ppc64.c
7a3408
+++ b/src/cpu/cpu_ppc64.c
7a3408
@@ -438,16 +438,22 @@ ppc64DriverCompare(virCPUDefPtr host,
7a3408
                    virCPUDefPtr cpu,
7a3408
                    bool failIncompatible)
7a3408
 {
7a3408
-    if ((cpu->arch == VIR_ARCH_NONE || host->arch == cpu->arch) &&
7a3408
-        STREQ(host->model, cpu->model))
7a3408
-        return VIR_CPU_COMPARE_IDENTICAL;
7a3408
+    virCPUCompareResult ret;
7a3408
+    char *message = NULL;
7a3408
 
7a3408
-    if (failIncompatible) {
7a3408
-        virReportError(VIR_ERR_CPU_INCOMPATIBLE, NULL);
7a3408
-        return VIR_CPU_COMPARE_ERROR;
7a3408
-    } else {
7a3408
-        return VIR_CPU_COMPARE_INCOMPATIBLE;
7a3408
+    ret = ppc64Compute(host, cpu, NULL, &message);
7a3408
+
7a3408
+    if (failIncompatible && ret == VIR_CPU_COMPARE_INCOMPATIBLE) {
7a3408
+        ret = VIR_CPU_COMPARE_ERROR;
7a3408
+        if (message) {
7a3408
+            virReportError(VIR_ERR_CPU_INCOMPATIBLE, "%s", message);
7a3408
+        } else {
7a3408
+            virReportError(VIR_ERR_CPU_INCOMPATIBLE, NULL);
7a3408
+        }
7a3408
     }
7a3408
+    VIR_FREE(message);
7a3408
+
7a3408
+    return ret;
7a3408
 }
7a3408
 
7a3408
 static int
7a3408
-- 
7a3408
2.5.0
7a3408