[libvirt PATCH 06/29] cpu-gather: Allow overwriting cpuid binary location

Tim Wiederhake twiederh at redhat.com
Tue Dec 15 16:24:52 UTC 2020


This is useful if cpuid was compiled from source in a non-standard
location.

Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
---
 tests/cputestdata/cpu-gather.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/tests/cputestdata/cpu-gather.py b/tests/cputestdata/cpu-gather.py
index 97655399c8..75cf290a28 100755
--- a/tests/cputestdata/cpu-gather.py
+++ b/tests/cputestdata/cpu-gather.py
@@ -18,10 +18,11 @@ def gather_name(args):
          "Use '--model' to set a model name.")
 
 
-def gather_cpuid_leaves():
+def gather_cpuid_leaves(args):
+    cpuid = args.path_to_cpuid or "cpuid"
     try:
         output = subprocess.check_output(
-            ["cpuid", "-1r"],
+            [cpuid, "-1r"],
             universal_newlines=True)
     except FileNotFoundError as e:
         exit("Error: '{}' not found.\n'cpuid' can be usually found in a "
@@ -43,13 +44,18 @@ def main():
         "--name",
         help="CPU model name. "
         "If unset, model name is read from '/proc/cpuinfo'.")
+    parser.add_argument(
+        "--path-to-cpuid",
+        metavar="PATH",
+        help="Path to 'cpuid' utility. "
+        "If unset, the first executable 'cpuid' in $PATH is used.")
 
     args = parser.parse_args()
 
     name = gather_name(args)
     print("model name\t: {}".format(name))
 
-    leaves = gather_cpuid_leaves()
+    leaves = gather_cpuid_leaves(args)
     print("CPU:")
     for leave in leaves:
         print("   {}".format(leave))
-- 
2.26.2




More information about the libvir-list mailing list