]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
cpu-gather: Allow overwriting cpuid binary location
authorTim Wiederhake <twiederh@redhat.com>
Tue, 15 Dec 2020 16:24:52 +0000 (17:24 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 18 Dec 2020 22:19:51 +0000 (23:19 +0100)
This is useful if cpuid was compiled from source in a non-standard
location.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tests/cputestdata/cpu-gather.py

index 97655399c80b3424c474624d75b247f08c5a02ab..75cf290a28d7ad50a0fc7966322e6fb85f96faa8 100755 (executable)
@@ -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))