From nobody Sat May 30 15:28:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1779876607; cv=none; d=zohomail.com; s=zohoarc; b=SJPw+FrbIyfzBSg2S21BPFoOac52hW8K5Iizdq+8xEGYLI4REBPzgFCsOx/iJNi1PpX42cCCOX1AU7KNvIldSLuzKTirY2DnwqdGpS2b7qUCA6ntV26vzTQ86O1Wj0i5z/y1heXlaqGsmwvodLITW97kCrpCSRlBrKb/Ygn5ZYw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779876607; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=7tZ9N9k25tiY9oYRZUNHahgu+JneU2ix4eO6E7+UqFo=; b=loDFLnrqKt/s4lJ2SfCStzsJrdR/U/E6AjkKJ6TwEpeBLcfVtXa9CRgHFvHc1RBmC0VflLzdjw9kCkX2BFp5iu1Cizprh08X+UPxKkjTUzznMxN8i+D4eM4TjCA7ipljX8+sNUE3U7p+7+WpxBz7jZL6X/OFHgxUxzPVBZkyW6o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1779876607125867.4148433494329; Wed, 27 May 2026 03:10:07 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 5B23341CB6; Wed, 27 May 2026 06:10:06 -0400 (EDT) Received: from [172.19.199.9] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 3B35741CD7; Wed, 27 May 2026 06:07:49 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 72CF441A82; Wed, 27 May 2026 06:07:31 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 8B94D41A82 for ; Wed, 27 May 2026 06:07:30 -0400 (EDT) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-KoQcsyyzOMi6VSS0zMiJvg-1; Wed, 27 May 2026 06:07:27 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 90F4B18005B3 for ; Wed, 27 May 2026 10:07:26 +0000 (UTC) Received: from orkuz (unknown [10.43.3.115]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2BA5319560AB for ; Wed, 27 May 2026 10:07:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779876450; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7tZ9N9k25tiY9oYRZUNHahgu+JneU2ix4eO6E7+UqFo=; b=Cz/IbQI6wDsa5P/WnaWwcObEckbk1fl1yR8F3qABsq4Hup+EDqU+3jyZa/7WAhLValO2Ox n/9mR0E+pkYAnv5Ih5m3M5wRyahkMN8YPLbU0tUBDEZf3iVMBSrflW4Z2dhN6d6LokiMIC rcUsAiCRPIE3H5rgTrQj8ZC2LK3tXYc= X-MC-Unique: KoQcsyyzOMi6VSS0zMiJvg-1 X-Mimecast-MFC-AGG-ID: KoQcsyyzOMi6VSS0zMiJvg_1779876446 To: devel@lists.libvirt.org Subject: [PATCH 01/10] qemu_capabilities: Split virQEMUCapsFillDomainCPUCaps Date: Wed, 27 May 2026 12:07:13 +0200 Message-ID: <854f990cdcaa94ad0513f320ce4c63d6cd631e08.1779876382.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: mRRKEc13qITHtr71-VLLQt4-48lpPQSliiU_m6zXoF0_1779876446 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: KY3HFVR5ZP6RILAW4SLS5CATQRGGDSTT X-Message-ID-Hash: KY3HFVR5ZP6RILAW4SLS5CATQRGGDSTT X-MailFrom: jdenemar@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Jiri Denemark via Devel Reply-To: Jiri Denemark X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1779876609805154100 Content-Type: text/plain; charset="utf-8" From: Jiri Denemark Each CPU mode is filled in its own dedicated function. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa --- src/qemu/qemu_capabilities.c | 96 ++++++++++++++++++++++++------------ 1 file changed, 64 insertions(+), 32 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 12af7c4616..90bd43e628 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -6606,6 +6606,66 @@ virQEMUCapsFillDomainOSCaps(virDomainCapsOS *os, } =20 =20 +static void +virQEMUCapsFillDomainCPUHostPassthrough(virQEMUCaps *qemuCaps, + virDomainCaps *domCaps) +{ + domCaps->cpu.hostPassthrough =3D true; + + domCaps->cpu.hostPassthroughMigratable.report =3D true; + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_CPU_MIGRATABLE)) { + VIR_DOMAIN_CAPS_ENUM_SET(domCaps->cpu.hostPassthroughMigratable, + VIR_TRISTATE_SWITCH_ON); + } + VIR_DOMAIN_CAPS_ENUM_SET(domCaps->cpu.hostPassthroughMigratable, + VIR_TRISTATE_SWITCH_OFF); +} + + +static void +virQEMUCapsFillDomainCPUMaximum(virDomainCaps *domCaps) +{ + domCaps->cpu.maximum =3D true; + + domCaps->cpu.maximumMigratable.report =3D true; + VIR_DOMAIN_CAPS_ENUM_SET(domCaps->cpu.maximumMigratable, + VIR_TRISTATE_SWITCH_ON); + VIR_DOMAIN_CAPS_ENUM_SET(domCaps->cpu.maximumMigratable, + VIR_TRISTATE_SWITCH_OFF); +} + + +static void +virQEMUCapsFillDomainCPUHostModel(virQEMUCaps *qemuCaps, + virDomainCaps *domCaps) +{ + virCPUDef *cpu =3D virQEMUCapsGetHostModel(qemuCaps, domCaps->virttype, + VIR_QEMU_CAPS_HOST_CPU_REPORT= ED); + + domCaps->cpu.hostModel =3D virCPUDefCopy(cpu); + domCaps->cpu.hostModel->addr =3D virQEMUCapsGetHostPhysAddr(qemuCaps, + domCaps->vir= ttype); +} + + +static void +virQEMUCapsFillDomainCPUCustom(virQEMUCaps *qemuCaps, + virDomainCaps *domCaps) +{ + const char *forbidden[] =3D { "host", NULL }; + g_auto(GStrv) models =3D NULL; + + if (virCPUGetModels(domCaps->arch, &models) >=3D 0) { + domCaps->cpu.custom =3D virQEMUCapsGetCPUModels(qemuCaps, + domCaps->virttype, + (const char **)model= s, + forbidden); + } else { + domCaps->cpu.custom =3D NULL; + } +} + + static void virQEMUCapsFillDomainCPUCaps(virQEMUCaps *qemuCaps, virArch hostarch, @@ -6614,53 +6674,25 @@ virQEMUCapsFillDomainCPUCaps(virQEMUCaps *qemuCaps, if (virQEMUCapsIsCPUModeSupported(qemuCaps, hostarch, domCaps->virttyp= e, VIR_CPU_MODE_HOST_PASSTHROUGH, domCaps->machine)) { - domCaps->cpu.hostPassthrough =3D true; - - domCaps->cpu.hostPassthroughMigratable.report =3D true; - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_CPU_MIGRATABLE)) { - VIR_DOMAIN_CAPS_ENUM_SET(domCaps->cpu.hostPassthroughMigratabl= e, - VIR_TRISTATE_SWITCH_ON); - } - VIR_DOMAIN_CAPS_ENUM_SET(domCaps->cpu.hostPassthroughMigratable, - VIR_TRISTATE_SWITCH_OFF); + virQEMUCapsFillDomainCPUHostPassthrough(qemuCaps, domCaps); } =20 if (virQEMUCapsIsCPUModeSupported(qemuCaps, hostarch, domCaps->virttyp= e, VIR_CPU_MODE_MAXIMUM, domCaps->machine)) { - domCaps->cpu.maximum =3D true; - - domCaps->cpu.maximumMigratable.report =3D true; - VIR_DOMAIN_CAPS_ENUM_SET(domCaps->cpu.maximumMigratable, - VIR_TRISTATE_SWITCH_ON); - VIR_DOMAIN_CAPS_ENUM_SET(domCaps->cpu.maximumMigratable, - VIR_TRISTATE_SWITCH_OFF); + virQEMUCapsFillDomainCPUMaximum(domCaps); } =20 if (virQEMUCapsIsCPUModeSupported(qemuCaps, hostarch, domCaps->virttyp= e, VIR_CPU_MODE_HOST_MODEL, domCaps->machine)) { - virCPUDef *cpu =3D virQEMUCapsGetHostModel(qemuCaps, domCaps->virt= type, - VIR_QEMU_CAPS_HOST_CPU_= REPORTED); - domCaps->cpu.hostModel =3D virCPUDefCopy(cpu); - domCaps->cpu.hostModel->addr =3D virQEMUCapsGetHostPhysAddr(qemuCa= ps, - domCaps-= >virttype); + virQEMUCapsFillDomainCPUHostModel(qemuCaps, domCaps); } =20 if (virQEMUCapsIsCPUModeSupported(qemuCaps, hostarch, domCaps->virttyp= e, VIR_CPU_MODE_CUSTOM, domCaps->machine)) { - const char *forbidden[] =3D { "host", NULL }; - g_auto(GStrv) models =3D NULL; - - if (virCPUGetModels(domCaps->arch, &models) >=3D 0) { - domCaps->cpu.custom =3D virQEMUCapsGetCPUModels(qemuCaps, - domCaps->virttyp= e, - (const char **)m= odels, - forbidden); - } else { - domCaps->cpu.custom =3D NULL; - } + virQEMUCapsFillDomainCPUCustom(qemuCaps, domCaps); } } =20 --=20 2.54.0 From nobody Sat May 30 15:28:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1779876710; cv=none; d=zohomail.com; s=zohoarc; b=QZWRM5Q/Lt3MOiXl0YFdrz6YhrqiImgcL6B8b1j9sWytqQvvGOnoaEsNgF3+oW4PerpxqXMRJeLbIti8G/jC4mOIXtJOHsQar5KOaRp22wdasqcvWEbuXPrJlxdDWGVvyWhGzcimYn75QqMS3yZdUn4DFAJkmj2+4oBUJmnHuo0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779876710; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=ICUnyCDLyJcyB1NcbeH/xGq1BSZ5xF/dAnxF7GWOqHQ=; b=WLbnJFCJXQT6Hp/13P9reKByLSLANzT/QTokUW+b+5yMqKp7M+qqBfD6GzZOhc9ScXhp67FtKeYGJeIcXuvb5Vwe+Y2hSZIFO5Kg+4Ty8iKw+d5xKoxZSSZbSbnnL6i6j0fzhMj+e4CCoFtZ+KBndE/bJHxMs8D+8jSg7vlBvx4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1779876710464970.1036780204408; Wed, 27 May 2026 03:11:50 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 9F02C41991; Wed, 27 May 2026 06:11:49 -0400 (EDT) Received: from [172.19.199.9] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 90E4C41D1A; Wed, 27 May 2026 06:07:54 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 1838041A83; Wed, 27 May 2026 06:07:32 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id E463241A7E for ; Wed, 27 May 2026 06:07:30 -0400 (EDT) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-498-9ufK1aXuPH-rGJtIJad7Hw-1; Wed, 27 May 2026 06:07:29 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (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 mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6B0DB18005B5 for ; Wed, 27 May 2026 10:07:28 +0000 (UTC) Received: from orkuz (unknown [10.43.3.115]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 05722404 for ; Wed, 27 May 2026 10:07:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779876450; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ICUnyCDLyJcyB1NcbeH/xGq1BSZ5xF/dAnxF7GWOqHQ=; b=UzI9AT83o3UAGrgFtigIzraGmtHZiSVTXannyOoSgg92yYo4uXEqsUgcJP2qbpaDLHMwMa oQAnvFr0r96lBPK1syCzY2mM8OBxaxsedhthZmfmkr1uvWTjskErtfVi6lcK1NAeWJRW1q hwlv/QpuXWtki7nEXpecdbFzgEd0o/o= X-MC-Unique: 9ufK1aXuPH-rGJtIJad7Hw-1 X-Mimecast-MFC-AGG-ID: 9ufK1aXuPH-rGJtIJad7Hw_1779876448 To: devel@lists.libvirt.org Subject: [PATCH 02/10] qemu: Move domain caps flags handling to virQEMUCapsFillDomainCPUHostModel Date: Wed, 27 May 2026 12:07:14 +0200 Message-ID: <337241f6becd272a4b9654d621c532e02ccae4ec.1779876382.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: MO-dOs3Wu1NcSlHk77BAg9haj0mwNXGlfqmc-uc2GVk_1779876448 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: MEJQXVBEX3R362O5TDS5EBQ33UETUVT4 X-Message-ID-Hash: MEJQXVBEX3R362O5TDS5EBQ33UETUVT4 X-MailFrom: jdenemar@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Jiri Denemark via Devel Reply-To: Jiri Denemark X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1779876715376154100 Content-Type: text/plain; charset="utf-8" From: Jiri Denemark We will need to generate the capabilities in a different way based on the flags. Signed-off-by: Jiri Denemark --- src/qemu/qemu_capabilities.c | 36 ++++++++++++++++++++++++++---------- src/qemu/qemu_capabilities.h | 3 ++- src/qemu/qemu_conf.c | 6 ++++-- src/qemu/qemu_conf.h | 3 ++- src/qemu/qemu_driver.c | 15 ++------------- tests/domaincapstest.c | 2 +- 6 files changed, 37 insertions(+), 28 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 90bd43e628..a612011ee1 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -795,6 +795,9 @@ struct _virQEMUCapsHostCPUData { unsigned int physAddrSize; /* Host CPU definition reported in domain capabilities. */ virCPUDef *reported; + /* Host CPU definition with possibly extra features that are supported= by + * the stack, but should not be included in a host-model CPU. */ + virCPUDef *supported; /* Migratable host CPU definition used for updating guest CPU. */ virCPUDef *migratable; /* CPU definition with features detected by libvirt using virCPUGetHost @@ -6637,14 +6640,25 @@ virQEMUCapsFillDomainCPUMaximum(virDomainCaps *domC= aps) =20 static void virQEMUCapsFillDomainCPUHostModel(virQEMUCaps *qemuCaps, - virDomainCaps *domCaps) + virDomainCaps *domCaps, + unsigned int flags) { - virCPUDef *cpu =3D virQEMUCapsGetHostModel(qemuCaps, domCaps->virttype, - VIR_QEMU_CAPS_HOST_CPU_REPORT= ED); + virQEMUCapsHostCPUType cpuType =3D VIR_QEMU_CAPS_HOST_CPU_REPORTED; + virCPUDef *cpu; =20 - domCaps->cpu.hostModel =3D virCPUDefCopy(cpu); - domCaps->cpu.hostModel->addr =3D virQEMUCapsGetHostPhysAddr(qemuCaps, - domCaps->vir= ttype); + cpu =3D virCPUDefCopy(virQEMUCapsGetHostModel(qemuCaps, domCaps->virtt= ype, + cpuType)); + domCaps->cpu.hostModel =3D cpu; + + cpu->addr =3D virQEMUCapsGetHostPhysAddr(qemuCaps, domCaps->virttype); + + if (flags & VIR_CONNECT_GET_DOMAIN_CAPABILITIES_DISABLE_DEPRECATED_FEA= TURES) { + virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, domCaps->virttype, + cpu, VIR_CPU_FEATURE_DISABL= E); + } + + if (flags & VIR_CONNECT_GET_DOMAIN_CAPABILITIES_EXPAND_CPU_FEATURES) + virCPUExpandFeatures(domCaps->arch, cpu); } =20 =20 @@ -6669,7 +6683,8 @@ virQEMUCapsFillDomainCPUCustom(virQEMUCaps *qemuCaps, static void virQEMUCapsFillDomainCPUCaps(virQEMUCaps *qemuCaps, virArch hostarch, - virDomainCaps *domCaps) + virDomainCaps *domCaps, + unsigned int flags) { if (virQEMUCapsIsCPUModeSupported(qemuCaps, hostarch, domCaps->virttyp= e, VIR_CPU_MODE_HOST_PASSTHROUGH, @@ -6686,7 +6701,7 @@ virQEMUCapsFillDomainCPUCaps(virQEMUCaps *qemuCaps, if (virQEMUCapsIsCPUModeSupported(qemuCaps, hostarch, domCaps->virttyp= e, VIR_CPU_MODE_HOST_MODEL, domCaps->machine)) { - virQEMUCapsFillDomainCPUHostModel(qemuCaps, domCaps); + virQEMUCapsFillDomainCPUHostModel(qemuCaps, domCaps, flags); } =20 if (virQEMUCapsIsCPUModeSupported(qemuCaps, hostarch, domCaps->virttyp= e, @@ -7315,7 +7330,8 @@ virQEMUCapsFillDomainCaps(virQEMUDriverConfig *cfg, virQEMUCaps *qemuCaps, virArch hostarch, virDomainCaps *domCaps, - bool privileged) + bool privileged, + unsigned int flags) { virDomainCapsOS *os =3D &domCaps->os; virDomainCapsDeviceDisk *disk =3D &domCaps->disk; @@ -7358,7 +7374,7 @@ virQEMUCapsFillDomainCaps(virQEMUDriverConfig *cfg, firmwares, nfirmwares) < 0) return -1; =20 - virQEMUCapsFillDomainCPUCaps(qemuCaps, hostarch, domCaps); + virQEMUCapsFillDomainCPUCaps(qemuCaps, hostarch, domCaps, flags); virQEMUCapsFillDomainMemoryBackingCaps(qemuCaps, memoryBacking); virQEMUCapsFillDomainDeviceDiskCaps(qemuCaps, domCaps->machine, disk); virQEMUCapsFillDomainDeviceGraphicsCaps(cfg, qemuCaps, graphics); diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index c26e06104d..b26b5d3145 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -903,7 +903,8 @@ int virQEMUCapsFillDomainCaps(virQEMUDriverConfig *cfg, virQEMUCaps *qemuCaps, virArch hostarch, virDomainCaps *domCaps, - bool privileged); + bool privileged, + unsigned int flags); =20 void virQEMUCapsFillDomainMemoryBackingCaps(virQEMUCaps *qemuCaps, virDomainCapsMemoryBacking *me= moryBacking); diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 9c32310096..9b94733a38 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1753,7 +1753,8 @@ virQEMUDriverGetDomainCapabilities(virQEMUDriver *dri= ver, virQEMUCaps *qemuCaps, const char *machine, virArch arch, - virDomainVirtType virttype) + virDomainVirtType virttype, + unsigned int flags) { g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); g_autoptr(virDomainCaps) domCaps =3D NULL; @@ -1787,7 +1788,8 @@ virQEMUDriverGetDomainCapabilities(virQEMUDriver *dri= ver, qemuCaps, driver->hostarch, domCaps, - driver->privileged) < 0) + driver->privileged, + flags) < 0) return NULL; =20 return g_steal_pointer(&domCaps); diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 511ab77f71..a2ca4ddbdb 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -383,7 +383,8 @@ virQEMUDriverGetDomainCapabilities(virQEMUDriver *drive= r, virQEMUCaps *qemuCaps, const char *machine, virArch arch, - virDomainVirtType virttype); + virDomainVirtType virttype, + unsigned int flags); =20 int qemuDriverAllocateID(virQEMUDriver *driver); virDomainXMLOption *virQEMUDriverCreateXMLConf(virQEMUDriver *driver, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index bcafacfb60..c351ce40af 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -16982,21 +16982,10 @@ qemuConnectGetDomainCapabilities(virConnectPtr co= nn, =20 if (!(domCaps =3D virQEMUDriverGetDomainCapabilities(driver, qemuCaps, machine, - arch, virttype))) + arch, virttype, + flags))) return NULL; =20 - if (flags & VIR_CONNECT_GET_DOMAIN_CAPABILITIES_DISABLE_DEPRECATED_FEA= TURES) { - virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, virttype, - domCaps->cpu.hostModel, - VIR_CPU_FEATURE_DISABLE); - } - - if (flags & VIR_CONNECT_GET_DOMAIN_CAPABILITIES_EXPAND_CPU_FEATURES) { - virCPUDef *cpu =3D domCaps->cpu.hostModel; - if (cpu && virCPUExpandFeatures(arch, cpu) < 0) - return NULL; - } - return virDomainCapsFormat(domCaps); } =20 diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index 5b2fc80f0a..f2248c2435 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -101,7 +101,7 @@ fillQemuCaps(virDomainCaps *domCaps, =20 if (virQEMUCapsFillDomainCaps(cfg, qemuCaps, domCaps->arch, domCaps, - false) < 0) + false, 0) < 0) return -1; =20 /* As of f05b6a918e28 we are expecting to see OVMF_CODE.fd file which --=20 2.54.0 From nobody Sat May 30 15:28:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1779876798; cv=none; d=zohomail.com; s=zohoarc; b=Q9g/+QjlrF99MufwWoIAAinb7FSSt825EEgmuFV6/V4EnjQsjX7cmVJITShjFKnA+fj57mwOxFez4rta2tXdXsRFuDG3E6/3CfDGIRKbznRDiHp3jmQiYSCmSFoR1z0D0iqblDnaZ+CCEP86W8spjhIvTG5Yxkl4ZtekkbmsQxk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779876798; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=A42y9HwKHRhHqvcbgjjkg6qyExXxpr9Gel4F8atQcjo=; b=eVXvjiEOmJ9FtiFBUuURzl+Dh8MNjtiAvM3pTT+3CSaxmYZLIOXvc1AON07Bp4PfVKkpUtfwLNz+oX0FNMvURBSfUz4n30bAsN+UZUOuWMuE8xmhwlRZp+gGYbqzUbnbV5FTEZPfXfw7zf1QPeQUN5sFqILE5Q22L78mg0/Ye+w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1779876798760660.0368172937485; Wed, 27 May 2026 03:13:18 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 0F16741C85; Wed, 27 May 2026 06:13:18 -0400 (EDT) Received: from [172.19.199.9] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id F240341D62; Wed, 27 May 2026 06:08:02 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 9264C41C43; Wed, 27 May 2026 06:07:40 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 3DAB841ABB for ; Wed, 27 May 2026 06:07:33 -0400 (EDT) Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-589-96tSD9GeMha3oN4QwKwiog-1; Wed, 27 May 2026 06:07:31 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2ACF2195608E for ; Wed, 27 May 2026 10:07:30 +0000 (UTC) Received: from orkuz (unknown [10.43.3.115]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B951718004A3 for ; Wed, 27 May 2026 10:07:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,SPF_HELO_PASS autolearn=no autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779876452; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=A42y9HwKHRhHqvcbgjjkg6qyExXxpr9Gel4F8atQcjo=; b=AD2a7cyGUJWE575JNI77EebtvBxc1FtGK5+RN0VmOrBE1Aj9AdkSrUrGwC6VhMXyZOEd7u ieMhPQRT1zqrnmZ59opRvb8qjdILp+Vy3zqnUzRTLb0AqxHBSxzGrK4bpGLNq/5A4CmXAI k9zBpwiJlPUCwKVK34Mxjf4vcAS486Q= X-MC-Unique: 96tSD9GeMha3oN4QwKwiog-1 X-Mimecast-MFC-AGG-ID: 96tSD9GeMha3oN4QwKwiog_1779876450 To: devel@lists.libvirt.org Subject: [PATCH 03/10] qemu_capabilities: Use g_autoptr in virQEMUCapsInitHostCPUModel Date: Wed, 27 May 2026 12:07:15 +0200 Message-ID: <29c67d679d9f93251d01df941bb87a5e05f055d5.1779876382.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 2QulXdrRRuJ_WLWwWku_xb9xgpcESmLIkdm0apSN18g_1779876450 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: R3YCMUIEYZ6T22JGALR3QIC2TF6WVL4F X-Message-ID-Hash: R3YCMUIEYZ6T22JGALR3QIC2TF6WVL4F X-MailFrom: jdenemar@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Jiri Denemark via Devel Reply-To: Jiri Denemark X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1779876802753154100 Content-Type: text/plain; charset="utf-8" From: Jiri Denemark Signed-off-by: Jiri Denemark --- src/qemu/qemu_capabilities.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index a612011ee1..581b853589 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4103,11 +4103,11 @@ virQEMUCapsInitHostCPUModel(virQEMUCaps *qemuCaps, virArch hostArch, virDomainVirtType type) { - virCPUDef *cpu =3D NULL; - virCPUDef *cpuExpanded =3D NULL; - virCPUDef *migCPU =3D NULL; - virCPUDef *hostCPU =3D NULL; - virCPUDef *fullCPU =3D NULL; + g_autoptr(virCPUDef) cpu =3D NULL; + g_autoptr(virCPUDef) cpuExpanded =3D NULL; + g_autoptr(virCPUDef) migCPU =3D NULL; + g_autoptr(virCPUDef) hostCPU =3D NULL; + g_autoptr(virCPUDef) fullCPU =3D NULL; unsigned int physAddrSize =3D 0; size_t i; int rc; @@ -4181,19 +4181,15 @@ virQEMUCapsInitHostCPUModel(virQEMUCaps *qemuCaps, if (virQEMUCapsTypeIsAccelerated(type)) virHostCPUGetPhysAddrSize(hostArch, &physAddrSize); =20 - virQEMUCapsSetHostModel(qemuCaps, type, physAddrSize, cpu, migCPU, ful= lCPU); + virQEMUCapsSetHostModel(qemuCaps, type, physAddrSize, + g_steal_pointer(&cpu), + g_steal_pointer(&migCPU), + g_steal_pointer(&fullCPU)); =20 - cleanup: - virCPUDefFree(cpuExpanded); - virCPUDefFree(hostCPU); return; =20 error: - virCPUDefFree(cpu); - virCPUDefFree(migCPU); - virCPUDefFree(fullCPU); virResetLastError(); - goto cleanup; } =20 =20 --=20 2.54.0 From nobody Sat May 30 15:28:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1779876862; cv=none; d=zohomail.com; s=zohoarc; b=i+2NhXZ/YAkD9o25e6imDf+L0rSTRriF5qfidLgPzn74oj54R8u8r8bdE/ErN8egdQMJEPu+VqLyUxIwrCLSjrCIbc8M5D/GuP4R5M9CIafLtGKkJA5V+wz6zbZh2gN/2ArxD57L8Lq8TLb6miiAP9xmlS2tN3E8O4EAM2flg5w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779876862; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=igU0fvVEwHdQegvNsjD0muXBXa8DiMMmDA3nig0aHh8=; b=mPmGTScgZ+2KQTGZUBhNxr2NMTs7e7/YDfqxMZU3/WsItmqtnBazMSUGS8wD/8RAzIRFbqw5nlIzUUBzbDkpn1lSWt40iqoYFSX6kr1p8l8bBX93ndbEkcZ9c/2u/nC1b1LUeJGLkT2mCKDItdyR9Ga7HUUkCrOLwNmG/443S1U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1779876862507895.0643554680671; Wed, 27 May 2026 03:14:22 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 9E3FB41AA5; Wed, 27 May 2026 06:14:21 -0400 (EDT) Received: from [172.19.199.9] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id A278441D9C; Wed, 27 May 2026 06:08:10 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 0C83041CA3; Wed, 27 May 2026 06:07:44 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id F11ED41B4A for ; Wed, 27 May 2026 06:07:34 -0400 (EDT) Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-621-xzIKVx9zPEuOm_NPeTsn2g-1; Wed, 27 May 2026 06:07:32 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D5127195609F for ; Wed, 27 May 2026 10:07:31 +0000 (UTC) Received: from orkuz (unknown [10.43.3.115]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6FA241800577 for ; Wed, 27 May 2026 10:07:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,SPF_HELO_PASS autolearn=no autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779876454; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=igU0fvVEwHdQegvNsjD0muXBXa8DiMMmDA3nig0aHh8=; b=XHHvKpCkcsqfp0Nt6K6x+58mK5gvzwBe+U1VJ5FbNY1zbQYtrr49VGPBRwIBkQXkYtaINN Vlzw6MGsJepjPYN6RWSz3vgHK76LdHjidPCvI7ujw8HAb+aqs8W1YV9VjFlEFTlMuUfOhW mpnG/ZuOmin0Kta+tsxdHILOslFtpRM= X-MC-Unique: xzIKVx9zPEuOm_NPeTsn2g-1 X-Mimecast-MFC-AGG-ID: xzIKVx9zPEuOm_NPeTsn2g_1779876451 To: devel@lists.libvirt.org Subject: [PATCH 04/10] qemu_capabilities: Split conditions in virQEMUCapsInitHostCPUModel Date: Wed, 27 May 2026 12:07:16 +0200 Message-ID: <5f6047ae03e0a6a942d43fa4531bee09bbd0fa07.1779876382.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: cKHDqzUNcyoaDfo-gtzMPtRi-mwuef_rAm9HKsL6-qo_1779876451 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: US2UI5BXPZMD52AY3JWXNMQE3GG2L5I5 X-Message-ID-Hash: US2UI5BXPZMD52AY3JWXNMQE3GG2L5I5 X-MailFrom: jdenemar@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Jiri Denemark via Devel Reply-To: Jiri Denemark X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1779876865703154100 Content-Type: text/plain; charset="utf-8" From: Jiri Denemark Having 'else' after goto is useless. Signed-off-by: Jiri Denemark --- src/qemu/qemu_capabilities.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 581b853589..166d6ed540 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4118,9 +4118,17 @@ virQEMUCapsInitHostCPUModel(virQEMUCaps *qemuCaps, if (!(cpu =3D virQEMUCapsNewHostCPUModel())) goto error; =20 - if ((rc =3D virQEMUCapsInitCPUModel(qemuCaps, type, cpu, false)) < 0) { + if ((rc =3D virQEMUCapsInitCPUModel(qemuCaps, type, cpu, false)) < 0) goto error; - } else if (rc =3D=3D 1) { + + if (rc =3D=3D 2) { + VIR_DEBUG("QEMU does not provide CPU model for arch=3D%s virttype= =3D%s", + virArchToString(qemuCaps->arch), + virDomainVirtTypeToString(type)); + goto error; + } + + if (rc =3D=3D 1) { g_autoptr(virDomainCapsCPUModels) cpuModels =3D NULL; =20 VIR_DEBUG("No host CPU model info from QEMU; probing host CPU dire= ctly"); @@ -4131,11 +4139,6 @@ virQEMUCapsInitHostCPUModel(virQEMUCaps *qemuCaps, =20 virCPUDefCopyModelFilter(cpu, hostCPU, true, virQEMUCapsCPUFilterF= eatures, &qemuCaps->arch); - } else if (rc =3D=3D 2) { - VIR_DEBUG("QEMU does not provide CPU model for arch=3D%s virttype= =3D%s", - virArchToString(qemuCaps->arch), - virDomainVirtTypeToString(type)); - goto error; } else if (virQEMUCapsTypeIsAccelerated(type) && virCPUGetHostIsSupported(qemuCaps->arch)) { if (!(fullCPU =3D virQEMUCapsProbeHostCPU(qemuCaps->arch, NULL))) @@ -4156,9 +4159,10 @@ virQEMUCapsInitHostCPUModel(virQEMUCaps *qemuCaps, if (!(migCPU =3D virQEMUCapsNewHostCPUModel())) goto error; =20 - if ((rc =3D virQEMUCapsInitCPUModel(qemuCaps, type, migCPU, true)) < 0= ) { + if ((rc =3D virQEMUCapsInitCPUModel(qemuCaps, type, migCPU, true)) < 0) goto error; - } else if (rc =3D=3D 1) { + + if (rc =3D=3D 1) { VIR_DEBUG("CPU migratability not provided by QEMU"); =20 virCPUDefFree(migCPU); --=20 2.54.0 From nobody Sat May 30 15:28:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1779876928; cv=none; d=zohomail.com; s=zohoarc; b=CrO6xLnMnwdQ6TgpZYWPW/zDLEIGoN1XybeoWcLgFMmAdB69MUy7CBudxeKBeMoM90Z9TGLjJkFXAEcQbws+pvd6c7Y3veFH7F0Rcg/YCtHK1erHxynFPs4vOkHeMLw3O4hneViMWNBl7WWH6bbBA+BwQO5icg5YL0MV3bImlew= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779876928; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=ZBbi8Akig426mhEqEfZ+6bJxgUt1yPH4tdWC4NLhJz4=; b=WkfbF2FHO9OUb9mo66Hbq+jNASyWbcJckR0aW01sDnFJ14tB1kiUpLYqFUypXHkIBkw+dp/BzW17nCwSylw4LieMatMYNv7kk9UvTkfamYj7gq+UevLk0ySgB1oYyHIYEvcoFliYgh2DS+YIbtNJgM3FUtgJM+Ki4rVB3DMxJsA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1779876928520362.22346505230996; Wed, 27 May 2026 03:15:28 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 1B03A419D3; Wed, 27 May 2026 06:15:27 -0400 (EDT) Received: from [172.19.199.9] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id A669041DD5; Wed, 27 May 2026 06:08:17 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id E7AFE41BB9; Wed, 27 May 2026 06:07:51 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 6E42741B93 for ; Wed, 27 May 2026 06:07:36 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-653-4liUfjH6P-OsUKFqNoA_FA-1; Wed, 27 May 2026 06:07:34 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 850061956055 for ; Wed, 27 May 2026 10:07:33 +0000 (UTC) Received: from orkuz (unknown [10.43.3.115]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1FCE91800347 for ; Wed, 27 May 2026 10:07:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,SPF_HELO_PASS autolearn=no autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779876456; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZBbi8Akig426mhEqEfZ+6bJxgUt1yPH4tdWC4NLhJz4=; b=Oz2b4VhTMHdU5tg0fF33C229pkW0DUkWwynrxOGJNLFYvfUdUhhVrpM3Mg3s5aBHpJvyv9 sQj3xiDtbzboV9/cmOMWNovkJMhcahUbkTwBgMZWuRYdQlkygGbQFYL49YTSYlUv4MJ9JA sxxo0iE6hH16ZEwiM9QVoiicPOTrqFI= X-MC-Unique: 4liUfjH6P-OsUKFqNoA_FA-1 X-Mimecast-MFC-AGG-ID: 4liUfjH6P-OsUKFqNoA_FA_1779876453 To: devel@lists.libvirt.org Subject: [PATCH 05/10] qemu_capabilities: Cache expanded CPU Date: Wed, 27 May 2026 12:07:17 +0200 Message-ID: <800744cc6acff99d7ad3fca749e061768cc56f69.1779876382.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: jTdnimF8-3PBma5sVVCK9v7CXn2YR3Qng64WC3FNuc8_1779876453 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: GZEGTPO52NMKH7Z6WIFG3YZNVSSAV4CC X-Message-ID-Hash: GZEGTPO52NMKH7Z6WIFG3YZNVSSAV4CC X-MailFrom: jdenemar@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Jiri Denemark via Devel Reply-To: Jiri Denemark X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1779876932337158500 Content-Type: text/plain; charset="utf-8" From: Jiri Denemark When probing host model CPU we already expand it to get a list of all CPU features. Let's store the expanded CPU definition in virQEMUCaps and copy it to domain capabilities when requested by the VIR_CONNECT_GET_DOMAIN_CAPABILITIES_EXPAND_CPU_FEATURES flag instead of expanding the CPU over and over on each request. Signed-off-by: Jiri Denemark --- src/qemu/qemu_capabilities.c | 36 +++++++++++++++++++++++++----------- src/qemu/qemu_capabilities.h | 4 ++++ 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 166d6ed540..8295a9ae9d 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1978,6 +1978,9 @@ virQEMUCapsHostCPUDataCopy(virQEMUCapsHostCPUData *ds= t, if (src->reported) dst->reported =3D virCPUDefCopy(src->reported); =20 + if (src->supported) + dst->supported =3D virCPUDefCopy(src->supported); + if (src->migratable) dst->migratable =3D virCPUDefCopy(src->migratable); =20 @@ -1991,6 +1994,7 @@ virQEMUCapsHostCPUDataClear(virQEMUCapsHostCPUData *c= puData) { qemuMonitorCPUModelInfoFree(cpuData->info); virCPUDefFree(cpuData->reported); + virCPUDefFree(cpuData->supported); virCPUDefFree(cpuData->migratable); virCPUDefFree(cpuData->full); =20 @@ -2317,6 +2321,9 @@ virQEMUCapsGetHostModel(virQEMUCaps *qemuCaps, /* 'full' is non-NULL only if we have data from both QEMU and * virCPUGetHost */ return cpuData->full ? cpuData->full : cpuData->reported; + + case VIR_QEMU_CAPS_HOST_CPU_SUPPORTED: + return cpuData->supported; } =20 return NULL; @@ -2328,6 +2335,7 @@ virQEMUCapsSetHostModel(virQEMUCaps *qemuCaps, virDomainVirtType type, unsigned int physAddrSize, virCPUDef *reported, + virCPUDef *supported, virCPUDef *migratable, virCPUDef *full) { @@ -2336,6 +2344,7 @@ virQEMUCapsSetHostModel(virQEMUCaps *qemuCaps, cpuData =3D &virQEMUCapsGetAccel(qemuCaps, type)->hostCPU; cpuData->physAddrSize =3D physAddrSize; cpuData->reported =3D reported; + cpuData->supported =3D supported; cpuData->migratable =3D migratable; cpuData->full =3D full; } @@ -4139,16 +4148,18 @@ virQEMUCapsInitHostCPUModel(virQEMUCaps *qemuCaps, =20 virCPUDefCopyModelFilter(cpu, hostCPU, true, virQEMUCapsCPUFilterF= eatures, &qemuCaps->arch); - } else if (virQEMUCapsTypeIsAccelerated(type) && - virCPUGetHostIsSupported(qemuCaps->arch)) { + } + + cpuExpanded =3D virCPUDefCopy(cpu); + if (virCPUExpandFeatures(qemuCaps->arch, cpuExpanded) < 0) + goto error; + + if (rc =3D=3D 0 && + virQEMUCapsTypeIsAccelerated(type) && + virCPUGetHostIsSupported(qemuCaps->arch)) { if (!(fullCPU =3D virQEMUCapsProbeHostCPU(qemuCaps->arch, NULL))) goto error; =20 - cpuExpanded =3D virCPUDefCopy(cpu); - - if (virCPUExpandFeatures(qemuCaps->arch, cpuExpanded) < 0) - goto error; - for (i =3D 0; i < cpuExpanded->nfeatures; i++) { if (cpuExpanded->features[i].policy =3D=3D VIR_CPU_FEATURE_REQ= UIRE) virCPUDefUpdateFeature(fullCPU, cpuExpanded->features[i].n= ame, @@ -4187,6 +4198,7 @@ virQEMUCapsInitHostCPUModel(virQEMUCaps *qemuCaps, =20 virQEMUCapsSetHostModel(qemuCaps, type, physAddrSize, g_steal_pointer(&cpu), + g_steal_pointer(&cpuExpanded), g_steal_pointer(&migCPU), g_steal_pointer(&fullCPU)); =20 @@ -6643,9 +6655,14 @@ virQEMUCapsFillDomainCPUHostModel(virQEMUCaps *qemuC= aps, virDomainCaps *domCaps, unsigned int flags) { - virQEMUCapsHostCPUType cpuType =3D VIR_QEMU_CAPS_HOST_CPU_REPORTED; + virQEMUCapsHostCPUType cpuType; virCPUDef *cpu; =20 + if (flags & VIR_CONNECT_GET_DOMAIN_CAPABILITIES_EXPAND_CPU_FEATURES) + cpuType =3D VIR_QEMU_CAPS_HOST_CPU_SUPPORTED; + else + cpuType =3D VIR_QEMU_CAPS_HOST_CPU_REPORTED; + cpu =3D virCPUDefCopy(virQEMUCapsGetHostModel(qemuCaps, domCaps->virtt= ype, cpuType)); domCaps->cpu.hostModel =3D cpu; @@ -6656,9 +6673,6 @@ virQEMUCapsFillDomainCPUHostModel(virQEMUCaps *qemuCa= ps, virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, domCaps->virttype, cpu, VIR_CPU_FEATURE_DISABL= E); } - - if (flags & VIR_CONNECT_GET_DOMAIN_CAPABILITIES_EXPAND_CPU_FEATURES) - virCPUExpandFeatures(domCaps->arch, cpu); } =20 =20 diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index b26b5d3145..53db699ae7 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -795,6 +795,10 @@ typedef enum { * combined with features reported by QEMU. This is used for backward * compatible comparison between a guest CPU and a host CPU. */ VIR_QEMU_CAPS_HOST_CPU_FULL, + /* Host CPU definition containing all supported features, including th= ose + * that should not be automatically included in a host-model CPU and + * features that are implicitly enabled by the selected CPU model. */ + VIR_QEMU_CAPS_HOST_CPU_SUPPORTED, } virQEMUCapsHostCPUType; =20 virCPUDef *virQEMUCapsGetHostModel(virQEMUCaps *qemuCaps, --=20 2.54.0 From nobody Sat May 30 15:28:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1779876982; cv=none; d=zohomail.com; s=zohoarc; b=FVp86BEWu+KvlK8vMADMLAi8W7JE2m7/GJCzEls6YRv/Y9RUYbMp0750f/vUn2+fmj6H016RkR2yKOZSGHNo0EY2pw7pSHkbi7iFZ91f78PTr/cErMOPeZ0oT9PZcqhod2ZV3WElrLTqYhCQQJC7fWj9AdSbYV2Gdmwa44a13xQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779876982; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=b3vwcLLH2HNTl5mfxB5T5+vkVLjhgJfepXvuGR4LfOw=; b=B9kp1Uq7ZWHB0HpPBWIBFgNUME2FnLV7txdlnPaoid+vV/ng1JKCF3KMlNAMv+GeyvvnwlJGfhl5dvS5Wu4g14EhZc39eUe54TvDAtvwVB0K95e+3FMDkXTTSfYoQswqpe7me6o6IpVtuUZRCsprHNmzWhSBaUuZMGm+7I9vry0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1779876982353446.13689829544467; Wed, 27 May 2026 03:16:22 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 13966419D3; Wed, 27 May 2026 06:16:21 -0400 (EDT) Received: from [172.19.199.9] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 9380841E03; Wed, 27 May 2026 06:08:23 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 6DB7141D3B; Wed, 27 May 2026 06:07:58 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 6A4A941BC5 for ; Wed, 27 May 2026 06:07:38 -0400 (EDT) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-198-vNMAa6TKP9W0SK5uJxXoGg-1; Wed, 27 May 2026 06:07:36 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 53CFE18005B5 for ; Wed, 27 May 2026 10:07:35 +0000 (UTC) Received: from orkuz (unknown [10.43.3.115]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E1B961800286 for ; Wed, 27 May 2026 10:07:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779876457; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b3vwcLLH2HNTl5mfxB5T5+vkVLjhgJfepXvuGR4LfOw=; b=MyywBjJ0xvDCj8vEQDpQl+RRirw0yhb1zx/jNb3BjpZx5Ey0K4KJRvkS4Z7zmIGXgY3ImE B5atgXJ9wf09MK0NbkCdrSz969UsYSdhMNXLGmoWJhMbsiksHSrONtYxpIeUOJrIq0/kaQ HiAgwksH8N7JZtJgQ3CBHYZzw16rd6Y= X-MC-Unique: vNMAa6TKP9W0SK5uJxXoGg-1 X-Mimecast-MFC-AGG-ID: vNMAa6TKP9W0SK5uJxXoGg_1779876455 To: devel@lists.libvirt.org Subject: [PATCH 06/10] util: Publish and mock virHostCPUGetMSRFromKVM Date: Wed, 27 May 2026 12:07:18 +0200 Message-ID: <9290a9fdc0f1f22986a8da2918531919ede17c81.1779876382.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 5_RWE9xn8u4D2Lipxlj7fH7ggyCwXCIGPNi_IiY1W_o_1779876455 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: Z5L5XOCHLNBS6QAE4U6P5TKVJODWYDZI X-Message-ID-Hash: Z5L5XOCHLNBS6QAE4U6P5TKVJODWYDZI X-MailFrom: jdenemar@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Jiri Denemark via Devel Reply-To: Jiri Denemark X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1779876982927158500 Content-Type: text/plain; charset="utf-8" From: Jiri Denemark The function will later be called when probing QEMU capabilities. Signed-off-by: Jiri Denemark --- src/libvirt_private.syms | 1 + src/util/virhostcpu.c | 16 +++++++++++++++- src/util/virhostcpu.h | 3 +++ tests/qemucpumock.c | 22 ++++++++++++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 2391f01bc7..3653459ef1 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2619,6 +2619,7 @@ virHostCPUGetKVMMaxVCPUs; virHostCPUGetMap; virHostCPUGetMicrocodeVersion; virHostCPUGetMSR; +virHostCPUGetMSRFromKVM; virHostCPUGetOnline; virHostCPUGetOnlineBitmap; virHostCPUGetPhysAddrSize; diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index 60743765a4..afa9ee3849 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -1376,7 +1376,12 @@ virHostCPUGetMicrocodeVersion(virArch hostArch G_GNU= C_UNUSED) =20 #if WITH_LINUX_KVM_H && defined(KVM_GET_MSRS) && \ (defined(__i386__) || defined(__x86_64__)) -static int +/* + * Returns 0 on success, + * 1 when the MSR is not supported by the host CPU, + * -1 on error. + */ +int virHostCPUGetMSRFromKVM(unsigned long index, uint64_t *result) { @@ -1613,6 +1618,15 @@ virHostCPUGetCPUID(void) return NULL; } =20 +int +virHostCPUGetMSRFromKVM(unsigned long index G_GNUC_UNUSED, + uint64_t *result G_GNUC_UNUSED) +{ + virReportSystemError(ENOSYS, "%s", + _("Reading MSRs is not supported on this platform= ")); + return -1; +} + int virHostCPUGetMSR(unsigned long index G_GNUC_UNUSED, uint64_t *msr G_GNUC_UNUSED) diff --git a/src/util/virhostcpu.h b/src/util/virhostcpu.h index 238054ed34..4df126dcc4 100644 --- a/src/util/virhostcpu.h +++ b/src/util/virhostcpu.h @@ -78,6 +78,9 @@ int virHostCPUGetOnline(unsigned int cpu, bool *online); unsigned int virHostCPUGetMicrocodeVersion(virArch hostArch) ATTRIBUTE_MOCKABLE; =20 +int virHostCPUGetMSRFromKVM(unsigned long index, + uint64_t *result) ATTRIBUTE_MOCKABLE; + int virHostCPUGetMSR(unsigned long index, uint64_t *msr); =20 diff --git a/tests/qemucpumock.c b/tests/qemucpumock.c index c85721f448..f8410912d4 100644 --- a/tests/qemucpumock.c +++ b/tests/qemucpumock.c @@ -23,6 +23,7 @@ #include "qemu/qemu_capspriv.h" #include "testutilshostcpus.h" #include "virarch.h" +#include "util/virhostcpu.h" =20 =20 virCPUDef * @@ -33,3 +34,24 @@ virQEMUCapsProbeHostCPU(virArch hostArch G_GNUC_UNUSED, =20 return testUtilsHostCpusGetDefForModel(model); } + + +int +virHostCPUGetMSRFromKVM(unsigned long index, + uint64_t *result) +{ + if (index =3D=3D 0x10a) { + /* Return some arbitrary bits in arch-capabilities MSR */ + *result =3D + 0x00000001 | /* rdctl-no */ + 0x00000008 | /* skip-l1dfl-vmentry */ + 0x00000020 | /* mds-no */ + 0x00000040 | /* pschange-mc-no */ + 0x04000000 | /* gds-no */ + 0x08000000; /* rfds-no */ + return 0; + } + + errno =3D ENOTSUP; + return -1; +} --=20 2.54.0 From nobody Sat May 30 15:28:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1779877032; cv=none; d=zohomail.com; s=zohoarc; b=WaYTPRGcYBFL74pV68353A4YNoVKTgKXHZubfsYfYkqkU52nL/rgBIyp71baalcfFZ+HL8uuf+5EFdXtyvkBXypRa/Ncvw7D0OdXtfxPxxSeE5KwLci+7nUfjnAHctONs3qIe0WCzPExvRs26+hAN+x9PnAwsSC0B70VqVvl/8M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779877032; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=yNLmudSbJWj9wGmbDL4CI12LHo0e/8mXAyov5d5pEZI=; b=YML87Yz5PnEgfClinOPqn3fROMHIDz54Yks+TyO1kZd69A4whyhWfF4tQuiz1v9tDjR/ms27rqxs4aQe/tdVuNkai9IWJA02iQBgRqD9DjBtictmJlQzaNexKnb+Vdwl9KMkVX57kE+sQSu9LYmBbJ5UUuSpALZYrvuSlAxQOic= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1779877032909590.7228296339024; Wed, 27 May 2026 03:17:12 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id B78CD41B6F; Wed, 27 May 2026 06:17:11 -0400 (EDT) Received: from [172.19.199.9] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 435C641E39; Wed, 27 May 2026 06:08:30 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 9626841D17; Wed, 27 May 2026 06:08:14 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 4D50741C77 for ; Wed, 27 May 2026 06:07:40 -0400 (EDT) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-99-9Lxy4RDGNjmMKVBjX0ORVQ-1; Wed, 27 May 2026 06:07:37 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (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 mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 045FA180034A for ; Wed, 27 May 2026 10:07:37 +0000 (UTC) Received: from orkuz (unknown [10.43.3.115]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 93C0D404 for ; Wed, 27 May 2026 10:07:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779876459; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yNLmudSbJWj9wGmbDL4CI12LHo0e/8mXAyov5d5pEZI=; b=PQ4GyBwj0Ea48MUtNGcmfcxmer9jRj3KUbCleavS4MJoAZfQ/pK9GVXtnEPq17GznIhGem 8RWBQMKSwMSomxAS0KStoL1OX/BKG8uCkl9UeA7fJ+LHXA8MH02UG95a5fWr1b1EQgdjRA DHKAtUDU7nFKWuOFO4M+HVRDVQrv1J8= X-MC-Unique: 9Lxy4RDGNjmMKVBjX0ORVQ-1 X-Mimecast-MFC-AGG-ID: 9Lxy4RDGNjmMKVBjX0ORVQ_1779876457 To: devel@lists.libvirt.org Subject: [PATCH 07/10] cpu_x86: Introduce virCPUx86DataAddMSR Date: Wed, 27 May 2026 12:07:19 +0200 Message-ID: <00be87c78aed04b8c78bc2de121e171ced26901b.1779876382.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: T7CFjffhRgQIiXtAfks00vqo_tnkehh6bep3jNY0o_U_1779876457 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: JQHL3L7LHP564G6UQVE75L3TF62HFKEN X-Message-ID-Hash: JQHL3L7LHP564G6UQVE75L3TF62HFKEN X-MailFrom: jdenemar@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Jiri Denemark via Devel Reply-To: Jiri Denemark X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1779877034983158500 Content-Type: text/plain; charset="utf-8" From: Jiri Denemark This just makes the relevant part of virCPUx86GetHost reusable in other places. Signed-off-by: Jiri Denemark --- src/cpu/cpu_x86.c | 31 +++++++++++++++++++------------ src/cpu/cpu_x86.h | 4 ++++ src/libvirt_private.syms | 1 + 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 3a18d859dc..93f1427e36 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -2911,18 +2911,8 @@ virCPUx86GetHost(virCPUDef *cpu, /* This is best effort since there might be no way to read the MSR * when we are not running as root. */ for (i =3D 0; i < nmsrs; i++) { - if (virHostCPUGetMSR(msrs[i], &msr) =3D=3D 0) { - virCPUx86DataItem item =3D { - .type =3D VIR_CPU_X86_DATA_MSR, - .data.msr =3D { - .index =3D msrs[i], - .eax =3D msr & 0xffffffff, - .edx =3D msr >> 32, - }, - }; - - virCPUx86DataAdd(cpuData, &item); - } + if (virHostCPUGetMSR(msrs[i], &msr) =3D=3D 0) + virCPUx86DataAddMSR(cpuData, msrs[i], msr); } =20 ret =3D x86DecodeCPUData(cpu, cpuData, models); @@ -3460,6 +3450,23 @@ virCPUx86DataAdd(virCPUData *cpuData, } =20 =20 +void virCPUx86DataAddMSR(virCPUData *cpuData, + uint32_t index, + uint64_t value) +{ + virCPUx86DataItem item =3D { + .type =3D VIR_CPU_X86_DATA_MSR, + .data.msr =3D { + .index =3D index, + .eax =3D value & 0xffffffff, + .edx =3D value >> 32, + }, + }; + + virCPUx86DataAdd(cpuData, &item); +} + + void virCPUx86DataSetSignature(virCPUData *cpuData, unsigned int family, diff --git a/src/cpu/cpu_x86.h b/src/cpu/cpu_x86.h index 2cd965fea4..bbc2a16447 100644 --- a/src/cpu/cpu_x86.h +++ b/src/cpu/cpu_x86.h @@ -28,6 +28,10 @@ extern struct cpuArchDriver cpuDriverX86; void virCPUx86DataAdd(virCPUData *cpuData, const virCPUx86DataItem *cpuid); =20 +void virCPUx86DataAddMSR(virCPUData *cpuData, + uint32_t index, + uint64_t value); + void virCPUx86DataSetSignature(virCPUData *cpuData, unsigned int family, unsigned int model, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 3653459ef1..9d5e927b8a 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1598,6 +1598,7 @@ virCPUValidateFeatures; =20 # cpu/cpu_x86.h virCPUx86DataAdd; +virCPUx86DataAddMSR; virCPUx86DataGetSignature; virCPUx86DataSetSignature; virCPUx86DataSetVendor; --=20 2.54.0 From nobody Sat May 30 15:28:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1779877110; cv=none; d=zohomail.com; s=zohoarc; b=R05Ji+uQDHxywuVZI+anmZq6mNP9gWLSOZp/f03oy6OpwF6O0lNKLbyMZvS+tv7ALxnL/leKIN95Th8o1l2FU2ilqY+cehy9xc3M61scDcZCA0V1Wh0UcJFQdv2RXEalGkvWtLP5lRvBRVlHfor6HIHMt5zUACzpPsm+MGfkdv8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779877110; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=JK2Yb/qMgovee8ii5zKJtR2DpBjsoWZEm+st1bwUWhM=; b=KYgkxph63CyQMeO4wOkDQCJwQH0bcHhc6yX/DloZM7GVCCOEZA6oR3JYhgacp8hrhnyOUH22A13ssjNGBUFLwGR73cmSPJaFY3p9KuhEQYTvUQAq8XnQtLzLSPLFbb6RMN7fCfAozwqOKxTm8xKyA0S+DsocDKekSzuuAGNjMUU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1779877110531759.9721549659827; Wed, 27 May 2026 03:18:30 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 39B5B41B4D; Wed, 27 May 2026 06:18:29 -0400 (EDT) Received: from [172.19.199.9] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 92BE6423E1; Wed, 27 May 2026 06:08:42 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id D1C6841CE1; Wed, 27 May 2026 06:08:33 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id A050341C91 for ; Wed, 27 May 2026 06:07:41 -0400 (EDT) Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-139-pmbq8HW6N3-uMO6Hr3ccWA-1; Wed, 27 May 2026 06:07:39 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B0F7B195608B for ; Wed, 27 May 2026 10:07:38 +0000 (UTC) Received: from orkuz (unknown [10.43.3.115]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4B5131800465 for ; Wed, 27 May 2026 10:07:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,SPF_HELO_PASS autolearn=no autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779876461; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JK2Yb/qMgovee8ii5zKJtR2DpBjsoWZEm+st1bwUWhM=; b=Rv7TzJop+3xi3sRYnBMi1jKNIJr13d9T8vubdqYpb490nqfpq5f8LhjPscJTav+lBgkSYH 8+CV4Bajx9j1ALrhzCi3RlLZ6ynek1qqso11oLFu62+hqvXrBQDmNjEg++idZA/XA7ke0L XWn+7B9VU4SXS2Wb78NQu9XrHHWXIok= X-MC-Unique: pmbq8HW6N3-uMO6Hr3ccWA-1 X-Mimecast-MFC-AGG-ID: pmbq8HW6N3-uMO6Hr3ccWA_1779876458 To: devel@lists.libvirt.org Subject: [PATCH 08/10] cpu: Introduce virCPUUpdateFeatures Date: Wed, 27 May 2026 12:07:20 +0200 Message-ID: <16750ab74e7977fbbe8dd1fc9a6fa2b0b0f89021.1779876382.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: RDuraTJCkbUnzBZdyt1P02DdpNQaeBa28-49W1M2ECM_1779876458 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: Q3V26FYMBHR6YCWOLVF7UTYM4QT6QPO6 X-Message-ID-Hash: Q3V26FYMBHR6YCWOLVF7UTYM4QT6QPO6 X-MailFrom: jdenemar@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Jiri Denemark via Devel Reply-To: Jiri Denemark X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1779877111506158500 Content-Type: text/plain; charset="utf-8" From: Jiri Denemark This new API can be used to update an existing CPU definition with features described by CPU data. Signed-off-by: Jiri Denemark --- src/cpu/cpu.c | 33 +++++++++++++++++++++++++++++++++ src/cpu/cpu.h | 12 ++++++++++++ src/cpu/cpu_x86.c | 23 +++++++++++++++++++++++ src/libvirt_private.syms | 1 + 4 files changed, 69 insertions(+) diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index 233686485d..4231fffa02 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -1372,6 +1372,39 @@ virCPUGetCanonicalModel(virArch arch, } =20 =20 +/** virCPUUpdateFeatures: + * + * @arch: CPU architecture + * @cpu: CPU definition to update + * @cpuData: CPU data describing features + * @policy: to be used by the updated features + * + * Updates features described in @cpuData to use the specified @policy. Mi= ssing + * features will be automatically added to the CPU definition. + * + * Returns 0 on success, -1 otherwise. + */ +int +virCPUUpdateFeatures(virArch arch, + virCPUDef *cpu, + virCPUData *cpuData, + virCPUFeaturePolicy policy) +{ + struct cpuArchDriver *driver; + + VIR_DEBUG("arch=3D%s, cpu=3D%p, model=3D%s", + virArchToString(arch), cpu, NULLSTR(cpu->model)); + + if (!(driver =3D cpuGetSubDriver(arch))) + return -1; + + if (!driver->updateFeatures) + return 0; + + return driver->updateFeatures(cpu, cpuData, policy); +} + + /** * virCPUArchIsSupported: * diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index 36fd123675..65711ac085 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -143,6 +143,11 @@ typedef int typedef const char * (*virCPUArchGetCanonicalModel)(const char *model); =20 +typedef int +(*virCPUArchUpdateFeatures)(virCPUDef *cpu, + virCPUData *cpuData, + virCPUFeaturePolicy policy); + struct cpuArchDriver { const char *name; const virArch *arch; @@ -172,6 +177,7 @@ struct cpuArchDriver { virCPUArchDataGetHost dataGetHost; virCPUArchGetCheckMode getCheckMode; virCPUArchGetCanonicalModel getCanonicalModel; + virCPUArchUpdateFeatures updateFeatures; }; =20 =20 @@ -332,6 +338,12 @@ const char * virCPUGetCanonicalModel(virArch arch, const char *model); =20 +int +virCPUUpdateFeatures(virArch arch, + virCPUDef *cpu, + virCPUData *cpuData, + virCPUFeaturePolicy policy); + bool virCPUArchIsSupported(virArch arch); =20 diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 93f1427e36..f6a6a2a46c 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -3780,6 +3780,28 @@ virCPUx86GetCanonicalModel(const char *modelName) } =20 =20 +static int +virCPUx86UpdateFeatures(virCPUDef *cpu, + virCPUData *cpuData, + virCPUFeaturePolicy policy) +{ + virCPUx86Data *data =3D &cpuData->data.x86; + virCPUx86Map *map; + size_t i; + + if (!(map =3D virCPUx86GetMap())) + return -1; + + for (i =3D 0; i < map->nfeatures; i++) { + virCPUx86Feature *feature =3D map->features[i]; + if (x86DataIsSubset(data, &feature->data)) + virCPUDefUpdateFeature(cpu, feature->name, policy); + } + + return 0; +} + + struct cpuArchDriver cpuDriverX86 =3D { .name =3D "x86", .arch =3D archs, @@ -3814,4 +3836,5 @@ struct cpuArchDriver cpuDriverX86 =3D { #endif .getCheckMode =3D virCPUx86GetCheckMode, .getCanonicalModel =3D virCPUx86GetCanonicalModel, + .updateFeatures =3D virCPUx86UpdateFeatures, }; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 9d5e927b8a..e1f499899e 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1592,6 +1592,7 @@ virCPUGetVendorForModel; virCPUProbeHost; virCPUTranslate; virCPUUpdate; +virCPUUpdateFeatures; virCPUUpdateLive; virCPUValidateFeatures; =20 --=20 2.54.0 From nobody Sat May 30 15:28:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1779877172; cv=none; d=zohomail.com; s=zohoarc; b=TGVtuNiz5qXlmwoqksocXkxrR4AfbUzlxe2WKb8JlUM+5175b1cpPAsPFcADXIpi2ZhcrPCArxcv/s89wrTaHFGDtQl3Xhy1s8ui2tUH95yzPR1qllZk/IDAxo/CDdRaUk1qQGf5AT7xQ6ukkteG2U0x0IcCCwazNq8AT2/9A98= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779877172; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=6abEmJsymi0MZ1/rcCglbLgyv6/bmCxE/yfuCbSLWCg=; b=MzW4cPwyJ5I56ztOG4FoN6HHqP/gZzrF6FS71iBl+1bCfQbp8beHxpEWckSiyP+H7GqbY6eDA7uiZgf0o5Z4DaM0Sc6bE5e+addHYhCWHJ6M3hkKDTj0bdFQVX2q2C78NyCVSH2l7P1z1ffeGtD1iGVRQcoXJkLudgyR0kptLWc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1779877172827925.7874047613353; Wed, 27 May 2026 03:19:32 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id C916641BD7; Wed, 27 May 2026 06:19:31 -0400 (EDT) Received: from [172.19.199.9] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id A108042410; Wed, 27 May 2026 06:08:58 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id A067D41C9B; Wed, 27 May 2026 06:08:49 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 9041241C9B for ; Wed, 27 May 2026 06:07:43 -0400 (EDT) Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-392-kSUjwaY6OwGZ6ZI4tJzjQA-1; Wed, 27 May 2026 06:07:41 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4E6751956088 for ; Wed, 27 May 2026 10:07:40 +0000 (UTC) Received: from orkuz (unknown [10.43.3.115]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DCA4419560AB for ; Wed, 27 May 2026 10:07:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,SPF_HELO_PASS autolearn=no autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779876462; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6abEmJsymi0MZ1/rcCglbLgyv6/bmCxE/yfuCbSLWCg=; b=W28aBKh4htFdX7UI65L05fobPxpYCHzZ39/JeQ0cL4AezTkbIhq/XBJjQqfxBD/aLklUbA ScqIZtyRTUIlZFMIOKkiyoxkPdDMyUTBmf2ZVQSZ8gCehVYOo2rnoCN5yFopvQv5p081ER n663kdgQgI41aMubesjtC0TR/aTQbX4= X-MC-Unique: kSUjwaY6OwGZ6ZI4tJzjQA-1 X-Mimecast-MFC-AGG-ID: kSUjwaY6OwGZ6ZI4tJzjQA_1779876460 To: devel@lists.libvirt.org Subject: [PATCH 09/10] Clarify documentation of VIR_CONNECT_GET_DOMAIN_CAPABILITIES_EXPAND_CPU_FEATURES Date: Wed, 27 May 2026 12:07:21 +0200 Message-ID: <5bc60fc9b456d16ad24fe03ba958ca31f61c2ce3.1779876382.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: d0NsvQAz_cDLRFBlP3cBhY62usN7tQNYPjkeGJ6jorc_1779876460 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: JX3IAIPEZBMMR5JAJCNMUFEGJDEXVLHL X-Message-ID-Hash: JX3IAIPEZBMMR5JAJCNMUFEGJDEXVLHL X-MailFrom: jdenemar@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Jiri Denemark via Devel Reply-To: Jiri Denemark X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1779877179599154100 Content-Type: text/plain; charset="utf-8" From: Jiri Denemark The flag is designed for showing all CPU features supported by the virt stack. But the description was not really consistent in all places. Signed-off-by: Jiri Denemark --- docs/manpages/virsh.rst | 4 +++- include/libvirt/libvirt-domain.h | 2 +- src/libvirt-domain.c | 7 +++++-- tools/virsh-host.c | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index d1901c82c2..8c445c685a 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -641,7 +641,9 @@ features will be paired with the "disable" policy. =20 The **--expand-cpu-features** option will cause the host-model CPU definit= ion to contain all CPU features supported on the host including those implicit= ly -enabled by the selected CPU model. +enabled by the selected CPU model. The CPU definition may also contain ext= ra +features that are supported on the host, but should not be enabled by defa= ult +when starting a domain with host-model CPU. =20 =20 pool-capabilities diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 8f07ef2156..b7b0b80318 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -1547,7 +1547,7 @@ int virDomainMigrateStartPostCopy(virDomainPtr domain, typedef enum { /* Report host model with deprecated features disabled. (Since: 11.0.0= ) */ VIR_CONNECT_GET_DOMAIN_CAPABILITIES_DISABLE_DEPRECATED_FEATURES =3D (1= << 0), - /* Report all host model CPU features. (Since: 12.2.0) */ + /* Report all CPU features supported on the host. (Since: 12.2.0) */ VIR_CONNECT_GET_DOMAIN_CAPABILITIES_EXPAND_CPU_FEATURES =3D (1 << 1), } virConnectGetDomainCapabilitiesFlags; =20 diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index a4cbeb8ad4..eeeb060f0d 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -12354,8 +12354,11 @@ virDomainSetUserPassword(virDomainPtr dom, * * If @flags includes VIR_CONNECT_GET_DOMAIN_CAPABILITIES_EXPAND_CPU_FEATU= RES, * libvirt will explicitly list all CPU features (in host-model CPU defini= tion) - * that are supported on the host. Without this flag features that are par= t of - * the CPU model itself will not be listed. + * that are supported on the host. Specifically, features that are normally + * hidden as included in the CPU model itself will be shown as well. The C= PU + * definition may also contain extra features that are supported on the ho= st, + * but should not be enabled by default when starting a domain with host-m= odel + * CPU. * * Returns NULL in case of error or an XML string * defining the capabilities. diff --git a/tools/virsh-host.c b/tools/virsh-host.c index ef91e22fed..8f323cbd96 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -121,7 +121,7 @@ static const vshCmdOptDef opts_domcapabilities[] =3D { }, {.name =3D "expand-cpu-features", .type =3D VSH_OT_BOOL, - .help =3D N_("show all features in host CPU model"), + .help =3D N_("show all supported features in host CPU model"), }, {.name =3D NULL} }; --=20 2.54.0 From nobody Sat May 30 15:28:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1779877228; cv=none; d=zohomail.com; s=zohoarc; b=QfvzfKTdiP1ySQ8F/qs6cSTsGwy94SWVjVT4PjAG4GWBlaDFi4RUKcFgJSdp/0KgH+Oc4ZS1NbERX5JrkUVSTEc8ucXGZLkABPNboEVRIIwk8L5H+N9uQT6dtWVhJc4y++Fnda2vaOHMgWOHlP6lhn66+pi47vJvOdFXClHiH9E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779877228; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=NO9nFAsy9Q0l8cc8NFy3SAe/4MdRAVWS4k/xxbk4zEQ=; b=OLc6Lt5aVYrxPL88bnwD+FtPoPfvufqghtVMDFb3hHgXYk9GIYfbtwWyHOsGPdZ2itm48Ve894W4vkwLaBirFwQ7C2wk6jxqzjVtyRCTrO0RMHlC14W2GAqcKv8Hj37vZgAB8fE69nLscxRFzt+Ei4nomKaZwvk6/z+dhdL5BoY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1779877228774782.8850936485371; Wed, 27 May 2026 03:20:28 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id E62EF418F8; Wed, 27 May 2026 06:20:27 -0400 (EDT) Received: from [172.19.199.9] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 39A2241B6E; Wed, 27 May 2026 06:09:18 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 641F341B14; Wed, 27 May 2026 06:09:08 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id B2AA641B55 for ; Wed, 27 May 2026 06:07:44 -0400 (EDT) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-440-Ric5Q9u3MPa723jsXShJMg-1; Wed, 27 May 2026 06:07:42 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (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 mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1C527180034E for ; Wed, 27 May 2026 10:07:42 +0000 (UTC) Received: from orkuz (unknown [10.43.3.115]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AC762D6E for ; Wed, 27 May 2026 10:07:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779876464; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NO9nFAsy9Q0l8cc8NFy3SAe/4MdRAVWS4k/xxbk4zEQ=; b=Za4EY0vvUnP5wwTi5FkA6XdqhxygURWNucAdIsS8WG42BhKqumsSe9t9SHfnb+V8f3h8Fx 0V6yXArLTgE6ojuspaXggSGcG+9L8nvWrfuCVMc37VUwu4QTLmZ7mhKSBsxP/LebMMhQFH noYLwU3/0ybQUl++vNMklELp0bN0GKA= X-MC-Unique: Ric5Q9u3MPa723jsXShJMg-1 X-Mimecast-MFC-AGG-ID: Ric5Q9u3MPa723jsXShJMg_1779876462 To: devel@lists.libvirt.org Subject: [PATCH 10/10] qemu_capabilities: Fix domain capabilities on AMD CPUs Date: Wed, 27 May 2026 12:07:22 +0200 Message-ID: <27ce69614d00abf8da43bb07e0cb82beed011f83.1779876382.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: PNu90r_oyR9QT0XElEhpP39Qv6y-zdc3NqaPOaPi2Wg_1779876462 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: HZTIK5OOC3DQHVHLRLRUMG3X7PAWWP6M X-Message-ID-Hash: HZTIK5OOC3DQHVHLRLRUMG3X7PAWWP6M X-MailFrom: jdenemar@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Jiri Denemark via Devel Reply-To: Jiri Denemark X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1779877230151154100 Content-Type: text/plain; charset="utf-8" From: Jiri Denemark The arch-capabilities MSR is not defined on AMD CPUs, but KVM has always been emulating them. Unfortunately, this may cause Windows to crash so QEMU (since 10.1, commit d3a24134e37d57abd3e7445842cda2717f49e96d) decided to mask the MSR by default with some additional compatibility code for older machine types. This is all mostly transparent except for probing when we run QEMU without a machine type and expand the "host" CPU model. With QEMU 10.1 and newer none of the arch-capabilities features will be shown as enabled, which may cause unexpected issues for users (such as KubeVirt) that get the list of all supported features from the host-model CPU definition in domain capabilities to select possible target nodes for migration. As a result of the change, no AMD host with new QEMU will be shown as available for incoming migration from older hosts. While we don't want to add the features in host-model definition by default, we can show them when a user wants to see all features supported on the host, i.e., when a recently introduced VIR_CONNECT_GET_DOMAIN_CAPABILITIES_EXPAND_CPU_FEATURES flag is passed. Signed-off-by: Jiri Denemark --- src/qemu/qemu_capabilities.c | 39 ++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 8295a9ae9d..b0406b348a 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4093,6 +4093,41 @@ virQEMUCapsInitCPUModel(virQEMUCaps *qemuCaps, } =20 =20 +static virCPUDef * +virQEMUCapsInitExpandedHostCPUModel(virQEMUCaps *qemuCaps, + virCPUDef *hostModel) +{ + g_autoptr(virCPUDef) cpu =3D virCPUDefCopy(hostModel); + virArch arch =3D qemuCaps->arch; + + if (ARCH_IS_X86(arch) && + STREQ_NULLABLE(cpu->vendor, "AMD") && + virCPUCheckFeature(arch, cpu, "arch-capabilities") =3D=3D 0) { + uint32_t index =3D 0x10a; + uint64_t msr =3D 0; + /* While the arch-capabilities MSR is not defined on AMD CPUs, KVM= has + * always been emulating them. Unfortunately, this may cause some + * Windows version to crash so QEMU decided to mask the MSR by def= ault. + * Let's just add the emulated features back to the expanded host-= model + * definition used for reporting all CPU features supported on a h= ost. + */ + if (virHostCPUGetMSRFromKVM(index, &msr) =3D=3D 0) { + g_autoptr(virCPUData) data =3D virCPUDataNew(arch); + virCPUFeaturePolicy policy =3D VIR_CPU_FEATURE_REQUIRE; + + virCPUx86DataAddMSR(data, index, msr); + virCPUUpdateFeatures(arch, cpu, data, policy); + virCPUDefUpdateFeature(cpu, "arch-capabilities", policy); + } + } + + if (virCPUExpandFeatures(arch, cpu) < 0) + return NULL; + + return g_steal_pointer(&cpu); +} + + static virCPUDef * virQEMUCapsNewHostCPUModel(void) { @@ -4150,8 +4185,8 @@ virQEMUCapsInitHostCPUModel(virQEMUCaps *qemuCaps, &qemuCaps->arch); } =20 - cpuExpanded =3D virCPUDefCopy(cpu); - if (virCPUExpandFeatures(qemuCaps->arch, cpuExpanded) < 0) + cpuExpanded =3D virQEMUCapsInitExpandedHostCPUModel(qemuCaps, cpu); + if (!cpuExpanded) goto error; =20 if (rc =3D=3D 0 && --=20 2.54.0