]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
cputest: Test CPU usability blockers
authorJiri Denemark <jdenemar@redhat.com>
Tue, 26 Sep 2017 19:08:37 +0000 (21:08 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Mon, 16 Oct 2017 07:23:20 +0000 (09:23 +0200)
Gather query-cpu-definitions results and use them for testing CPU model
usability blockers in CPUID to virCPUDef translation.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/qemu/qemu_capabilities.c
src/qemu/qemu_capspriv.h
tests/cputest.c
tests/cputestdata/cpu-cpuid.py
tests/cputestdata/cpu-gather.sh

index 8803980495714abe738decd7f94ace9b2fe86c97..4de411e397bf0db9a46cbcffb64ad6f067353df1 100644 (file)
@@ -2933,7 +2933,7 @@ virQEMUCapsProbeQMPMachineTypes(virQEMUCapsPtr qemuCaps,
 }
 
 
-static int
+int
 virQEMUCapsProbeQMPCPUDefinitions(virQEMUCapsPtr qemuCaps,
                                   qemuMonitorPtr mon,
                                   bool tcg)
index d05256bd359ccd68c4ce0cdfcc426d5ac4655f0f..f23995ec6e0aa9acc42364988fbf0a5f863324b9 100644 (file)
@@ -101,4 +101,9 @@ virQEMUCapsParseHelpStr(const char *qemu,
 int
 virQEMUCapsParseDeviceStr(virQEMUCapsPtr qemuCaps,
                           const char *str);
+
+int
+virQEMUCapsProbeQMPCPUDefinitions(virQEMUCapsPtr qemuCaps,
+                                  qemuMonitorPtr mon,
+                                  bool tcg);
 #endif
index dcfdf57d439c3ed7935e55430ede7ddb313449cd..0a07a2da14732526bdf2368f8befcb08f06096dc 100644 (file)
@@ -673,6 +673,7 @@ cpuTestUpdateLive(const void *arg)
 typedef enum {
     JSON_NONE,
     JSON_HOST,
+    JSON_MODELS,
 } cpuTestCPUIDJson;
 
 #if WITH_QEMU && WITH_YAJL
@@ -704,10 +705,19 @@ cpuTestJSONCPUID(const void *arg)
     if (!(qemuCaps = virQEMUCapsNew()))
         goto cleanup;
 
+    virQEMUCapsSet(qemuCaps, QEMU_CAPS_KVM);
+    if (data->flags == JSON_MODELS)
+        virQEMUCapsSet(qemuCaps, QEMU_CAPS_QUERY_CPU_DEFINITIONS);
+
     virQEMUCapsSetArch(qemuCaps, data->arch);
     virQEMUCapsSetCPUModelInfo(qemuCaps, VIR_DOMAIN_VIRT_KVM, model);
     model = NULL;
 
+    if (virQEMUCapsProbeQMPCPUDefinitions(qemuCaps,
+                                          qemuMonitorTestGetMonitor(testMon),
+                                          false) < 0)
+        goto cleanup;
+
     if (VIR_ALLOC(cpu) < 0)
         goto cleanup;
 
@@ -870,7 +880,7 @@ mymain(void)
     do {                                                                \
         if (json != JSON_NONE) {                                        \
             DO_TEST(arch, cpuTestJSONCPUID, host, host,                 \
-                    NULL, NULL, 0, 0);                                  \
+                    NULL, NULL, json, 0);                               \
         }                                                               \
     } while (0)
 #else
index a2fd938c24c234b0279d07c2b83dce5d699c145f..4fe8e8b9528d436783412152f93a567563ce2c39 100755 (executable)
@@ -228,17 +228,22 @@ def parseFeatureWords(path):
         s = f.read()
 
     props = {}
-    for i in range(5):
+    rest = []
+    chunk = 0
+    while s != "":
         (data, pos) = dec.raw_decode(s)
-        if i == 0:
+        if chunk == 0:
             features = data["return"]
-        else:
+        elif chunk < 5:
             keys = ["family", "model", "stepping", "model-id"]
-            props[keys[i - 1]] = data["return"]
+            props[keys[chunk - 1]] = data["return"]
+        else:
+            rest.append(data)
 
         while pos < len(s) and s[pos] != "{":
             pos += 1
         s = s[pos:]
+        chunk += 1
 
     if props["model-id"].find("Intel") != -1:
         props["vendor"] = "GenuineIntel"
@@ -255,13 +260,13 @@ def parseFeatureWords(path):
         leaf = cpuidLeaf(cpuid, in_eax, in_ecx)
         leaf[feat["cpuid-register"].lower()] = feat["features"]
 
-    return props, cpuid
+    return props, cpuid, rest
 
 
 def parseQemu(path, features):
     cpuid = {}
     with open(path, "r") as f:
-        data = json.load(f)
+        data, pos = json.JSONDecoder().raw_decode(f.read())
 
     for (prop, val) in data["return"]["model"]["props"].iteritems():
         if val and prop in features:
@@ -288,6 +293,7 @@ def parseCpuid(path):
 
 
 def formatCpuid(cpuid, path, comment):
+    print path
     with open(path, "w") as f:
         f.write("<!-- " + comment + " -->\n")
         f.write("<cpudata arch='x86'>\n")
@@ -304,19 +310,25 @@ def formatCpuid(cpuid, path, comment):
 
 
 def convert(path):
-    props, cpuid = parseFeatureWords(path)
+    props, cpuid, rest = parseFeatureWords(path)
 
     for feature in cpuidMap:
         value = cpuidIsSet(cpuid, feature)
         for name in feature["names"]:
             props[name] = value
 
+    print path
     with open(path, "w") as f:
         json.dump({"return": {"model": {"name": "base", "props": props}},
                    "id": "model-expansion"},
                   f, indent = 2, separators = (',', ': '))
         f.write("\n")
 
+        for chunk in rest:
+            f.write("\n")
+            json.dump(chunk, f, indent = 2, separators = (',', ': '))
+            f.write("\n")
+
 
 def diff(features, path):
     base = path.replace(".json", "")
index 83963557ec4075d351be09e17994ac5300bc5d1f..9c696f57bdbcc4d906a91d7cba178aac20df0192 100755 (executable)
@@ -58,5 +58,6 @@ $(
         qom_get model-id
     fi
 )
+{"execute":"query-cpu-definitions","id":"definitions"}
 {"execute":"quit"}
 EOF