From nobody Sat Sep 6 23:16:26 2025 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1702678508582473.0677212250358; Fri, 15 Dec 2023 14:15:08 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 32EAD1A99; Fri, 15 Dec 2023 17:15:07 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 615CF1A9D; Fri, 15 Dec 2023 17:12:27 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id B5EF71AA3; Fri, 15 Dec 2023 17:12:13 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id E01531A90 for ; Fri, 15 Dec 2023 17:12:11 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-597-xaXjJAWiMtCdac9N05lSvw-1; Fri, 15 Dec 2023 17:12:09 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5E0F8869EC2 for ; Fri, 15 Dec 2023 22:12:09 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.34.110]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2758FC15E6A; Fri, 15 Dec 2023 22:12:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: xaXjJAWiMtCdac9N05lSvw-1 From: Jonathon Jongsma To: devel@lists.libvirt.org Subject: [PATCH v3 01/12] cpu_map: update script to handle versioned CPUs Date: Fri, 15 Dec 2023 16:11:57 -0600 Message-ID: <20231215221208.4138294-2-jjongsma@redhat.com> In-Reply-To: <20231215221208.4138294-1-jjongsma@redhat.com> References: <20231215221208.4138294-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: 64F7H2JAZBHTMABYPADVPNZCRY4KWLHT X-Message-ID-Hash: 64F7H2JAZBHTMABYPADVPNZCRY4KWLHT X-MailFrom: jjongsma@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: jdenemar@redhat.com X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1702678510467100001 Previously, the script only generated the parent CPU and any versions that had a defined alias. The script now generates 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. The reason for this change is two-fold. First, we need to add new models that support new features (such as SEV-SNP). To deal with this, the script now generates model definitions for all versions. But we also need to ensure that our CPU definitions are migration-safe. To deal with this issue we need to make sure we're always using the canonical versioned names for CPUs. Qemu documentation states that unversioned names for CPU models (e.g. 'EPYC') are actually aliases to a specific versioned CPU model (e.g. 'EPYC-v1'). The documentation further states that the specific version targeted by the alias may change based on the machine type of the domain. Management software such as libvirt is directed to translate these aliases to a concrete version in order to make sure that the CPU definition is safe when migrating between different qemu versions that may make different choices for which underlying versioned model represents the alias. In practice, at the time of writing qemu always maps the unversioned aliases to the -v1 model. And libvirt's CPU model definitions also assume that this is the case. For example, the 'x86_EPYC.xml' file contains the features that are defined for the EPYC-v1 inside of qemu. But if qemu ever changes their alias mapping, libvirt's idea of what an 'EPYC' CPU means and qemu's idea of what an 'EPYC' CPU means will no longer match. So when choosing a CPU model for a domain, we should always pass the canonical versioned name to libvirt rather than the unversioned alias. To enable this, the script will generate a new 'canonical_name' field to the CPU model xml definition. Signed-off-by: Jonathon Jongsma Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Jim Fehlig --- src/cpu_map/sync_qemu_models_i386.py | 42 ++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/src/cpu_map/sync_qemu_models_i386.py b/src/cpu_map/sync_qemu_m= odels_i386.py index 1c6a2d4d27..7fd62eba4a 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.""" =20 - result =3D { - "name": model.pop(".name"), + basename =3D model.pop(".name") + parent =3D { + "name": basename, "vendor": translate_vendor(model.pop(".vendor")), "features": set(), "extra": dict()} =20 if ".family" in model and ".model" in model: - result["family"] =3D model.pop(".family") - result["model"] =3D model.pop(".model") + parent["family"] =3D model.pop(".family") + parent["model"] =3D model.pop(".model") =20 for k in [k for k in model if k.startswith(".features")]: v =3D model.pop(k) for feature in v.split(): translated =3D translate_feature(feature) if translated: - result["features"].add(translated) + parent["features"].add(translated) =20 versions =3D model.pop(".versions", []) for k, v in model.items(): - result["extra"]["model" + k] =3D v - yield result + parent["extra"]["model" + k] =3D v + + if not versions: + yield parent + return + + result =3D parent =20 for version in versions: + # each version builds on the previous one result =3D copy.deepcopy(result) - result["name"] =3D version.pop(".alias", result["name"]) + vnum =3D int(version.pop(".version")) + vname =3D "{}-v{}".format(basename, vnum) + result["canonical_name"] =3D vname + if vnum =3D=3D 1: + # the first version should always be an alias for the parent a= nd + # should therefore have no extra properties + if version.items(): + raise RuntimeError("Unexpected properties in version 1") + yield result + continue + + # prefer the 'alias' over the generated the name if it exists sinc= e we + # have already been using these aliases + alias =3D version.pop(".alias", None) + if alias: + result["name"] =3D alias + else: + result["name"] =3D vname =20 props =3D version.pop(".props", dict()) for k, v in props: @@ -377,6 +401,8 @@ def output_model(f, model): =20 f.write("\n") f.write(" \n".format(model["name"])) + if "canonical_name" in model and model["name"] !=3D model["canonical_n= ame"]: + f.write(" {}\n".format(model["= canonical_name"])) f.write(" \n") f.write(" \n".format( model["family"], model["model"])) --=20 2.41.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org