]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
cpu: Move check for NULL CPU model inside the driver
authorAndrea Bolognani <abologna@redhat.com>
Fri, 14 Aug 2015 14:04:18 +0000 (16:04 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Fri, 21 Aug 2015 22:42:38 +0000 (15:42 -0700)
While the check is appropriate for eg. the x86 and generic drivers,
there are some valid ppc64 guest configurations where the CPU
model is supposed to be NULL.

Moving this check from the generic code to the drivers makes it
possible to accomodate both use cases.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1251927

src/cpu/cpu.c
src/cpu/cpu_generic.c
src/cpu/cpu_ppc64.c
src/cpu/cpu_x86.c

index 731df26ea764f66613d8a1cb68002e666faec52c..1952b53ecf1b1b299e3929644960f553f34e75e6 100644 (file)
@@ -142,12 +142,6 @@ cpuCompare(virCPUDefPtr host,
 
     VIR_DEBUG("host=%p, cpu=%p", host, cpu);
 
-    if (!cpu->model) {
-        virReportError(VIR_ERR_INVALID_ARG, "%s",
-                       _("no guest CPU model specified"));
-        return VIR_CPU_COMPARE_ERROR;
-    }
-
     if ((driver = cpuGetSubDriver(host->arch)) == NULL)
         return VIR_CPU_COMPARE_ERROR;
 
@@ -376,12 +370,6 @@ cpuGuestData(virCPUDefPtr host,
 
     VIR_DEBUG("host=%p, guest=%p, data=%p, msg=%p", host, guest, data, msg);
 
-    if (!guest->model) {
-        virReportError(VIR_ERR_INVALID_ARG, "%s",
-                       _("no guest CPU model specified"));
-        return VIR_CPU_COMPARE_ERROR;
-    }
-
     if ((driver = cpuGetSubDriver(host->arch)) == NULL)
         return VIR_CPU_COMPARE_ERROR;
 
index a9cde4ca3c612dd5cdaa65b7b445d35d165b1c8c..f26a62dc63b1c4344a99ecdf2a08373a89085c26 100644 (file)
@@ -65,6 +65,12 @@ genericCompare(virCPUDefPtr host,
     size_t i;
     unsigned int reqfeatures;
 
+    if (!cpu->model) {
+        virReportError(VIR_ERR_INVALID_ARG, "%s",
+                       _("no guest CPU model specified"));
+        goto cleanup;
+    }
+
     if ((cpu->arch != VIR_ARCH_NONE &&
          host->arch != cpu->arch) ||
         STRNEQ(host->model, cpu->model)) {
index a72cc32ae4327cf6934d9d4ba3cd83e0ba60854b..364c8ed082093263b96661f7329981227b3e0b99 100644 (file)
@@ -71,7 +71,8 @@ ppc64ConvertLegacyCPUDef(const virCPUDef *legacy)
     if (!(cpu = virCPUDefCopy(legacy)))
         goto out;
 
-    if (!(STREQ(cpu->model, "POWER7_v2.1") ||
+    if (!cpu->model ||
+        !(STREQ(cpu->model, "POWER7_v2.1") ||
           STREQ(cpu->model, "POWER7_v2.3") ||
           STREQ(cpu->model, "POWER7+_v2.1") ||
           STREQ(cpu->model, "POWER8_v1.0"))) {
index f5f769730e279dc72191660c2cc4f303a50e8ae4..90949f68cce125ce925e7bd422b62ce07e2514f7 100644 (file)
@@ -1371,6 +1371,12 @@ x86Compute(virCPUDefPtr host,
     virArch arch;
     size_t i;
 
+    if (!cpu->model) {
+        virReportError(VIR_ERR_INVALID_ARG, "%s",
+                       _("no guest CPU model specified"));
+        return VIR_CPU_COMPARE_ERROR;
+    }
+
     if (cpu->arch != VIR_ARCH_NONE) {
         bool found = false;