[libvirt PATCH 11/29] cpu-gather: Move simple model extraction to new script

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


Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
---
 tests/cputestdata/cpu-gather.py | 60 +++++++++++++++++++++++++++++++++
 tests/cputestdata/cpu-gather.sh | 13 -------
 2 files changed, 60 insertions(+), 13 deletions(-)

diff --git a/tests/cputestdata/cpu-gather.py b/tests/cputestdata/cpu-gather.py
index 0c8d8e93d0..5c03d226b6 100755
--- a/tests/cputestdata/cpu-gather.py
+++ b/tests/cputestdata/cpu-gather.py
@@ -115,6 +115,63 @@ def gather_static_model(args):
     return None
 
 
+def gather_full_model(args, static_model):
+    if static_model:
+        return []
+    else:
+        return call_qemu(args.path_to_qemu, [
+            {
+                "execute": "qom-get",
+                "arguments":
+                {
+                    "path": "/machine/unattached/device[0]",
+                    "property": "feature-words"
+                },
+                "id": "feature-words"
+            },
+            {
+                "execute": "qom-get",
+                "arguments":
+                {
+                    "path": "/machine/unattached/device[0]",
+                    "property": "family"
+                },
+                "id": "family"
+            },
+            {
+                "execute": "qom-get",
+                "arguments":
+                {
+                    "path": "/machine/unattached/device[0]",
+                    "property": "model"
+                },
+                "id": "model"
+            },
+            {
+                "execute": "qom-get",
+                "arguments":
+                {
+                    "path": "/machine/unattached/device[0]",
+                    "property": "stepping"
+                },
+                "id": "stepping"
+            },
+            {
+                "execute": "qom-get",
+                "arguments":
+                {
+                    "path": "/machine/unattached/device[0]",
+                    "property": "model-id"
+                },
+                "id": "model-id"
+            },
+            {
+                "execute": "query-cpu-definitions",
+                "id": "definitions"
+            }
+        ])
+
+
 def main():
     parser = argparse.ArgumentParser(description="Gather cpu test data")
     parser.add_argument(
@@ -161,6 +218,9 @@ def main():
             print("   0x{:x}: 0x{:016x}\n".format(int(key), value))
 
     static_model = gather_static_model(args)
+    model = gather_full_model(args, static_model)
+    for o in model:
+        print(json.dumps(o))
 
     print(end="", flush=True)
     os.environ["CPU_GATHER_PY"] = "true"
diff --git a/tests/cputestdata/cpu-gather.sh b/tests/cputestdata/cpu-gather.sh
index 726f013908..05faf14a96 100755
--- a/tests/cputestdata/cpu-gather.sh
+++ b/tests/cputestdata/cpu-gather.sh
@@ -5,13 +5,6 @@ if [ -z "${CPU_GATHER_PY}" ]; then
     exit 1
 fi
 
-qom_get()
-{
-    path='/machine/unattached/device[0]'
-    echo '{"execute":"qom-get","arguments":{"path":"'$path'",' \
-         '"property":"'$1'"},"id":"'$1'"}'
-}
-
 model_expansion()
 {
     mode=$1
@@ -26,12 +19,6 @@ $qemu -machine accel=kvm -cpu host -nodefaults -nographic -qmp stdio <<EOF
 $(
     if [ "x$model" != x ]; then
         model_expansion full "$model"
-    else
-        qom_get feature-words
-        qom_get family
-        qom_get model
-        qom_get stepping
-        qom_get model-id
     fi
 )
 {"execute":"query-cpu-definitions","id":"definitions"}
-- 
2.26.2




More information about the libvir-list mailing list