]> xenbits.xensource.com Git - libvirt.git/commitdiff
cpu: Use ppc64Compute() to implement ppc64DriverCompare()
authorAndrea Bolognani <abologna@redhat.com>
Fri, 7 Aug 2015 15:39:11 +0000 (17:39 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Tue, 11 Aug 2015 09:04:57 +0000 (11:04 +0200)
This ensures comparison of two CPU definitions will be consistent
regardless of the fact that it is performed using cpuCompare() or
cpuGuestData(). The x86 driver uses the same exact code.

src/cpu/cpu_ppc64.c

index 07699568a3733271dd86fa319a1c46e2dc3b52da..efac7396b23e18e32cd763e4c74f18e905dffc1c 100644 (file)
@@ -438,16 +438,22 @@ ppc64DriverCompare(virCPUDefPtr host,
                    virCPUDefPtr cpu,
                    bool failIncompatible)
 {
-    if ((cpu->arch == VIR_ARCH_NONE || host->arch == cpu->arch) &&
-        STREQ(host->model, cpu->model))
-        return VIR_CPU_COMPARE_IDENTICAL;
+    virCPUCompareResult ret;
+    char *message = NULL;
 
-    if (failIncompatible) {
-        virReportError(VIR_ERR_CPU_INCOMPATIBLE, NULL);
-        return VIR_CPU_COMPARE_ERROR;
-    } else {
-        return VIR_CPU_COMPARE_INCOMPATIBLE;
+    ret = ppc64Compute(host, cpu, NULL, &message);
+
+    if (failIncompatible && ret == VIR_CPU_COMPARE_INCOMPATIBLE) {
+        ret = VIR_CPU_COMPARE_ERROR;
+        if (message) {
+            virReportError(VIR_ERR_CPU_INCOMPATIBLE, "%s", message);
+        } else {
+            virReportError(VIR_ERR_CPU_INCOMPATIBLE, NULL);
+        }
     }
+    VIR_FREE(message);
+
+    return ret;
 }
 
 static int