mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
cputest: Test CPU usability blockers
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>
This commit is contained in:
parent
c517a6a369
commit
7bca16937a
@ -2933,7 +2933,7 @@ virQEMUCapsProbeQMPMachineTypes(virQEMUCapsPtr qemuCaps,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
int
|
||||
virQEMUCapsProbeQMPCPUDefinitions(virQEMUCapsPtr qemuCaps,
|
||||
qemuMonitorPtr mon,
|
||||
bool tcg)
|
||||
|
@ -101,4 +101,9 @@ virQEMUCapsParseHelpStr(const char *qemu,
|
||||
int
|
||||
virQEMUCapsParseDeviceStr(virQEMUCapsPtr qemuCaps,
|
||||
const char *str);
|
||||
|
||||
int
|
||||
virQEMUCapsProbeQMPCPUDefinitions(virQEMUCapsPtr qemuCaps,
|
||||
qemuMonitorPtr mon,
|
||||
bool tcg);
|
||||
#endif
|
||||
|
@ -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
|
||||
|
@ -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", "")
|
||||
|
@ -58,5 +58,6 @@ $(
|
||||
qom_get model-id
|
||||
fi
|
||||
)
|
||||
{"execute":"query-cpu-definitions","id":"definitions"}
|
||||
{"execute":"quit"}
|
||||
EOF
|
||||
|
Loading…
Reference in New Issue
Block a user