typedef enum {
JSON_NONE,
JSON_HOST,
+ JSON_MODELS,
} cpuTestCPUIDJson;
#if WITH_QEMU && WITH_YAJL
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;
do { \
if (json != JSON_NONE) { \
DO_TEST(arch, cpuTestJSONCPUID, host, host, \
- NULL, NULL, 0, 0); \
+ NULL, NULL, json, 0); \
} \
} while (0)
#else
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"
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:
def formatCpuid(cpuid, path, comment):
+ print path
with open(path, "w") as f:
f.write("<!-- " + comment + " -->\n")
f.write("<cpudata arch='x86'>\n")
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", "")