From db127963d56cd46723e35ecdde55b48cfdfa4cfa Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Mon, 21 Oct 2024 13:25:51 +0200 Subject: [PATCH] sync_qemu_models_i386: Add support for versioned CPU models MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 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 Reviewed-by: Daniel P. Berrangé --- 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("\n") f.write(f" \n") - f.write(" \n") - f.write(f" \n") - f.write(f" \n") + f.write(f" \n") + + if "alias" in model: + f.write(f" \n") + else: + f.write(f" \n") + f.write(f" \n") + for feature in sorted(model["features"]): f.write(f" \n") f.write(" \n")