Previously, the script only generated the parent CPU and any versions
that had a defined alias. Now generate all CPU versions. Any version
that had a defined alias will continue to use that alias, but those
without aliases will use the generated name $BASECPUNAME-vN. This
generated name will be used as an alternate name for those CPU versions
with defined aliases.
Signed-off-by: Jonathon Jongsma <jjongsma(a)redhat.com>
---
src/cpu_map/sync_qemu_models_i386.py | 44 +++++++++++++++++++++++-----
1 file changed, 36 insertions(+), 8 deletions(-)
diff --git a/src/cpu_map/sync_qemu_models_i386.py b/src/cpu_map/sync_qemu_models_i386.py
index 1c6a2d4d27..956e4700de 100755
--- a/src/cpu_map/sync_qemu_models_i386.py
+++ b/src/cpu_map/sync_qemu_models_i386.py
@@ -322,31 +322,55 @@ def expand_model(model):
different fields and may have differing versions into several libvirt-
friendly cpu models."""
- result = {
- "name": model.pop(".name"),
+ basename = model.pop(".name")
+ parent = {
+ "name": basename,
+ "alias": None,
"vendor": translate_vendor(model.pop(".vendor")),
"features": set(),
"extra": dict()}
if ".family" in model and ".model" in model:
- result["family"] = model.pop(".family")
- result["model"] = model.pop(".model")
+ parent["family"] = model.pop(".family")
+ parent["model"] = model.pop(".model")
for k in [k for k in model if k.startswith(".features")]:
v = model.pop(k)
for feature in v.split():
translated = translate_feature(feature)
if translated:
- result["features"].add(translated)
+ parent["features"].add(translated)
versions = model.pop(".versions", [])
for k, v in model.items():
- result["extra"]["model" + k] = v
- yield result
+ parent["extra"]["model" + k] = v
+
+ result = parent
for version in versions:
+ # each version builds on the previous one
result = copy.deepcopy(result)
- result["name"] = version.pop(".alias",
result["name"])
+ vnum = int(version.pop(".version"))
+ vname = "{}-v{}".format(basename, vnum)
+ if vnum == 1:
+ # the first version should always be an alias for the parent and
+ # should therefore have no extra properties
+ if version.items():
+ raise RuntimeError("Unexpected properties in version 1")
+ # just treat this version as an alias of the parent model and don't
+ # generate a new CPU model
+ parent["alias"] = vname
+ continue
+
+ # prefer the 'alias' over the generated the name if it exists since we
+ # have already been using these aliases
+ alias = version.pop(".alias", None)
+ if alias:
+ result["name"] = alias
+ result["alias"] = vname
+ else:
+ result["name"] = vname
+ result["alias"] = None
props = version.pop(".props", dict())
for k, v in props:
@@ -367,6 +391,8 @@ def expand_model(model):
yield result
+ yield parent
+
def output_model(f, model):
if model["extra"]:
@@ -377,6 +403,8 @@ def output_model(f, model):
f.write("<cpus>\n")
f.write(" <model
name='{}'>\n".format(model["name"]))
+ if model["alias"]:
+ f.write(" <alias
name='{}'/>\n".format(model["alias"]))
f.write(" <decode host='on' guest='on'/>\n")
f.write(" <signature family='{}'
model='{}'/>\n".format(
model["family"], model["model"]))
--
2.41.0