[PATCH 30/36] cputest: Generalize feature parsing in cpu-cpuid.py

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The parseMapFeature for parsing features from CPU map XML can be easily
generalized to support more feature types.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 tests/cputestdata/cpu-cpuid.py | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/tests/cputestdata/cpu-cpuid.py b/tests/cputestdata/cpu-cpuid.py
index ac69c5a012..89efc3a40c 100755
--- a/tests/cputestdata/cpu-cpuid.py
+++ b/tests/cputestdata/cpu-cpuid.py
@@ -85,17 +85,20 @@ def parseCPUData(path):
     return cpuData
 
 
-def parseMapFeature(data):
-    cpuid = {"type": "cpuid"}
-    for reg in ["eax_in", "ecx_in", "eax", "ebx", "ecx", "edx"]:
-        attr = "@%s" % reg
+def parseMapFeature(fType, data):
+    ret = {"type": fType}
 
+    if fType == "cpuid":
+        fields = ["eax_in", "ecx_in", "eax", "ebx", "ecx", "edx"]
+
+    for field in fields:
+        attr = "@%s" % field
         if attr in data:
-            cpuid[reg] = int(data[attr], 0)
+            ret[field] = int(data[attr], 0)
         else:
-            cpuid[reg] = 0
+            ret[field] = 0
 
-    return cpuid
+    return ret
 
 
 def parseMap():
@@ -106,8 +109,9 @@ def parseMap():
 
     cpuMap = {}
     for feature in data["cpus"]["feature"]:
-        if "cpuid" in feature:
-            cpuMap[feature["@name"]] = parseMapFeature(feature["cpuid"])
+        for fType in ["cpuid"]:
+            if fType in feature:
+                cpuMap[feature["@name"]] = parseMapFeature(fType, feature[fType])
 
     return cpuMap
 
-- 
2.21.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux