Each CPU model with -v* suffix is defined as a standalone model copying
all attributes of the previous version. CPU model versions with an alias
are handled differently. The full definition is used for the alias and
the versioned model is created as an identical copy of the alias.
To avoid breaking migration compatibility of host-model CPUs all
versioned models are marked with <decode guest='off'/> so that they are
ignored when selecting candidates for host-model. It's not ideal but not
doing so would break almost all host-model CPUs as the new versioned CPU
models have all vmx-* features included since their introduction while
existing CPU models were updated later. This meas existing models would
be accompanied with a long list of vmx-* features to properly describe a
host CPU while the newly added CPU models would have those features
enabled implicitly and their list of features would be significantly
shorter. Thus the new models would always be better candidates for
host-model than the existing models.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
Notes:
Version 2:
- make -v? variants linked to their corresponding non-versioned models
(such as -noTSX, -IBRS, etc.)
- all -v? variants are marked with <decode guest='off'/>
src/cpu_map/sync_qemu_models_i386.py | 44 ++++++++++++++++++++++++----
1 file changed, 39 insertions(+), 5 deletions(-)
diff --git a/src/cpu_map/sync_qemu_models_i386.py b/src/cpu_map/sync_qemu_models_i386.py
index 13f62780e6..5169d50b08 100755
--- a/src/cpu_map/sync_qemu_models_i386.py
+++ b/src/cpu_map/sync_qemu_models_i386.py
@@ -454,11 +454,21 @@ def expand_model(model):
versions = model.pop(".versions", [])
for k, v in model.items():
result["extra"]["model" + k] = v
+
+ print(result['name'])
yield result
+ name = result["name"]
for version in versions:
result = copy.deepcopy(result)
- result["name"] = version.pop(".alias", result["name"])
+
+ ver = int(version.pop(".version"))
+ result["name"] = f"{name}-v{ver}"
+ result["base"] = name
+
+ alias = version.pop(".alias", None)
+ if not alias and ver == 1:
+ alias = name
props = version.pop(".props", dict())
for k, v in props:
@@ -477,7 +487,24 @@ def expand_model(model):
for k, v in version.items():
result["extra"]["version" + k] = v
- yield result
+ if alias:
+ print(f"v{ver}: {result['name']} => {alias}")
+ yield {
+ "vendor": result["vendor"],
+ "name": result["name"],
+ "base": result["base"],
+ "alias": alias,
+ "extra": None,
+ "features": [],
+ }
+
+ if ver != 1:
+ result["name"] = alias
+ print(f"v{ver}: {result['name']}")
+ yield result
+ else:
+ print(f"v{ver}: {result['name']}")
+ yield result
def output_model(f, model):
@@ -487,11 +514,18 @@ def output_model(f, model):
f.write(f" '{k}': '{v}'\n")
f.write("-->\n")
+ decode = "off" if "base" in model else "on"
+
f.write("<cpus>\n")
f.write(f" <model name='{model['name']}'>\n")
- f.write(" <decode host='on' guest='on'/>\n")
- f.write(f" <signature family='{model['family']}' model='{model['model']}'/>\n")
- f.write(f" <vendor name='{model['vendor']}'/>\n")
+ f.write(f" <decode host='on' guest='{decode}'/>\n")
+
+ if "alias" in model:
+ f.write(f" <model name='{model['alias']}'/>\n")
+ else:
+ f.write(f" <signature family='{model['family']}' model='{model['model']}'/>\n")
+ f.write(f" <vendor name='{model['vendor']}'/>\n")
+
for feature in sorted(model["features"]):
f.write(f" <feature name='{feature}'/>\n")
f.write(" </model>\n")
--
2.47.0