From nobody Sun Sep 7 20:35:30 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 1702678914766337.4836026931313; Fri, 15 Dec 2023 14:21:54 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id AE4201B2D; Fri, 15 Dec 2023 17:21:53 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 3499C1AB1; Fri, 15 Dec 2023 17:12:48 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 3F2E11AB1; Fri, 15 Dec 2023 17:12:18 -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 5C5961A9F for ; Fri, 15 Dec 2023 17:12:12 -0500 (EST) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-253-YgV2Xv_HOh-kSMP9YOqcvw-1; Fri, 15 Dec 2023 17:12:10 -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 065723816B54 for ; Fri, 15 Dec 2023 22:12:10 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.34.110]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C5B65C15968; 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: YgV2Xv_HOh-kSMP9YOqcvw-1 From: Jonathon Jongsma To: devel@lists.libvirt.org Subject: [PATCH v3 03/12] cpu: parse the canonical name from the cpu model Date: Fri, 15 Dec 2023 16:11:59 -0600 Message-ID: <20231215221208.4138294-4-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: BS4XZRFDEEVQFTL3TRQZQ2ATKE5RYJJU X-Message-ID-Hash: BS4XZRFDEEVQFTL3TRQZQ2ATKE5RYJJU 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: 1702678915791100001 Recent changes have added a 'canonical_name' field to the xml definitions for our CPU models. Parse this field into the C structure and pass it around where necessary. Reviewed-by: Daniel P. Berrang=C3=A9 --- src/conf/cpu_conf.c | 3 +++ src/conf/cpu_conf.h | 1 + src/cpu/cpu_x86.c | 24 ++++++++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 7abe489733..a771893956 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -113,6 +113,7 @@ void ATTRIBUTE_NONNULL(1) virCPUDefFreeModel(virCPUDef *def) { VIR_FREE(def->model); + VIR_FREE(def->canonical_model); VIR_FREE(def->vendor); VIR_FREE(def->vendor_id); virCPUDefFreeFeatures(def); @@ -161,6 +162,7 @@ virCPUDefCopyModelFilter(virCPUDef *dst, =20 dst->features =3D g_new0(virCPUFeatureDef, src->nfeatures); dst->model =3D g_strdup(src->model); + dst->canonical_model =3D g_strdup(src->canonical_model); dst->vendor =3D g_strdup(src->vendor); dst->vendor_id =3D g_strdup(src->vendor_id); dst->microcodeVersion =3D src->microcodeVersion; @@ -211,6 +213,7 @@ virCPUDefStealModel(virCPUDef *dst, virCPUDefFreeModel(dst); =20 dst->model =3D g_steal_pointer(&src->model); + dst->canonical_model =3D g_steal_pointer(&src->canonical_model); dst->features =3D g_steal_pointer(&src->features); dst->microcodeVersion =3D src->microcodeVersion; dst->nfeatures_max =3D src->nfeatures_max; diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h index 3e4c53675c..ba8dab6c7f 100644 --- a/src/conf/cpu_conf.h +++ b/src/conf/cpu_conf.h @@ -142,6 +142,7 @@ struct _virCPUDef { virCPUCheck check; virArch arch; char *model; + char *canonical_model; char *vendor_id; /* vendor id returned by CPUID in the guest */ int fallback; /* enum virCPUFallback */ char *vendor; diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 8d0e3947ce..70800d9579 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -142,6 +142,7 @@ struct _virCPUx86Signatures { typedef struct _virCPUx86Model virCPUx86Model; struct _virCPUx86Model { char *name; + char *canonical_name; bool decodeHost; bool decodeGuest; virCPUx86Vendor *vendor; @@ -864,6 +865,7 @@ x86DataToCPU(const virCPUx86Data *data, cpu =3D virCPUDefNew(); =20 cpu->model =3D g_strdup(model->name); + cpu->canonical_model =3D g_strdup(model->canonical_name); =20 x86DataCopy(©, data); x86DataCopy(&modelData, &model->data); @@ -1281,6 +1283,7 @@ x86ModelFree(virCPUx86Model *model) return; =20 g_free(model->name); + g_free(model->canonical_name); virCPUx86SignaturesFree(model->signatures); virCPUx86DataClear(&model->data); g_strfreev(model->removedFeatures); @@ -1296,6 +1299,7 @@ x86ModelCopy(virCPUx86Model *model) =20 copy =3D g_new0(virCPUx86Model, 1); copy->name =3D g_strdup(model->name); + copy->canonical_name =3D g_strdup(model->canonical_name); copy->signatures =3D virCPUx86SignaturesCopy(model->signatures); x86DataCopy(©->data, &model->data); copy->removedFeatures =3D g_strdupv(model->removedFeatures); @@ -1451,6 +1455,17 @@ x86ModelCompare(virCPUx86Model *model1, } =20 =20 +static int +x86ModelParseCanonicalName(virCPUx86Model *model, + xmlXPathContextPtr ctxt) +{ + if (!(model->canonical_name =3D virXPathString("string(./canonical_nam= e[1])", ctxt))) + model->canonical_name =3D g_strdup(model->name); + + return 0; +} + + static int x86ModelParseDecode(virCPUx86Model *model, xmlXPathContextPtr ctxt) @@ -1668,6 +1683,9 @@ x86ModelParse(xmlXPathContextPtr ctxt, model =3D g_new0(virCPUx86Model, 1); model->name =3D g_strdup(name); =20 + if (x86ModelParseCanonicalName(model, ctxt) < 0) + return -1; + if (x86ModelParseDecode(model, ctxt) < 0) return -1; =20 @@ -2268,6 +2286,7 @@ x86Decode(virCPUDef *cpu, sigFamily, sigModel, sigStepping); =20 cpu->model =3D g_steal_pointer(&cpuModel->model); + cpu->canonical_model =3D g_steal_pointer(&cpuModel->canonical_model); cpu->features =3D g_steal_pointer(&cpuModel->features); cpu->nfeatures =3D cpuModel->nfeatures; cpuModel->nfeatures =3D 0; @@ -3010,6 +3029,11 @@ virCPUx86Update(virCPUDef *guest, return -1; } =20 + if (guestModel->canonical_name) { + g_free(guest->canonical_model); + guest->canonical_model =3D g_strdup(guestModel->canonical_name); + } + if (virCPUx86DisableRemovedFeatures(guest, guestModel) < 0) return -1; =20 --=20 2.41.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org