From nobody Tue Feb 10 12:45:18 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642416967; cv=none; d=zohomail.com; s=zohoarc; b=QzVoS728IvHnVmMd7vg/zqiOqYuSy1sDeU7+euN9tr3xXOnuPdPQ+hD0YSP0N7iK+JwRC92DXN37pKk1pxfKTPVotEiZyYoniGp3b/o8iGkEDAi6wl7U69BrAqkL4CWkCGqhOQfXEZGIwAPB4axfvfLqYkpI8gXmpU53S24p3aM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642416967; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=essw77yRzm73IC4/bK5hNwdr+NdzWbNCDIp++BXTUJI=; b=Ma3C7e0agw59p1vAua6yR5H1qHZUvkMOsrF70RZDmts6NbfsjrLHjy2dEZ/3JyxsS1vGli9r/YSkWuJr4hTZvQHoNM4Y6n2efz5uU5oSSDjbcVkSUyPL6ae37KsCZT/bGirTR+Ira8yxmAqhvfPJdZouMvoi8tl2NNs0YZnGizY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 16424169672411005.4557339586195; Mon, 17 Jan 2022 02:56:07 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-246-vttNQ62uM9SiGOEYjMC-Dg-1; Mon, 17 Jan 2022 05:56:02 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EB4AE1083F67; Mon, 17 Jan 2022 10:55:57 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CC8CB1059596; Mon, 17 Jan 2022 10:55:57 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9C7D31802FEA; Mon, 17 Jan 2022 10:55:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20HAr6Xw008984 for ; Mon, 17 Jan 2022 05:53:06 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1CBDC1059596; Mon, 17 Jan 2022 10:53:06 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.40.194.229]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4B22E1059A7C; Mon, 17 Jan 2022 10:53:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642416966; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=essw77yRzm73IC4/bK5hNwdr+NdzWbNCDIp++BXTUJI=; b=SFiq3/DO4Z6iQrsxpF7nw5PgSt6D2s7uVmmPXdiUx6bYfyoKLdwfjd5ZFUjkqdtsDKc4Go DCOnZb4EH49xh4Zr0pM/hjzaQT+5X6/M9vQKAH7+pM4wyAKGgPL+wPqtMly7XMLdA31sBf O9UP7iTfq8pzE2tWIpCY04JggkyGTL0= X-MC-Unique: vttNQ62uM9SiGOEYjMC-Dg-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 02/20] qemu: Add KVM CPUs into cache only if KVM is present Date: Mon, 17 Jan 2022 11:52:42 +0100 Message-Id: <20220117105300.15759-3-abologna@redhat.com> In-Reply-To: <20220117105300.15759-1-abologna@redhat.com> References: <20220117105300.15759-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: r.bolshakov@yadro.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642416969002100001 Content-Type: text/plain; charset="utf-8" From: Roman Bolshakov virQEMUCapsFormatCache/virQEMUCapsLoadCache adds/reads KVM CPUs to/from capabilities cache regardless of QEMU_CAPS_KVM. That can cause undesired side-effects when KVM CPUs are present in the cache on a platform that doesn't support it, e.g. macOS or Linux without KVM support. Signed-off-by: Roman Bolshakov Signed-off-by: Andrea Bolognani Tested-by: Brad Laue Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_capabilities.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index a71d3b912f..c2d56dfc9d 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4423,8 +4423,11 @@ virQEMUCapsLoadCache(virArch hostArch, return -1; } =20 - if (virQEMUCapsLoadAccel(qemuCaps, ctxt, VIR_DOMAIN_VIRT_KVM) < 0 || - virQEMUCapsLoadAccel(qemuCaps, ctxt, VIR_DOMAIN_VIRT_QEMU) < 0) + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM) && + virQEMUCapsLoadAccel(qemuCaps, ctxt, VIR_DOMAIN_VIRT_KVM) < 0) { + return -1; + } + if (virQEMUCapsLoadAccel(qemuCaps, ctxt, VIR_DOMAIN_VIRT_QEMU) < 0) return -1; =20 if (virQEMUCapsParseGIC(qemuCaps, ctxt) < 0) @@ -4433,7 +4436,8 @@ virQEMUCapsLoadCache(virArch hostArch, if (virQEMUCapsParseSEVInfo(qemuCaps, ctxt) < 0) return -1; =20 - virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_KVM); + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) + virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_KV= M); virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_QEMU); =20 if (virXPathBoolean("boolean(./kvmSupportsNesting)", ctxt) > 0) @@ -4666,7 +4670,8 @@ virQEMUCapsFormatCache(virQEMUCaps *qemuCaps) virBufferAsprintf(&buf, "%s\n", virArchToString(qemuCaps->arch)); =20 - virQEMUCapsFormatAccel(qemuCaps, &buf, VIR_DOMAIN_VIRT_KVM); + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) + virQEMUCapsFormatAccel(qemuCaps, &buf, VIR_DOMAIN_VIRT_KVM); virQEMUCapsFormatAccel(qemuCaps, &buf, VIR_DOMAIN_VIRT_QEMU); =20 for (i =3D 0; i < qemuCaps->ngicCapabilities; i++) { @@ -5520,7 +5525,8 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch, qemuCaps->libvirtCtime =3D virGetSelfLastChanged(); qemuCaps->libvirtVersion =3D LIBVIR_VERSION_NUMBER; =20 - virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_KVM); + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) + virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_KV= M); virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_QEMU); =20 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) { --=20 2.34.1