]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: Don't report CPU frequency for ARM hosts
authorAndrea Bolognani <abologna@redhat.com>
Mon, 11 Dec 2017 15:09:20 +0000 (16:09 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Mon, 8 Jan 2018 13:22:53 +0000 (14:22 +0100)
Some ARM platforms, such as the original Raspberry Pi, report the
CPU frequency in the BogoMIPS field of /proc/cpuinfo, so libvirt
parsed that field and returned it through its API.

However, not only many more boards don't report any value there,
but several - including ARMv8-based server hardware, and even the
more recent Raspberry Pi 3 - use this field as originally intended:
to report the BogoMIPS value instead of the CPU frequency.

Since we have no way of detecting how the field is being used,
it's better to report no information at all rather than something
ludicrous like "your shiny 96-core aarch64 virtualization host's
CPUs are running at a whopping 100 MHz".

Partially-resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1206353

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/util/virhostcpu.c
tests/virhostcpudata/linux-aarch64-rhel74-moonshot.expected
tests/virhostcpudata/linux-armv6l-raspberrypi.expected

index f3ee3a1a58e9afc847cbb9ef21b673471c885911..5b46fab54535cad860dea1e12d917d36a4282e0d 100644 (file)
@@ -592,12 +592,14 @@ virHostCPUParseFrequency(FILE *cpuinfo,
     const char *prefix = NULL;
     char line[1024];
 
+    /* No sensible way to retrieve CPU frequency */
+    if (ARCH_IS_ARM(arch))
+        return 0;
+
     if (ARCH_IS_X86(arch))
         prefix = "cpu MHz";
     else if (ARCH_IS_PPC(arch))
         prefix = "clock";
-    else if (ARCH_IS_ARM(arch))
-        prefix = "BogoMIPS";
 
     if (!prefix) {
         VIR_WARN("%s is not supported by the %s parser",
index 24ff0ea0b07498669a01d1365001a0114b45b334..6776aa6c2db7aa431f03c6fc5b72e666492e74de 100644 (file)
@@ -1 +1 @@
-CPUs: 8/8, MHz: 100, Nodes: 1, Sockets: 1, Cores: 8, Threads: 1
+CPUs: 8/8, MHz: 0, Nodes: 1, Sockets: 1, Cores: 8, Threads: 1
index 146bd073e7eeac964ddb36682403677aef9e1096..1c4c713d564f2fbb338d1848cddcb2c1cc2c56b6 100644 (file)
@@ -1 +1 @@
-CPUs: 1/1, MHz: 697, Nodes: 1, Sockets: 1, Cores: 1, Threads: 1
+CPUs: 1/1, MHz: 0, Nodes: 1, Sockets: 1, Cores: 1, Threads: 1