[libvirt] [PATCH 6/6] util: Don't report CPU frequency for ARM hosts

Andrea Bolognani abologna at redhat.com
Mon Dec 11 16:40:36 UTC 2017


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".

Signed-off-by: Andrea Bolognani <abologna at redhat.com>
---
 src/util/virhostcpu.c                                       | 5 +----
 tests/virhostcpudata/linux-aarch64-rhel74-moonshot.expected | 2 +-
 tests/virhostcpudata/linux-armv6l-raspberrypi.expected      | 2 +-
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c
index 3b478fc45..9bc213580 100644
--- a/src/util/virhostcpu.c
+++ b/src/util/virhostcpu.c
@@ -563,10 +563,7 @@ virHostCPUGetInfoParseCPUInfo(FILE *cpuinfo,
         } else if (ARCH_IS_PPC(arch)) {
             if (virHostCPUGetInfoParseCPUFrequency(line, "clock", mhz) < 0)
                 goto cleanup;
-        } else if (ARCH_IS_ARM(arch)) {
-            if (virHostCPUGetInfoParseCPUFrequency(line, "BogoMIPS", mhz) < 0)
-                goto cleanup;
-        } else if (ARCH_IS_S390(arch)) {
+        } else if (ARCH_IS_S390(arch) || ARCH_IS_ARM(arch)) {
             /* No reasonable way to obtain CPU frequency */
         } else {
             VIR_WARN("Parser for /proc/cpuinfo needs to be adapted for your architecture");
diff --git a/tests/virhostcpudata/linux-aarch64-rhel74-moonshot.expected b/tests/virhostcpudata/linux-aarch64-rhel74-moonshot.expected
index 24ff0ea0b..6776aa6c2 100644
--- a/tests/virhostcpudata/linux-aarch64-rhel74-moonshot.expected
+++ b/tests/virhostcpudata/linux-aarch64-rhel74-moonshot.expected
@@ -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
diff --git a/tests/virhostcpudata/linux-armv6l-raspberrypi.expected b/tests/virhostcpudata/linux-armv6l-raspberrypi.expected
index 146bd073e..1c4c713d5 100644
--- a/tests/virhostcpudata/linux-armv6l-raspberrypi.expected
+++ b/tests/virhostcpudata/linux-armv6l-raspberrypi.expected
@@ -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
-- 
2.14.3




More information about the libvir-list mailing list