]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
cpu-gather: Move static model extraction to new script
authorTim Wiederhake <twiederh@redhat.com>
Tue, 15 Dec 2020 16:24:56 +0000 (17:24 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 18 Dec 2020 22:20:05 +0000 (23:20 +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 e4a82fc9494a691bb89a1b8977d0437b88f92890..0c8d8e93d0e1a7c064a94a1b11f8027ea6b9997e 100755 (executable)
@@ -91,7 +91,9 @@ def call_qemu(qemu, qmp_cmds):
     except FileNotFoundError:
         exit("Error: File not found: '{}'.".format(qemu))
 
-    return output
+    for line in output.split("\n"):
+        if line:
+            yield json.loads(line)
 
 
 def gather_static_model(args):
@@ -105,7 +107,12 @@ def gather_static_model(args):
             },
             "id": "model-expansion"
         }])
-    return output
+
+    for o in output:
+        if o.get("id") == "model-expansion":
+            return o["return"]["model"]
+
+    return None
 
 
 def main():
@@ -158,7 +165,7 @@ def main():
     print(end="", flush=True)
     os.environ["CPU_GATHER_PY"] = "true"
     os.environ["qemu"] = args.path_to_qemu
-    os.environ["model"] = static_model
+    os.environ["model"] = json.dumps(static_model) if static_model else ""
     subprocess.check_call("./cpu-gather.sh")
 
 
index af0f40b61c6d97393bf3b0ab09f402538dd09299..726f0139084d9e26fe35fc593e0306cb7d24e14c 100755 (executable)
@@ -21,11 +21,6 @@ model_expansion()
          '{"type":"'"$mode"'","model":'"$model"'},"id":"model-expansion"}'
 }
 
-model=$(
-    echo "$model" | \
-    sed -ne 's/^{"return": {"model": {\(.*{.*}\)}}, .*/{\1}/p'
-)
-
 $qemu -machine accel=kvm -cpu host -nodefaults -nographic -qmp stdio <<EOF
 {"execute":"qmp_capabilities"}
 $(