]> xenbits.xensource.com Git - libvirt.git/commitdiff
ppc: Enable starting of Qemu VMs on ppc host
authorStefan Berger <stefanb@us.ibm.com>
Thu, 14 Apr 2011 18:50:22 +0000 (14:50 -0400)
committerStefan Berger <stefanb@us.ibm.com>
Thu, 14 Apr 2011 18:50:22 +0000 (14:50 -0400)
Due to differences in /proc/cpuinfo the parsing of the cpu data is
different between architectures. On PPC /proc/cpuinfo looks like this:

[original formatting with tabs]

processor    : 0
cpu          : PPC970MP, altivec supported
clock        : 2297.700000MHz
revision     : 1.1 (pvr 0044 0101)

processor    : 1
cpu          : PPC970MP, altivec supported
clock        : 2297.700000MHz
revision     : 1.1 (pvr 0044 0101)

[..]

timebase     : 14318000
platform     : pSeries
model        : IBM,8844-AC1
machine      : CHRP IBM,8844-AC1

The patch adapts the parsing of the data found in /proc/cpuinfo.

/sys/devices/system/cpu/cpuX/topology/physical_package_id also
always returns -1. Check for it on ppc and make it '0' if found negative.

src/nodeinfo.c

index 5d40aca8c9edaead91dc939e13c9678159eeed2b..8b816b509ed3483c0d4bc8fd95e9a85e9727839a 100644 (file)
@@ -163,7 +163,14 @@ cleanup:
 
 static int parse_socket(unsigned int cpu)
 {
-    return get_cpu_value(cpu, "topology/physical_package_id", false);
+    int ret = get_cpu_value(cpu, "topology/physical_package_id", false);
+#if defined(__powerpc__) || \
+    defined(__powerpc64__)
+    /* ppc has -1 */
+    if (ret < 0)
+        ret = 0;
+#endif
+    return ret;
 }
 
 int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
@@ -206,6 +213,9 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
                 return -1;
             }
             nodeinfo->cpus++;
+#if defined(__x86_64__) || \
+    defined(__amd64__)  || \
+    defined(__i386__)
         } else if (STRPREFIX(buf, "cpu MHz")) {
             char *p;
             unsigned int ui;
@@ -237,6 +247,27 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
                 && id > nodeinfo->cores)
                 nodeinfo->cores = id;
         }
+#elif defined(__powerpc__) || \
+      defined(__powerpc64__)
+        } else if (STRPREFIX(buf, "clock")) {
+            char *p;
+            unsigned int ui;
+            buf += 5;
+            while (*buf && c_isspace(*buf))
+                buf++;
+            if (*buf != ':' || !buf[1]) {
+                nodeReportError(VIR_ERR_INTERNAL_ERROR,
+                                "%s", _("parsing cpuinfo cpu MHz"));
+                return -1;
+            }
+            if (virStrToLong_ui(buf+1, &p, 10, &ui) == 0
+                /* Accept trailing fractional part.  */
+                && (*p == '\0' || *p == '.' || c_isspace(*p)))
+                nodeinfo->mhz = ui;
+        }
+#else
+# warning Parser for /proc/cpuinfo needs to be adapted for your architecture
+#endif
     }
 
     if (!nodeinfo->cpus) {