]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
cpu-gather: Move model_name to new script
authorTim Wiederhake <twiederh@redhat.com>
Tue, 15 Dec 2020 16:24:49 +0000 (17:24 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 18 Dec 2020 22:19:37 +0000 (23:19 +0100)
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 f7030eb48bc22cc4dfe348f81a6c161b95261a88..1b02df6ec7d646480767b6a65d8e4a1aff2f9fa4 100755 (executable)
@@ -4,7 +4,20 @@ import os
 import subprocess
 
 
+def gather_name():
+    with open("/proc/cpuinfo", "rt") as f:
+        for line in f.readlines():
+            if line.startswith("model name"):
+                return line.split(":", 2)[1].strip()
+
+    exit("Error: '/proc/cpuinfo' does not contain a model name.")
+
+
 def main():
+    name = gather_name()
+    print("model name\t: {}".format(name))
+
+    print(end="", flush=True)
     os.environ["CPU_GATHER_PY"] = "true"
     subprocess.check_call("./cpu-gather.sh")
 
index cd65d74da5e2c6734cea78cdca34aa4b4c8e6129..b671f223a5c9e5a41413923f060219bc2bd23fb4 100755 (executable)
@@ -9,8 +9,6 @@ if [ -z "${CPU_GATHER_PY}" ]; then
     exit 1
 fi
 
-grep 'model name' /proc/cpuinfo | head -n1
-
 cpuid -1r
 echo