mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +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,
|
virQEMUCapsProbeQMPCPUDefinitions(virQEMUCapsPtr qemuCaps,
|
||||||
qemuMonitorPtr mon,
|
qemuMonitorPtr mon,
|
||||||
bool tcg)
|
bool tcg)
|
||||||
|
@ -101,4 +101,9 @@ virQEMUCapsParseHelpStr(const char *qemu,
|
|||||||
int
|
int
|
||||||
virQEMUCapsParseDeviceStr(virQEMUCapsPtr qemuCaps,
|
virQEMUCapsParseDeviceStr(virQEMUCapsPtr qemuCaps,
|
||||||
const char *str);
|
const char *str);
|
||||||
|
|
||||||
|
int
|
||||||
|
virQEMUCapsProbeQMPCPUDefinitions(virQEMUCapsPtr qemuCaps,
|
||||||
|
qemuMonitorPtr mon,
|
||||||
|
bool tcg);
|
||||||
#endif
|
#endif
|
||||||
|
@ -673,6 +673,7 @@ cpuTestUpdateLive(const void *arg)
|
|||||||
typedef enum {
|
typedef enum {
|
||||||
JSON_NONE,
|
JSON_NONE,
|
||||||
JSON_HOST,
|
JSON_HOST,
|
||||||
|
JSON_MODELS,
|
||||||
} cpuTestCPUIDJson;
|
} cpuTestCPUIDJson;
|
||||||
|
|
||||||
#if WITH_QEMU && WITH_YAJL
|
#if WITH_QEMU && WITH_YAJL
|
||||||
@ -704,10 +705,19 @@ cpuTestJSONCPUID(const void *arg)
|
|||||||
if (!(qemuCaps = virQEMUCapsNew()))
|
if (!(qemuCaps = virQEMUCapsNew()))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_KVM);
|
||||||
|
if (data->flags == JSON_MODELS)
|
||||||
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_QUERY_CPU_DEFINITIONS);
|
||||||
|
|
||||||
virQEMUCapsSetArch(qemuCaps, data->arch);
|
virQEMUCapsSetArch(qemuCaps, data->arch);
|
||||||
virQEMUCapsSetCPUModelInfo(qemuCaps, VIR_DOMAIN_VIRT_KVM, model);
|
virQEMUCapsSetCPUModelInfo(qemuCaps, VIR_DOMAIN_VIRT_KVM, model);
|
||||||
model = NULL;
|
model = NULL;
|
||||||
|
|
||||||
|
if (virQEMUCapsProbeQMPCPUDefinitions(qemuCaps,
|
||||||
|
qemuMonitorTestGetMonitor(testMon),
|
||||||
|
false) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (VIR_ALLOC(cpu) < 0)
|
if (VIR_ALLOC(cpu) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -870,7 +880,7 @@ mymain(void)
|
|||||||
do { \
|
do { \
|
||||||
if (json != JSON_NONE) { \
|
if (json != JSON_NONE) { \
|
||||||
DO_TEST(arch, cpuTestJSONCPUID, host, host, \
|
DO_TEST(arch, cpuTestJSONCPUID, host, host, \
|
||||||
NULL, NULL, 0, 0); \
|
NULL, NULL, json, 0); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
#else
|
#else
|
||||||
|
@ -228,17 +228,22 @@ def parseFeatureWords(path):
|
|||||||
s = f.read()
|
s = f.read()
|
||||||
|
|
||||||
props = {}
|
props = {}
|
||||||
for i in range(5):
|
rest = []
|
||||||
|
chunk = 0
|
||||||
|
while s != "":
|
||||||
(data, pos) = dec.raw_decode(s)
|
(data, pos) = dec.raw_decode(s)
|
||||||
if i == 0:
|
if chunk == 0:
|
||||||
features = data["return"]
|
features = data["return"]
|
||||||
else:
|
elif chunk < 5:
|
||||||
keys = ["family", "model", "stepping", "model-id"]
|
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] != "{":
|
while pos < len(s) and s[pos] != "{":
|
||||||
pos += 1
|
pos += 1
|
||||||
s = s[pos:]
|
s = s[pos:]
|
||||||
|
chunk += 1
|
||||||
|
|
||||||
if props["model-id"].find("Intel") != -1:
|
if props["model-id"].find("Intel") != -1:
|
||||||
props["vendor"] = "GenuineIntel"
|
props["vendor"] = "GenuineIntel"
|
||||||
@ -255,13 +260,13 @@ def parseFeatureWords(path):
|
|||||||
leaf = cpuidLeaf(cpuid, in_eax, in_ecx)
|
leaf = cpuidLeaf(cpuid, in_eax, in_ecx)
|
||||||
leaf[feat["cpuid-register"].lower()] = feat["features"]
|
leaf[feat["cpuid-register"].lower()] = feat["features"]
|
||||||
|
|
||||||
return props, cpuid
|
return props, cpuid, rest
|
||||||
|
|
||||||
|
|
||||||
def parseQemu(path, features):
|
def parseQemu(path, features):
|
||||||
cpuid = {}
|
cpuid = {}
|
||||||
with open(path, "r") as f:
|
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():
|
for (prop, val) in data["return"]["model"]["props"].iteritems():
|
||||||
if val and prop in features:
|
if val and prop in features:
|
||||||
@ -288,6 +293,7 @@ def parseCpuid(path):
|
|||||||
|
|
||||||
|
|
||||||
def formatCpuid(cpuid, path, comment):
|
def formatCpuid(cpuid, path, comment):
|
||||||
|
print path
|
||||||
with open(path, "w") as f:
|
with open(path, "w") as f:
|
||||||
f.write("<!-- " + comment + " -->\n")
|
f.write("<!-- " + comment + " -->\n")
|
||||||
f.write("<cpudata arch='x86'>\n")
|
f.write("<cpudata arch='x86'>\n")
|
||||||
@ -304,19 +310,25 @@ def formatCpuid(cpuid, path, comment):
|
|||||||
|
|
||||||
|
|
||||||
def convert(path):
|
def convert(path):
|
||||||
props, cpuid = parseFeatureWords(path)
|
props, cpuid, rest = parseFeatureWords(path)
|
||||||
|
|
||||||
for feature in cpuidMap:
|
for feature in cpuidMap:
|
||||||
value = cpuidIsSet(cpuid, feature)
|
value = cpuidIsSet(cpuid, feature)
|
||||||
for name in feature["names"]:
|
for name in feature["names"]:
|
||||||
props[name] = value
|
props[name] = value
|
||||||
|
|
||||||
|
print path
|
||||||
with open(path, "w") as f:
|
with open(path, "w") as f:
|
||||||
json.dump({"return": {"model": {"name": "base", "props": props}},
|
json.dump({"return": {"model": {"name": "base", "props": props}},
|
||||||
"id": "model-expansion"},
|
"id": "model-expansion"},
|
||||||
f, indent = 2, separators = (',', ': '))
|
f, indent = 2, separators = (',', ': '))
|
||||||
f.write("\n")
|
f.write("\n")
|
||||||
|
|
||||||
|
for chunk in rest:
|
||||||
|
f.write("\n")
|
||||||
|
json.dump(chunk, f, indent = 2, separators = (',', ': '))
|
||||||
|
f.write("\n")
|
||||||
|
|
||||||
|
|
||||||
def diff(features, path):
|
def diff(features, path):
|
||||||
base = path.replace(".json", "")
|
base = path.replace(".json", "")
|
||||||
|
@ -58,5 +58,6 @@ $(
|
|||||||
qom_get model-id
|
qom_get model-id
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
|
{"execute":"query-cpu-definitions","id":"definitions"}
|
||||||
{"execute":"quit"}
|
{"execute":"quit"}
|
||||||
EOF
|
EOF
|
||||||
|
Loading…
Reference in New Issue
Block a user