[libvirt] [PATCH v3 0/5] Improvements to CPU frequency reporting

Changes from [v2]: * improve the parser; * print the architecture name instead of "your architecture". Changes from [v1]: * adopt Bjoern's approach to refactoring. [v2] https://www.redhat.com/archives/libvir-list/2017-December/msg00467.html [v1] https://www.redhat.com/archives/libvir-list/2017-December/msg00356.html Andrea Bolognani (4): tests: Add host CPU data for Moonshot (RHEL 7.4) util: Print architecture name in /proc/cpuinfo parser util: Improve CPU frequency parsing util: Don't report CPU frequency for ARM hosts Bjoern Walk (1): util: virhostcpu: factor out frequency parsing src/Makefile.am | 1 + src/util/virhostcpu.c | 188 ++++++++++++--------- .../linux-aarch64-rhel74-moonshot.cpuinfo | 72 ++++++++ .../linux-aarch64-rhel74-moonshot.expected | 1 + .../linux-armv6l-raspberrypi.expected | 2 +- .../linux-rhel74-moonshot/cpu/cpu0/node0 | 1 + .../linux-rhel74-moonshot/cpu/cpu0/online | 1 + .../cpu/cpu0/topology/core_id | 1 + .../cpu/cpu0/topology/core_siblings | 1 + .../cpu/cpu0/topology/core_siblings_list | 1 + .../cpu/cpu0/topology/physical_package_id | 1 + .../cpu/cpu0/topology/thread_siblings | 1 + .../cpu/cpu0/topology/thread_siblings_list | 1 + .../linux-rhel74-moonshot/cpu/cpu1/node0 | 1 + .../linux-rhel74-moonshot/cpu/cpu1/online | 1 + .../cpu/cpu1/topology/core_id | 1 + .../cpu/cpu1/topology/core_siblings | 1 + .../cpu/cpu1/topology/core_siblings_list | 1 + .../cpu/cpu1/topology/physical_package_id | 1 + .../cpu/cpu1/topology/thread_siblings | 1 + .../cpu/cpu1/topology/thread_siblings_list | 1 + .../linux-rhel74-moonshot/cpu/cpu2/node0 | 1 + .../linux-rhel74-moonshot/cpu/cpu2/online | 1 + .../cpu/cpu2/topology/core_id | 1 + .../cpu/cpu2/topology/core_siblings | 1 + .../cpu/cpu2/topology/core_siblings_list | 1 + .../cpu/cpu2/topology/physical_package_id | 1 + .../cpu/cpu2/topology/thread_siblings | 1 + .../cpu/cpu2/topology/thread_siblings_list | 1 + .../linux-rhel74-moonshot/cpu/cpu3/node0 | 1 + .../linux-rhel74-moonshot/cpu/cpu3/online | 1 + .../cpu/cpu3/topology/core_id | 1 + .../cpu/cpu3/topology/core_siblings | 1 + .../cpu/cpu3/topology/core_siblings_list | 1 + .../cpu/cpu3/topology/physical_package_id | 1 + .../cpu/cpu3/topology/thread_siblings | 1 + .../cpu/cpu3/topology/thread_siblings_list | 1 + .../linux-rhel74-moonshot/cpu/cpu4/node0 | 1 + .../linux-rhel74-moonshot/cpu/cpu4/online | 1 + .../cpu/cpu4/topology/core_id | 1 + .../cpu/cpu4/topology/core_siblings | 1 + .../cpu/cpu4/topology/core_siblings_list | 1 + .../cpu/cpu4/topology/physical_package_id | 1 + .../cpu/cpu4/topology/thread_siblings | 1 + .../cpu/cpu4/topology/thread_siblings_list | 1 + .../linux-rhel74-moonshot/cpu/cpu5/node0 | 1 + .../linux-rhel74-moonshot/cpu/cpu5/online | 1 + .../cpu/cpu5/topology/core_id | 1 + .../cpu/cpu5/topology/core_siblings | 1 + .../cpu/cpu5/topology/core_siblings_list | 1 + .../cpu/cpu5/topology/physical_package_id | 1 + .../cpu/cpu5/topology/thread_siblings | 1 + .../cpu/cpu5/topology/thread_siblings_list | 1 + .../linux-rhel74-moonshot/cpu/cpu6/node0 | 1 + .../linux-rhel74-moonshot/cpu/cpu6/online | 1 + .../cpu/cpu6/topology/core_id | 1 + .../cpu/cpu6/topology/core_siblings | 1 + .../cpu/cpu6/topology/core_siblings_list | 1 + .../cpu/cpu6/topology/physical_package_id | 1 + .../cpu/cpu6/topology/thread_siblings | 1 + .../cpu/cpu6/topology/thread_siblings_list | 1 + .../linux-rhel74-moonshot/cpu/cpu7/node0 | 1 + .../linux-rhel74-moonshot/cpu/cpu7/online | 1 + .../cpu/cpu7/topology/core_id | 1 + .../cpu/cpu7/topology/core_siblings | 1 + .../cpu/cpu7/topology/core_siblings_list | 1 + .../cpu/cpu7/topology/physical_package_id | 1 + .../cpu/cpu7/topology/thread_siblings | 1 + .../cpu/cpu7/topology/thread_siblings_list | 1 + .../linux-rhel74-moonshot/cpu/kernel_max | 1 + .../linux-rhel74-moonshot/cpu/offline | 1 + .../linux-rhel74-moonshot/cpu/online | 1 + .../linux-rhel74-moonshot/cpu/possible | 1 + .../linux-rhel74-moonshot/cpu/present | 1 + .../linux-rhel74-moonshot/node/has_cpu | 1 + .../linux-rhel74-moonshot/node/has_memory | 1 + .../linux-rhel74-moonshot/node/has_normal_memory | 1 + .../linux-rhel74-moonshot/node/node0/cpu0 | 1 + .../linux-rhel74-moonshot/node/node0/cpu1 | 1 + .../linux-rhel74-moonshot/node/node0/cpu2 | 1 + .../linux-rhel74-moonshot/node/node0/cpu3 | 1 + .../linux-rhel74-moonshot/node/node0/cpu4 | 1 + .../linux-rhel74-moonshot/node/node0/cpu5 | 1 + .../linux-rhel74-moonshot/node/node0/cpu6 | 1 + .../linux-rhel74-moonshot/node/node0/cpu7 | 1 + .../linux-rhel74-moonshot/node/node0/cpulist | 1 + .../linux-rhel74-moonshot/node/node0/cpumap | 1 + .../linux-rhel74-moonshot/node/online | 1 + .../linux-rhel74-moonshot/node/possible | 1 + tests/virhostcpudata/linux-x86_64-test1.cpuinfo | 4 + tests/virhostcputest.c | 1 + 91 files changed, 273 insertions(+), 80 deletions(-) create mode 100644 tests/virhostcpudata/linux-aarch64-rhel74-moonshot.cpuinfo create mode 100644 tests/virhostcpudata/linux-aarch64-rhel74-moonshot.expected create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/node0 create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/online create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/core_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/core_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/core_siblings_list create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/physical_package_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/thread_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/thread_siblings_list create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/node0 create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/online create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/core_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/core_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/core_siblings_list create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/physical_package_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/thread_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/thread_siblings_list create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/node0 create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/online create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/core_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/core_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/core_siblings_list create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/physical_package_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/thread_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/thread_siblings_list create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/node0 create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/online create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/core_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/core_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/core_siblings_list create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/physical_package_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/thread_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/thread_siblings_list create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/node0 create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/online create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/core_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/core_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/core_siblings_list create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/physical_package_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/thread_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/thread_siblings_list create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/node0 create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/online create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/core_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/core_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/core_siblings_list create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/physical_package_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/thread_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/thread_siblings_list create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/node0 create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/online create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/core_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/core_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/core_siblings_list create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/physical_package_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/thread_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/thread_siblings_list create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/node0 create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/online create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/core_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/core_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/core_siblings_list create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/physical_package_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/thread_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/thread_siblings_list create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/kernel_max create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/offline create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/online create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/possible create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/present create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/node/has_cpu create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/node/has_memory create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/node/has_normal_memory create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu0 create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu1 create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu2 create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu3 create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu4 create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu5 create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu6 create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu7 create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpulist create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpumap create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/node/online create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/node/possible -- 2.14.3

Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- .../linux-aarch64-rhel74-moonshot.cpuinfo | 72 ++++++++++++++++++++++ .../linux-aarch64-rhel74-moonshot.expected | 1 + .../linux-rhel74-moonshot/cpu/cpu0/node0 | 1 + .../linux-rhel74-moonshot/cpu/cpu0/online | 1 + .../cpu/cpu0/topology/core_id | 1 + .../cpu/cpu0/topology/core_siblings | 1 + .../cpu/cpu0/topology/core_siblings_list | 1 + .../cpu/cpu0/topology/physical_package_id | 1 + .../cpu/cpu0/topology/thread_siblings | 1 + .../cpu/cpu0/topology/thread_siblings_list | 1 + .../linux-rhel74-moonshot/cpu/cpu1/node0 | 1 + .../linux-rhel74-moonshot/cpu/cpu1/online | 1 + .../cpu/cpu1/topology/core_id | 1 + .../cpu/cpu1/topology/core_siblings | 1 + .../cpu/cpu1/topology/core_siblings_list | 1 + .../cpu/cpu1/topology/physical_package_id | 1 + .../cpu/cpu1/topology/thread_siblings | 1 + .../cpu/cpu1/topology/thread_siblings_list | 1 + .../linux-rhel74-moonshot/cpu/cpu2/node0 | 1 + .../linux-rhel74-moonshot/cpu/cpu2/online | 1 + .../cpu/cpu2/topology/core_id | 1 + .../cpu/cpu2/topology/core_siblings | 1 + .../cpu/cpu2/topology/core_siblings_list | 1 + .../cpu/cpu2/topology/physical_package_id | 1 + .../cpu/cpu2/topology/thread_siblings | 1 + .../cpu/cpu2/topology/thread_siblings_list | 1 + .../linux-rhel74-moonshot/cpu/cpu3/node0 | 1 + .../linux-rhel74-moonshot/cpu/cpu3/online | 1 + .../cpu/cpu3/topology/core_id | 1 + .../cpu/cpu3/topology/core_siblings | 1 + .../cpu/cpu3/topology/core_siblings_list | 1 + .../cpu/cpu3/topology/physical_package_id | 1 + .../cpu/cpu3/topology/thread_siblings | 1 + .../cpu/cpu3/topology/thread_siblings_list | 1 + .../linux-rhel74-moonshot/cpu/cpu4/node0 | 1 + .../linux-rhel74-moonshot/cpu/cpu4/online | 1 + .../cpu/cpu4/topology/core_id | 1 + .../cpu/cpu4/topology/core_siblings | 1 + .../cpu/cpu4/topology/core_siblings_list | 1 + .../cpu/cpu4/topology/physical_package_id | 1 + .../cpu/cpu4/topology/thread_siblings | 1 + .../cpu/cpu4/topology/thread_siblings_list | 1 + .../linux-rhel74-moonshot/cpu/cpu5/node0 | 1 + .../linux-rhel74-moonshot/cpu/cpu5/online | 1 + .../cpu/cpu5/topology/core_id | 1 + .../cpu/cpu5/topology/core_siblings | 1 + .../cpu/cpu5/topology/core_siblings_list | 1 + .../cpu/cpu5/topology/physical_package_id | 1 + .../cpu/cpu5/topology/thread_siblings | 1 + .../cpu/cpu5/topology/thread_siblings_list | 1 + .../linux-rhel74-moonshot/cpu/cpu6/node0 | 1 + .../linux-rhel74-moonshot/cpu/cpu6/online | 1 + .../cpu/cpu6/topology/core_id | 1 + .../cpu/cpu6/topology/core_siblings | 1 + .../cpu/cpu6/topology/core_siblings_list | 1 + .../cpu/cpu6/topology/physical_package_id | 1 + .../cpu/cpu6/topology/thread_siblings | 1 + .../cpu/cpu6/topology/thread_siblings_list | 1 + .../linux-rhel74-moonshot/cpu/cpu7/node0 | 1 + .../linux-rhel74-moonshot/cpu/cpu7/online | 1 + .../cpu/cpu7/topology/core_id | 1 + .../cpu/cpu7/topology/core_siblings | 1 + .../cpu/cpu7/topology/core_siblings_list | 1 + .../cpu/cpu7/topology/physical_package_id | 1 + .../cpu/cpu7/topology/thread_siblings | 1 + .../cpu/cpu7/topology/thread_siblings_list | 1 + .../linux-rhel74-moonshot/cpu/kernel_max | 1 + .../linux-rhel74-moonshot/cpu/offline | 1 + .../linux-rhel74-moonshot/cpu/online | 1 + .../linux-rhel74-moonshot/cpu/possible | 1 + .../linux-rhel74-moonshot/cpu/present | 1 + .../linux-rhel74-moonshot/node/has_cpu | 1 + .../linux-rhel74-moonshot/node/has_memory | 1 + .../linux-rhel74-moonshot/node/has_normal_memory | 1 + .../linux-rhel74-moonshot/node/node0/cpu0 | 1 + .../linux-rhel74-moonshot/node/node0/cpu1 | 1 + .../linux-rhel74-moonshot/node/node0/cpu2 | 1 + .../linux-rhel74-moonshot/node/node0/cpu3 | 1 + .../linux-rhel74-moonshot/node/node0/cpu4 | 1 + .../linux-rhel74-moonshot/node/node0/cpu5 | 1 + .../linux-rhel74-moonshot/node/node0/cpu6 | 1 + .../linux-rhel74-moonshot/node/node0/cpu7 | 1 + .../linux-rhel74-moonshot/node/node0/cpulist | 1 + .../linux-rhel74-moonshot/node/node0/cpumap | 1 + .../linux-rhel74-moonshot/node/online | 1 + .../linux-rhel74-moonshot/node/possible | 1 + tests/virhostcputest.c | 1 + 87 files changed, 158 insertions(+) create mode 100644 tests/virhostcpudata/linux-aarch64-rhel74-moonshot.cpuinfo create mode 100644 tests/virhostcpudata/linux-aarch64-rhel74-moonshot.expected create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/node0 create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/online create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/core_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/core_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/core_siblings_list create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/physical_package_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/thread_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/thread_siblings_list create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/node0 create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/online create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/core_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/core_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/core_siblings_list create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/physical_package_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/thread_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/thread_siblings_list create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/node0 create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/online create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/core_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/core_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/core_siblings_list create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/physical_package_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/thread_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/thread_siblings_list create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/node0 create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/online create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/core_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/core_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/core_siblings_list create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/physical_package_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/thread_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/thread_siblings_list create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/node0 create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/online create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/core_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/core_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/core_siblings_list create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/physical_package_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/thread_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/thread_siblings_list create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/node0 create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/online create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/core_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/core_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/core_siblings_list create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/physical_package_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/thread_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/thread_siblings_list create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/node0 create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/online create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/core_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/core_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/core_siblings_list create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/physical_package_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/thread_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/thread_siblings_list create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/node0 create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/online create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/core_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/core_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/core_siblings_list create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/physical_package_id create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/thread_siblings create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/thread_siblings_list create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/kernel_max create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/offline create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/online create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/possible create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/cpu/present create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/node/has_cpu create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/node/has_memory create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/node/has_normal_memory create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu0 create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu1 create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu2 create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu3 create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu4 create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu5 create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu6 create mode 120000 tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu7 create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpulist create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpumap create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/node/online create mode 100644 tests/virhostcpudata/linux-rhel74-moonshot/node/possible diff --git a/tests/virhostcpudata/linux-aarch64-rhel74-moonshot.cpuinfo b/tests/virhostcpudata/linux-aarch64-rhel74-moonshot.cpuinfo new file mode 100644 index 000000000..ae528bf61 --- /dev/null +++ b/tests/virhostcpudata/linux-aarch64-rhel74-moonshot.cpuinfo @@ -0,0 +1,72 @@ +processor : 0 +BogoMIPS : 100.00 +Features : fp asimd evtstrm cpuid +CPU implementer : 0x50 +CPU architecture: 8 +CPU variant : 0x0 +CPU part : 0x000 +CPU revision : 1 + +processor : 1 +BogoMIPS : 100.00 +Features : fp asimd evtstrm cpuid +CPU implementer : 0x50 +CPU architecture: 8 +CPU variant : 0x0 +CPU part : 0x000 +CPU revision : 1 + +processor : 2 +BogoMIPS : 100.00 +Features : fp asimd evtstrm cpuid +CPU implementer : 0x50 +CPU architecture: 8 +CPU variant : 0x0 +CPU part : 0x000 +CPU revision : 1 + +processor : 3 +BogoMIPS : 100.00 +Features : fp asimd evtstrm cpuid +CPU implementer : 0x50 +CPU architecture: 8 +CPU variant : 0x0 +CPU part : 0x000 +CPU revision : 1 + +processor : 4 +BogoMIPS : 100.00 +Features : fp asimd evtstrm cpuid +CPU implementer : 0x50 +CPU architecture: 8 +CPU variant : 0x0 +CPU part : 0x000 +CPU revision : 1 + +processor : 5 +BogoMIPS : 100.00 +Features : fp asimd evtstrm cpuid +CPU implementer : 0x50 +CPU architecture: 8 +CPU variant : 0x0 +CPU part : 0x000 +CPU revision : 1 + +processor : 6 +BogoMIPS : 100.00 +Features : fp asimd evtstrm cpuid +CPU implementer : 0x50 +CPU architecture: 8 +CPU variant : 0x0 +CPU part : 0x000 +CPU revision : 1 + +processor : 7 +BogoMIPS : 100.00 +Features : fp asimd evtstrm cpuid +CPU implementer : 0x50 +CPU architecture: 8 +CPU variant : 0x0 +CPU part : 0x000 +CPU revision : 1 + diff --git a/tests/virhostcpudata/linux-aarch64-rhel74-moonshot.expected b/tests/virhostcpudata/linux-aarch64-rhel74-moonshot.expected new file mode 100644 index 000000000..24ff0ea0b --- /dev/null +++ b/tests/virhostcpudata/linux-aarch64-rhel74-moonshot.expected @@ -0,0 +1 @@ +CPUs: 8/8, MHz: 100, Nodes: 1, Sockets: 1, Cores: 8, Threads: 1 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/node0 b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/node0 new file mode 120000 index 000000000..222b6af32 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/node0 @@ -0,0 +1 @@ +../../node/node0 \ No newline at end of file diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/online b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/online new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/online @@ -0,0 +1 @@ +1 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/core_id b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/core_id new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/core_id @@ -0,0 +1 @@ +0 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/core_siblings b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/core_siblings new file mode 100644 index 000000000..fcd15acf9 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/core_siblings @@ -0,0 +1 @@ +ff diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/core_siblings_list b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/core_siblings_list new file mode 100644 index 000000000..74fc2fb6b --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/core_siblings_list @@ -0,0 +1 @@ +0-7 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/physical_package_id b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/physical_package_id new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/physical_package_id @@ -0,0 +1 @@ +0 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/thread_siblings b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/thread_siblings new file mode 100644 index 000000000..8a0f05e16 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/thread_siblings @@ -0,0 +1 @@ +01 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/thread_siblings_list b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/thread_siblings_list new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu0/topology/thread_siblings_list @@ -0,0 +1 @@ +0 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/node0 b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/node0 new file mode 120000 index 000000000..222b6af32 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/node0 @@ -0,0 +1 @@ +../../node/node0 \ No newline at end of file diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/online b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/online new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/online @@ -0,0 +1 @@ +1 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/core_id b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/core_id new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/core_id @@ -0,0 +1 @@ +1 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/core_siblings b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/core_siblings new file mode 100644 index 000000000..fcd15acf9 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/core_siblings @@ -0,0 +1 @@ +ff diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/core_siblings_list b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/core_siblings_list new file mode 100644 index 000000000..74fc2fb6b --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/core_siblings_list @@ -0,0 +1 @@ +0-7 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/physical_package_id b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/physical_package_id new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/physical_package_id @@ -0,0 +1 @@ +0 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/thread_siblings b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/thread_siblings new file mode 100644 index 000000000..9e22bcb8e --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/thread_siblings @@ -0,0 +1 @@ +02 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/thread_siblings_list b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/thread_siblings_list new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu1/topology/thread_siblings_list @@ -0,0 +1 @@ +1 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/node0 b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/node0 new file mode 120000 index 000000000..222b6af32 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/node0 @@ -0,0 +1 @@ +../../node/node0 \ No newline at end of file diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/online b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/online new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/online @@ -0,0 +1 @@ +1 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/core_id b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/core_id new file mode 100644 index 000000000..0cfbf0888 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/core_id @@ -0,0 +1 @@ +2 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/core_siblings b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/core_siblings new file mode 100644 index 000000000..fcd15acf9 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/core_siblings @@ -0,0 +1 @@ +ff diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/core_siblings_list b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/core_siblings_list new file mode 100644 index 000000000..74fc2fb6b --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/core_siblings_list @@ -0,0 +1 @@ +0-7 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/physical_package_id b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/physical_package_id new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/physical_package_id @@ -0,0 +1 @@ +0 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/thread_siblings b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/thread_siblings new file mode 100644 index 000000000..64969239d --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/thread_siblings @@ -0,0 +1 @@ +04 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/thread_siblings_list b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/thread_siblings_list new file mode 100644 index 000000000..0cfbf0888 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu2/topology/thread_siblings_list @@ -0,0 +1 @@ +2 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/node0 b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/node0 new file mode 120000 index 000000000..222b6af32 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/node0 @@ -0,0 +1 @@ +../../node/node0 \ No newline at end of file diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/online b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/online new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/online @@ -0,0 +1 @@ +1 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/core_id b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/core_id new file mode 100644 index 000000000..00750edc0 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/core_id @@ -0,0 +1 @@ +3 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/core_siblings b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/core_siblings new file mode 100644 index 000000000..fcd15acf9 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/core_siblings @@ -0,0 +1 @@ +ff diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/core_siblings_list b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/core_siblings_list new file mode 100644 index 000000000..74fc2fb6b --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/core_siblings_list @@ -0,0 +1 @@ +0-7 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/physical_package_id b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/physical_package_id new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/physical_package_id @@ -0,0 +1 @@ +0 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/thread_siblings b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/thread_siblings new file mode 100644 index 000000000..adb9de8ee --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/thread_siblings @@ -0,0 +1 @@ +08 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/thread_siblings_list b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/thread_siblings_list new file mode 100644 index 000000000..00750edc0 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu3/topology/thread_siblings_list @@ -0,0 +1 @@ +3 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/node0 b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/node0 new file mode 120000 index 000000000..222b6af32 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/node0 @@ -0,0 +1 @@ +../../node/node0 \ No newline at end of file diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/online b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/online new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/online @@ -0,0 +1 @@ +1 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/core_id b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/core_id new file mode 100644 index 000000000..b8626c4cf --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/core_id @@ -0,0 +1 @@ +4 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/core_siblings b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/core_siblings new file mode 100644 index 000000000..fcd15acf9 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/core_siblings @@ -0,0 +1 @@ +ff diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/core_siblings_list b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/core_siblings_list new file mode 100644 index 000000000..74fc2fb6b --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/core_siblings_list @@ -0,0 +1 @@ +0-7 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/physical_package_id b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/physical_package_id new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/physical_package_id @@ -0,0 +1 @@ +0 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/thread_siblings b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/thread_siblings new file mode 100644 index 000000000..f599e28b8 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/thread_siblings @@ -0,0 +1 @@ +10 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/thread_siblings_list b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/thread_siblings_list new file mode 100644 index 000000000..b8626c4cf --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu4/topology/thread_siblings_list @@ -0,0 +1 @@ +4 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/node0 b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/node0 new file mode 120000 index 000000000..222b6af32 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/node0 @@ -0,0 +1 @@ +../../node/node0 \ No newline at end of file diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/online b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/online new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/online @@ -0,0 +1 @@ +1 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/core_id b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/core_id new file mode 100644 index 000000000..7ed6ff82d --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/core_id @@ -0,0 +1 @@ +5 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/core_siblings b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/core_siblings new file mode 100644 index 000000000..fcd15acf9 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/core_siblings @@ -0,0 +1 @@ +ff diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/core_siblings_list b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/core_siblings_list new file mode 100644 index 000000000..74fc2fb6b --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/core_siblings_list @@ -0,0 +1 @@ +0-7 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/physical_package_id b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/physical_package_id new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/physical_package_id @@ -0,0 +1 @@ +0 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/thread_siblings b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/thread_siblings new file mode 100644 index 000000000..209e3ef4b --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/thread_siblings @@ -0,0 +1 @@ +20 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/thread_siblings_list b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/thread_siblings_list new file mode 100644 index 000000000..7ed6ff82d --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu5/topology/thread_siblings_list @@ -0,0 +1 @@ +5 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/node0 b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/node0 new file mode 120000 index 000000000..222b6af32 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/node0 @@ -0,0 +1 @@ +../../node/node0 \ No newline at end of file diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/online b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/online new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/online @@ -0,0 +1 @@ +1 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/core_id b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/core_id new file mode 100644 index 000000000..1e8b31496 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/core_id @@ -0,0 +1 @@ +6 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/core_siblings b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/core_siblings new file mode 100644 index 000000000..fcd15acf9 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/core_siblings @@ -0,0 +1 @@ +ff diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/core_siblings_list b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/core_siblings_list new file mode 100644 index 000000000..74fc2fb6b --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/core_siblings_list @@ -0,0 +1 @@ +0-7 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/physical_package_id b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/physical_package_id new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/physical_package_id @@ -0,0 +1 @@ +0 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/thread_siblings b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/thread_siblings new file mode 100644 index 000000000..425151f3a --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/thread_siblings @@ -0,0 +1 @@ +40 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/thread_siblings_list b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/thread_siblings_list new file mode 100644 index 000000000..1e8b31496 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu6/topology/thread_siblings_list @@ -0,0 +1 @@ +6 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/node0 b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/node0 new file mode 120000 index 000000000..222b6af32 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/node0 @@ -0,0 +1 @@ +../../node/node0 \ No newline at end of file diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/online b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/online new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/online @@ -0,0 +1 @@ +1 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/core_id b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/core_id new file mode 100644 index 000000000..7f8f011eb --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/core_id @@ -0,0 +1 @@ +7 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/core_siblings b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/core_siblings new file mode 100644 index 000000000..fcd15acf9 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/core_siblings @@ -0,0 +1 @@ +ff diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/core_siblings_list b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/core_siblings_list new file mode 100644 index 000000000..74fc2fb6b --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/core_siblings_list @@ -0,0 +1 @@ +0-7 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/physical_package_id b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/physical_package_id new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/physical_package_id @@ -0,0 +1 @@ +0 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/thread_siblings b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/thread_siblings new file mode 100644 index 000000000..d15a2cc44 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/thread_siblings @@ -0,0 +1 @@ +80 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/thread_siblings_list b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/thread_siblings_list new file mode 100644 index 000000000..7f8f011eb --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/cpu7/topology/thread_siblings_list @@ -0,0 +1 @@ +7 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/kernel_max b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/kernel_max new file mode 100644 index 000000000..50b0f7906 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/kernel_max @@ -0,0 +1 @@ +4095 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/offline b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/offline new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/offline @@ -0,0 +1 @@ + diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/online b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/online new file mode 100644 index 000000000..74fc2fb6b --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/online @@ -0,0 +1 @@ +0-7 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/possible b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/possible new file mode 100644 index 000000000..74fc2fb6b --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/possible @@ -0,0 +1 @@ +0-7 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/cpu/present b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/present new file mode 100644 index 000000000..74fc2fb6b --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/cpu/present @@ -0,0 +1 @@ +0-7 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/node/has_cpu b/tests/virhostcpudata/linux-rhel74-moonshot/node/has_cpu new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/node/has_cpu @@ -0,0 +1 @@ +0 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/node/has_memory b/tests/virhostcpudata/linux-rhel74-moonshot/node/has_memory new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/node/has_memory @@ -0,0 +1 @@ +0 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/node/has_normal_memory b/tests/virhostcpudata/linux-rhel74-moonshot/node/has_normal_memory new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/node/has_normal_memory @@ -0,0 +1 @@ +0 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu0 b/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu0 new file mode 120000 index 000000000..c841bea28 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu0 @@ -0,0 +1 @@ +../../cpu/cpu0 \ No newline at end of file diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu1 b/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu1 new file mode 120000 index 000000000..5f4536279 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu1 @@ -0,0 +1 @@ +../../cpu/cpu1 \ No newline at end of file diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu2 b/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu2 new file mode 120000 index 000000000..2dcca332c --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu2 @@ -0,0 +1 @@ +../../cpu/cpu2 \ No newline at end of file diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu3 b/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu3 new file mode 120000 index 000000000..c7690e5aa --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu3 @@ -0,0 +1 @@ +../../cpu/cpu3 \ No newline at end of file diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu4 b/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu4 new file mode 120000 index 000000000..9e77a64eb --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu4 @@ -0,0 +1 @@ +../../cpu/cpu4 \ No newline at end of file diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu5 b/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu5 new file mode 120000 index 000000000..cc07c3b97 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu5 @@ -0,0 +1 @@ +../../cpu/cpu5 \ No newline at end of file diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu6 b/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu6 new file mode 120000 index 000000000..2e7576354 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu6 @@ -0,0 +1 @@ +../../cpu/cpu6 \ No newline at end of file diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu7 b/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu7 new file mode 120000 index 000000000..09e3f79b4 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpu7 @@ -0,0 +1 @@ +../../cpu/cpu7 \ No newline at end of file diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpulist b/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpulist new file mode 100644 index 000000000..74fc2fb6b --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpulist @@ -0,0 +1 @@ +0-7 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpumap b/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpumap new file mode 100644 index 000000000..fcd15acf9 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/node/node0/cpumap @@ -0,0 +1 @@ +ff diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/node/online b/tests/virhostcpudata/linux-rhel74-moonshot/node/online new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/node/online @@ -0,0 +1 @@ +0 diff --git a/tests/virhostcpudata/linux-rhel74-moonshot/node/possible b/tests/virhostcpudata/linux-rhel74-moonshot/node/possible new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/tests/virhostcpudata/linux-rhel74-moonshot/node/possible @@ -0,0 +1 @@ +0 diff --git a/tests/virhostcputest.c b/tests/virhostcputest.c index d1208c373..d3ee18461 100644 --- a/tests/virhostcputest.c +++ b/tests/virhostcputest.c @@ -239,6 +239,7 @@ mymain(void) {"raspberrypi", VIR_ARCH_ARMV6L}, {"f21-mustang", VIR_ARCH_AARCH64}, {"rhelsa-3.19.0-mustang", VIR_ARCH_AARCH64}, + {"rhel74-moonshot", VIR_ARCH_AARCH64}, {"deconf-cpus", VIR_ARCH_PPC64}, /* subcores, default configuration */ {"subcores1", VIR_ARCH_PPC64}, -- 2.14.3

From: Bjoern Walk <bwalk@linux.vnet.ibm.com> All different architectures use the same copy-pasted code to parse processor frequency information from /proc/cpuinfo. Let's extract that code into a function to avoid repetition. We now also tolerate if the parsing of /proc/cpuinfo is not successful and just report a warning instead of bailing out and abandoning the rest of the CPU information. Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com> Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com> Reviewed-by: Andrea Bolognani <abologna@redhat.com> Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com> --- src/util/virhostcpu.c | 141 ++++++++++++++++++++++---------------------------- 1 file changed, 62 insertions(+), 79 deletions(-) diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index c485a9721..d47062013 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -508,6 +508,65 @@ virHostCPUHasValidSubcoreConfiguration(int threads_per_subcore) return ret; } +static int +virHostCPUParseFrequencyString(const char *str, + const char *prefix, + unsigned int *mhz) +{ + char *p; + unsigned int ui; + + if (!STRPREFIX(str, prefix)) + return 1; + + str += strlen(prefix); + + while (*str && c_isspace(*str)) + str++; + + if (*str != ':' || !str[1]) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("parsing cpu MHz from cpuinfo")); + return -1; + } + + if (virStrToLong_ui(str + 1, &p, 10, &ui) == 0 && + /* Accept trailing fractional part. */ + (*p == '\0' || *p == '.' || c_isspace(*p))) + *mhz = ui; + + return 0; +} + +static int +virHostCPUParseFrequency(FILE *cpuinfo, + virArch arch, + unsigned int *mhz) +{ + const char *prefix = NULL; + char line[1024]; + + 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("Your architecture is not supported by the %s parser", + CPUINFO_PATH); + return 1; + } + + while (fgets(line, sizeof(line), cpuinfo) != NULL) { + if (virHostCPUParseFrequencyString(line, prefix, mhz) < 0) + return -1; + } + + return 0; +} + int virHostCPUGetInfoPopulateLinux(FILE *cpuinfo, virArch arch, @@ -520,7 +579,6 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo, { virBitmapPtr present_cpus_map = NULL; virBitmapPtr online_cpus_map = NULL; - char line[1024]; DIR *nodedir = NULL; struct dirent *nodedirent = NULL; int nodecpus, nodecores, nodesockets, nodethreads, offline = 0; @@ -535,84 +593,9 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo, *cpus = *nodes = *sockets = *cores = *threads = 0; /* Start with parsing CPU clock speed from /proc/cpuinfo */ - while (fgets(line, sizeof(line), cpuinfo) != NULL) { - if (ARCH_IS_X86(arch)) { - char *buf = line; - if (STRPREFIX(buf, "cpu MHz")) { - char *p; - unsigned int ui; - - buf += 7; - while (*buf && c_isspace(*buf)) - buf++; - - if (*buf != ':' || !buf[1]) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("parsing cpu MHz from cpuinfo")); - goto cleanup; - } - - if (virStrToLong_ui(buf+1, &p, 10, &ui) == 0 && - /* Accept trailing fractional part. */ - (*p == '\0' || *p == '.' || c_isspace(*p))) - *mhz = ui; - } - } else if (ARCH_IS_PPC(arch)) { - char *buf = line; - if (STRPREFIX(buf, "clock")) { - char *p; - unsigned int ui; - - buf += 5; - while (*buf && c_isspace(*buf)) - buf++; - - if (*buf != ':' || !buf[1]) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("parsing cpu MHz from cpuinfo")); - goto cleanup; - } - - if (virStrToLong_ui(buf+1, &p, 10, &ui) == 0 && - /* Accept trailing fractional part. */ - (*p == '\0' || *p == '.' || c_isspace(*p))) - *mhz = ui; - /* No other interesting infos are available in /proc/cpuinfo. - * However, there is a line identifying processor's version, - * identification and machine, but we don't want it to be caught - * and parsed in next iteration, because it is not in expected - * format and thus lead to error. */ - } - } else if (ARCH_IS_ARM(arch)) { - char *buf = line; - if (STRPREFIX(buf, "BogoMIPS")) { - char *p; - unsigned int ui; - - buf += 8; - while (*buf && c_isspace(*buf)) - buf++; - - if (*buf != ':' || !buf[1]) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("parsing cpu MHz from cpuinfo")); - goto cleanup; - } - - if (virStrToLong_ui(buf+1, &p, 10, &ui) == 0 - /* Accept trailing fractional part. */ - && (*p == '\0' || *p == '.' || c_isspace(*p))) - *mhz = ui; - } - } else if (ARCH_IS_S390(arch)) { - /* s390x has no realistic value for CPU speed, - * assign a value of zero to signify this */ - *mhz = 0; - } else { - VIR_WARN("Parser for /proc/cpuinfo needs to be adapted for your architecture"); - break; - } - } + if (virHostCPUParseFrequency(cpuinfo, arch, mhz) < 0) + VIR_WARN("Unable to parse CPU frequency information from %s", + CPUINFO_PATH); /* Get information about what CPUs are present in the host and what * CPUs are online, so that we don't have to so for each node */ -- 2.14.3

On 12/14/2017 07:33 AM, Andrea Bolognani wrote:
From: Bjoern Walk <bwalk@linux.vnet.ibm.com>
All different architectures use the same copy-pasted code to parse processor frequency information from /proc/cpuinfo. Let's extract that code into a function to avoid repetition.
We now also tolerate if the parsing of /proc/cpuinfo is not successful and just report a warning instead of bailing out and abandoning the rest of the CPU information.
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com> Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com> Reviewed-by: Andrea Bolognani <abologna@redhat.com> Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com> --- src/util/virhostcpu.c | 141 ++++++++++++++++++++++---------------------------- 1 file changed, 62 insertions(+), 79 deletions(-)
Couple of nits... see below Reviewed-by: John Ferlan <jferlan@redhat.com> John
diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index c485a9721..d47062013 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -508,6 +508,65 @@ virHostCPUHasValidSubcoreConfiguration(int threads_per_subcore) return ret; }
Two blank lines between functions...
+static int +virHostCPUParseFrequencyString(const char *str, + const char *prefix, + unsigned int *mhz) +{ + char *p; + unsigned int ui; + + if (!STRPREFIX(str, prefix)) + return 1; + + str += strlen(prefix); + + while (*str && c_isspace(*str)) + str++; + + if (*str != ':' || !str[1]) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("parsing cpu MHz from cpuinfo")); + return -1; + } + + if (virStrToLong_ui(str + 1, &p, 10, &ui) == 0 && + /* Accept trailing fractional part. */ + (*p == '\0' || *p == '.' || c_isspace(*p))) + *mhz = ui; + + return 0; +} +
blank line
+static int +virHostCPUParseFrequency(FILE *cpuinfo, + virArch arch, + unsigned int *mhz) +{ + const char *prefix = NULL; + char line[1024]; + + 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("Your architecture is not supported by the %s parser", + CPUINFO_PATH); + return 1; + } + + while (fgets(line, sizeof(line), cpuinfo) != NULL) { + if (virHostCPUParseFrequencyString(line, prefix, mhz) < 0) + return -1; + } + + return 0; +} +
extra blank line...
int virHostCPUGetInfoPopulateLinux(FILE *cpuinfo, virArch arch, @@ -520,7 +579,6 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo, { virBitmapPtr present_cpus_map = NULL; virBitmapPtr online_cpus_map = NULL; - char line[1024]; DIR *nodedir = NULL; struct dirent *nodedirent = NULL; int nodecpus, nodecores, nodesockets, nodethreads, offline = 0; @@ -535,84 +593,9 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo, *cpus = *nodes = *sockets = *cores = *threads = 0;
/* Start with parsing CPU clock speed from /proc/cpuinfo */ - while (fgets(line, sizeof(line), cpuinfo) != NULL) { - if (ARCH_IS_X86(arch)) { - char *buf = line; - if (STRPREFIX(buf, "cpu MHz")) { - char *p; - unsigned int ui; - - buf += 7; - while (*buf && c_isspace(*buf)) - buf++; - - if (*buf != ':' || !buf[1]) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("parsing cpu MHz from cpuinfo")); - goto cleanup; - } - - if (virStrToLong_ui(buf+1, &p, 10, &ui) == 0 && - /* Accept trailing fractional part. */ - (*p == '\0' || *p == '.' || c_isspace(*p))) - *mhz = ui; - } - } else if (ARCH_IS_PPC(arch)) { - char *buf = line; - if (STRPREFIX(buf, "clock")) { - char *p; - unsigned int ui; - - buf += 5; - while (*buf && c_isspace(*buf)) - buf++; - - if (*buf != ':' || !buf[1]) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("parsing cpu MHz from cpuinfo")); - goto cleanup; - } - - if (virStrToLong_ui(buf+1, &p, 10, &ui) == 0 && - /* Accept trailing fractional part. */ - (*p == '\0' || *p == '.' || c_isspace(*p))) - *mhz = ui; - /* No other interesting infos are available in /proc/cpuinfo. - * However, there is a line identifying processor's version, - * identification and machine, but we don't want it to be caught - * and parsed in next iteration, because it is not in expected - * format and thus lead to error. */ - } - } else if (ARCH_IS_ARM(arch)) { - char *buf = line; - if (STRPREFIX(buf, "BogoMIPS")) { - char *p; - unsigned int ui; - - buf += 8; - while (*buf && c_isspace(*buf)) - buf++; - - if (*buf != ':' || !buf[1]) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("parsing cpu MHz from cpuinfo")); - goto cleanup; - } - - if (virStrToLong_ui(buf+1, &p, 10, &ui) == 0 - /* Accept trailing fractional part. */ - && (*p == '\0' || *p == '.' || c_isspace(*p))) - *mhz = ui; - } - } else if (ARCH_IS_S390(arch)) { - /* s390x has no realistic value for CPU speed, - * assign a value of zero to signify this */ - *mhz = 0; - } else { - VIR_WARN("Parser for /proc/cpuinfo needs to be adapted for your architecture"); - break; - } - } + if (virHostCPUParseFrequency(cpuinfo, arch, mhz) < 0) + VIR_WARN("Unable to parse CPU frequency information from %s", + CPUINFO_PATH);
/* Get information about what CPUs are present in the host and what * CPUs are online, so that we don't have to so for each node */

On Fri, 2018-01-05 at 15:41 -0500, John Ferlan wrote:
src/util/virhostcpu.c | 141 ++++++++++++++++++++++---------------------------- 1 file changed, 62 insertions(+), 79 deletions(-)
Couple of nits... see below
Reviewed-by: John Ferlan <jferlan@redhat.com>
diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index c485a9721..d47062013 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -508,6 +508,65 @@ virHostCPUHasValidSubcoreConfiguration(int threads_per_subcore) return ret; }
Two blank lines between functions...
+static int +virHostCPUParseFrequencyString(const char *str, + const char *prefix, + unsigned int *mhz) +{
I guess Bjoern tried to be consistent with the rest of the file, which mostly uses a single line to separate functions. But I'm perfectly fine using two lines as well, so I'll change it before pushing unless someone feels very strongly against it. -- Andrea Bolognani / Red Hat / Virtualization

Instead of a generic "your architecture", print the actual architecture name. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- src/Makefile.am | 1 + src/util/virhostcpu.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index 4c022d1e4..166c9a8e9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2477,6 +2477,7 @@ noinst_LTLIBRARIES += libvirt-setuid-rpc-client.la libvirt_setuid_rpc_client_la_SOURCES = \ util/viralloc.c \ + util/virarch.c \ util/viratomic.c \ util/viratomic.h \ util/virbitmap.c \ diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index d47062013..3c20755eb 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -554,7 +554,8 @@ virHostCPUParseFrequency(FILE *cpuinfo, prefix = "BogoMIPS"; if (!prefix) { - VIR_WARN("Your architecture is not supported by the %s parser", + VIR_WARN("%s is not supported by the %s parser", + virArchToString(arch), CPUINFO_PATH); return 1; } -- 2.14.3

Andrea Bolognani <abologna@redhat.com> [2017-12-14, 01:33PM +0100]:
Instead of a generic "your architecture", print the actual architecture name.
Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- src/Makefile.am | 1 + src/util/virhostcpu.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/Makefile.am b/src/Makefile.am index 4c022d1e4..166c9a8e9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2477,6 +2477,7 @@ noinst_LTLIBRARIES += libvirt-setuid-rpc-client.la
libvirt_setuid_rpc_client_la_SOURCES = \ util/viralloc.c \ + util/virarch.c \ util/viratomic.c \ util/viratomic.h \ util/virbitmap.c \ diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index d47062013..3c20755eb 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -554,7 +554,8 @@ virHostCPUParseFrequency(FILE *cpuinfo, prefix = "BogoMIPS";
if (!prefix) { - VIR_WARN("Your architecture is not supported by the %s parser", + VIR_WARN("%s is not supported by the %s parser", + virArchToString(arch), CPUINFO_PATH); return 1; } -- 2.14.3
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
-- IBM Systems Linux on z Systems & Virtualization Development ------------------------------------------------------------------------ IBM Deutschland Schönaicher Str. 220 71032 Böblingen Phone: +49 7031 16 1819 E-Mail: bwalk@de.ibm.com ------------------------------------------------------------------------ IBM Deutschland Research & Development GmbH Vorsitzende des Aufsichtsrats: Martina Koederitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294

Make the parser both more strict, by not ignoring errors reported by virStrToLong_ui(), and more permissive, by not failing due to unrelated fields which just happen to have a know prefix and accepting any amount of whitespace before the numeric value. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- src/util/virhostcpu.c | 62 +++++++++++++++++++++---- tests/virhostcpudata/linux-x86_64-test1.cpuinfo | 4 ++ 2 files changed, 57 insertions(+), 9 deletions(-) diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index 3c20755eb..9c9f362de 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -508,6 +508,27 @@ virHostCPUHasValidSubcoreConfiguration(int threads_per_subcore) return ret; } +/** + * virHostCPUParseFrequencyString: + * @str: string to be parsed + * @prefix: expected prefix + * @mhz: output location + * + * Parse a /proc/cpuinfo line and extract the CPU frequency, if present. + * + * The expected format of @str looks like + * + * cpu MHz : 2100.000 + * + * where @prefix ("cpu MHz" in the example), is architecture-dependent. + * + * The decimal part of the CPU frequency, as well as all whitespace, is + * ignored. + * + * Returns: 0 when the string has been parsed successfully and the CPU + * frequency has been stored in @mhz, >0 when the string has not + * been parsed but no error has occurred, <0 on failure. + */ static int virHostCPUParseFrequencyString(const char *str, const char *prefix, @@ -516,26 +537,49 @@ virHostCPUParseFrequencyString(const char *str, char *p; unsigned int ui; + /* If the string doesn't start with the expected prefix, then + * we're not looking at the right string and we should move on */ if (!STRPREFIX(str, prefix)) return 1; + /* Skip the prefix */ str += strlen(prefix); - while (*str && c_isspace(*str)) + /* Skip all whitespace */ + while (c_isspace(*str)) str++; + if (*str == '\0') + goto error; - if (*str != ':' || !str[1]) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("parsing cpu MHz from cpuinfo")); - return -1; + /* Skip the colon. If anything but a colon is found, then we're + * not looking at the right string and we should move on */ + if (*str != ':') + return 1; + str++; + + /* Skip all whitespace */ + while (c_isspace(*str)) + str++; + if (*str == '\0') + goto error; + + /* Parse the frequency. We expect an unsigned value, optionally + * followed by a fractional part (which gets discarded) or some + * leading whitespace */ + if (virStrToLong_ui(str, &p, 10, &ui) < 0 || + (*p != '.' && *p != '\0' && !c_isspace(*p))) { + goto error; } - if (virStrToLong_ui(str + 1, &p, 10, &ui) == 0 && - /* Accept trailing fractional part. */ - (*p == '\0' || *p == '.' || c_isspace(*p))) - *mhz = ui; + *mhz = ui; return 0; + + error: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Missing or invalid CPU frequency in %s"), + CPUINFO_PATH); + return -1; } static int diff --git a/tests/virhostcpudata/linux-x86_64-test1.cpuinfo b/tests/virhostcpudata/linux-x86_64-test1.cpuinfo index e88a48ff3..706b69a54 100644 --- a/tests/virhostcpudata/linux-x86_64-test1.cpuinfo +++ b/tests/virhostcpudata/linux-x86_64-test1.cpuinfo @@ -28,6 +28,10 @@ model : 4 model name : Intel(R) Xeon(TM) CPU 2.80GHz stepping : 8 cpu MHz : 2800.000 +# The following field is a made-up one, intended to make sure our cpuinfo +# parser deals correctly with the introduction of new fields that just so +# happen to share a prefix with the one used for CPU frequency +cpu MHz rounded up to GHz : 3000.000 cache size : 2048 KB physical id : 0 siblings : 2 -- 2.14.3

Andrea Bolognani <abologna@redhat.com> [2017-12-14, 01:34PM +0100]:
Make the parser both more strict, by not ignoring errors reported by virStrToLong_ui(), and more permissive, by not failing due to unrelated fields which just happen to have a know prefix and accepting any amount of whitespace before the numeric value.
Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- src/util/virhostcpu.c | 62 +++++++++++++++++++++---- tests/virhostcpudata/linux-x86_64-test1.cpuinfo | 4 ++ 2 files changed, 57 insertions(+), 9 deletions(-)
diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index 3c20755eb..9c9f362de 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -508,6 +508,27 @@ virHostCPUHasValidSubcoreConfiguration(int threads_per_subcore) return ret; }
+/** + * virHostCPUParseFrequencyString: + * @str: string to be parsed + * @prefix: expected prefix + * @mhz: output location + * + * Parse a /proc/cpuinfo line and extract the CPU frequency, if present. + * + * The expected format of @str looks like + * + * cpu MHz : 2100.000 + * + * where @prefix ("cpu MHz" in the example), is architecture-dependent. + * + * The decimal part of the CPU frequency, as well as all whitespace, is + * ignored. + * + * Returns: 0 when the string has been parsed successfully and the CPU + * frequency has been stored in @mhz, >0 when the string has not
Maybe, >0 when the line prefix does not match exactly?
+ * been parsed but no error has occurred, <0 on failure. + */ static int virHostCPUParseFrequencyString(const char *str, const char *prefix, @@ -516,26 +537,49 @@ virHostCPUParseFrequencyString(const char *str, char *p; unsigned int ui;
+ /* If the string doesn't start with the expected prefix, then + * we're not looking at the right string and we should move on */ if (!STRPREFIX(str, prefix)) return 1;
+ /* Skip the prefix */ str += strlen(prefix);
- while (*str && c_isspace(*str)) + /* Skip all whitespace */ + while (c_isspace(*str)) str++; + if (*str == '\0') + goto error;
- if (*str != ':' || !str[1]) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("parsing cpu MHz from cpuinfo")); - return -1; + /* Skip the colon. If anything but a colon is found, then we're + * not looking at the right string and we should move on */ + if (*str != ':') + return 1; + str++;
You could do *str++ != ':' and save one line.
+ + /* Skip all whitespace */ + while (c_isspace(*str)) + str++; + if (*str == '\0') + goto error; + + /* Parse the frequency. We expect an unsigned value, optionally + * followed by a fractional part (which gets discarded) or some + * leading whitespace */ + if (virStrToLong_ui(str, &p, 10, &ui) < 0 || + (*p != '.' && *p != '\0' && !c_isspace(*p))) { + goto error; }
- if (virStrToLong_ui(str + 1, &p, 10, &ui) == 0 && - /* Accept trailing fractional part. */ - (*p == '\0' || *p == '.' || c_isspace(*p))) - *mhz = ui; + *mhz = ui;
return 0; + + error: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Missing or invalid CPU frequency in %s"), + CPUINFO_PATH); + return -1; }
static int diff --git a/tests/virhostcpudata/linux-x86_64-test1.cpuinfo b/tests/virhostcpudata/linux-x86_64-test1.cpuinfo index e88a48ff3..706b69a54 100644 --- a/tests/virhostcpudata/linux-x86_64-test1.cpuinfo +++ b/tests/virhostcpudata/linux-x86_64-test1.cpuinfo @@ -28,6 +28,10 @@ model : 4 model name : Intel(R) Xeon(TM) CPU 2.80GHz stepping : 8 cpu MHz : 2800.000 +# The following field is a made-up one, intended to make sure our cpuinfo +# parser deals correctly with the introduction of new fields that just so +# happen to share a prefix with the one used for CPU frequency +cpu MHz rounded up to GHz : 3000.000 cache size : 2048 KB physical id : 0 siblings : 2 -- 2.14.3
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
-- IBM Systems Linux on z Systems & Virtualization Development ------------------------------------------------------------------------ IBM Deutschland Schönaicher Str. 220 71032 Böblingen Phone: +49 7031 16 1819 E-Mail: bwalk@de.ibm.com ------------------------------------------------------------------------ IBM Deutschland Research & Development GmbH Vorsitzende des Aufsichtsrats: Martina Koederitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294

On Thu, 2017-12-14 at 14:55 +0100, Bjoern Walk wrote:
+ * Returns: 0 when the string has been parsed successfully and the CPU + * frequency has been stored in @mhz, >0 when the string has not
Maybe, >0 when the line prefix does not match exactly?
Documentation goes out of sync with reality quickly enough when the language used is purposefully vague ;)
+ /* Skip the colon. If anything but a colon is found, then we're + * not looking at the right string and we should move on */ + if (*str != ':') + return 1; + str++;
You could do *str++ != ':' and save one line.
I'd rather not. Lines are cheap :) -- Andrea Bolognani / Red Hat / Virtualization

Andrea Bolognani <abologna@redhat.com> [2017-12-14, 03:01PM +0100]:
On Thu, 2017-12-14 at 14:55 +0100, Bjoern Walk wrote:
+ * Returns: 0 when the string has been parsed successfully and the CPU + * frequency has been stored in @mhz, >0 when the string has not
Maybe, >0 when the line prefix does not match exactly?
Documentation goes out of sync with reality quickly enough when the language used is purposefully vague ;)
+ /* Skip the colon. If anything but a colon is found, then we're + * not looking at the right string and we should move on */ + if (*str != ':') + return 1; + str++;
You could do *str++ != ':' and save one line.
I'd rather not. Lines are cheap :)
Yeah, this was just nit-picking. Looks like I forgot my rb, so Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
-- Andrea Bolognani / Red Hat / Virtualization
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
-- IBM Systems Linux on z Systems & Virtualization Development ------------------------------------------------------------------------ IBM Deutschland Schönaicher Str. 220 71032 Böblingen Phone: +49 7031 16 1819 E-Mail: bwalk@de.ibm.com ------------------------------------------------------------------------ IBM Deutschland Research & Development GmbH Vorsitzende des Aufsichtsrats: Martina Koederitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294

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@redhat.com> --- src/util/virhostcpu.c | 6 ++++-- tests/virhostcpudata/linux-aarch64-rhel74-moonshot.expected | 2 +- tests/virhostcpudata/linux-armv6l-raspberrypi.expected | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index 9c9f362de..1c9ee5921 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -590,12 +590,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", 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

On 12/14/2017 07:34 AM, Andrea Bolognani wrote:
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@redhat.com> --- src/util/virhostcpu.c | 6 ++++-- tests/virhostcpudata/linux-aarch64-rhel74-moonshot.expected | 2 +- tests/virhostcpudata/linux-armv6l-raspberrypi.expected | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-)
Suggestion - follow cmdNodeinfo for virhostcputest.c and don't print the MHz if it's 0. It's the indication that the data wasn't obtainable. I think printing 0 is perhaps just as bad as printing the erroneous 100. I trust you can make the adjustment without another round of patches. Reviewed-by: John Ferlan <jferlan@redhat.com> John
diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index 9c9f362de..1c9ee5921 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -590,12 +590,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", 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

On Fri, 2018-01-05 at 15:52 -0500, John Ferlan wrote:
Suggestion - follow cmdNodeinfo for virhostcputest.c and don't print the MHz if it's 0. It's the indication that the data wasn't obtainable. I think printing 0 is perhaps just as bad as printing the erroneous 100.
I trust you can make the adjustment without another round of patches.
Good idea. However, I've implemented it as a separate patch for a few reasons: * I've converted the test to use virBuffer, so the changes are not trivial enough that I feel comfortable pushing them without review; * there are already a couple of files that contain 'MHz: 0' in the test suite, so it feels cleaner to change all of them at once; * it's better to avoid performing more than one change per commit. The follow-up patch is already on the list, in case you feel like taking a look at it :) -- Andrea Bolognani / Red Hat / Virtualization

A very 2018 ping :) On Thu, 2017-12-14 at 13:33 +0100, Andrea Bolognani wrote:
Changes from [v2]:
* improve the parser; * print the architecture name instead of "your architecture".
Changes from [v1]:
* adopt Bjoern's approach to refactoring.
[v2] https://www.redhat.com/archives/libvir-list/2017-December/msg00467.html [v1] https://www.redhat.com/archives/libvir-list/2017-December/msg00356.html
Andrea Bolognani (4): tests: Add host CPU data for Moonshot (RHEL 7.4) util: Print architecture name in /proc/cpuinfo parser util: Improve CPU frequency parsing util: Don't report CPU frequency for ARM hosts
Bjoern Walk (1): util: virhostcpu: factor out frequency parsing
-- Andrea Bolognani / Red Hat / Virtualization
participants (3)
-
Andrea Bolognani
-
Bjoern Walk
-
John Ferlan