]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
cpu-gather: Move cpuid call to new script
authorTim Wiederhake <twiederh@redhat.com>
Tue, 15 Dec 2020 16:24:51 +0000 (17:24 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 18 Dec 2020 22:19:46 +0000 (23:19 +0100)
Turn the comment on how to aquire cpuid into a runtime error message.
Use "http" instead of "https" in the URL, as the latter is broken.

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

index 4e8c72e4f41e497fda1ab9c67160c9ddc3ea233b..97655399c80b3424c474624d75b247f08c5a02ab 100755 (executable)
@@ -18,6 +18,25 @@ def gather_name(args):
          "Use '--model' to set a model name.")
 
 
+def gather_cpuid_leaves():
+    try:
+        output = subprocess.check_output(
+            ["cpuid", "-1r"],
+            universal_newlines=True)
+    except FileNotFoundError as e:
+        exit("Error: '{}' not found.\n'cpuid' can be usually found in a "
+             "package named identically. If your distro does not provide such "
+             "package, you can find the sources or binary packages at "
+             "'http://www.etallen.com/cpuid.html'.".format(e.filename))
+
+    for line in output.split("\n"):
+        if not line:
+            continue
+        if line == "CPU:":
+            continue
+        yield line.strip()
+
+
 def main():
     parser = argparse.ArgumentParser(description="Gather cpu test data")
     parser.add_argument(
@@ -30,6 +49,12 @@ def main():
     name = gather_name(args)
     print("model name\t: {}".format(name))
 
+    leaves = gather_cpuid_leaves()
+    print("CPU:")
+    for leave in leaves:
+        print("   {}".format(leave))
+    print()
+
     print(end="", flush=True)
     os.environ["CPU_GATHER_PY"] = "true"
     subprocess.check_call("./cpu-gather.sh")
index b671f223a5c9e5a41413923f060219bc2bd23fb4..f84215e7771409070f73d93158ac21f98029ee55 100755 (executable)
@@ -1,17 +1,10 @@
 #!/bin/bash
-#
-# The cpuid tool can be usually found in a package called "cpuid". If your
-# distro does not provide such package, you can find the sources or binary
-# packages at https://www.etallen.com/cpuid.html
 
 if [ -z "${CPU_GATHER_PY}" ]; then
     echo >&2 "Do not call this script directly. Use 'cpu-gather.py' instead."
     exit 1
 fi
 
-cpuid -1r
-echo
-
 python3 <<EOF
 from struct import pack, unpack
 from fcntl import ioctl