From nobody Sun Feb 8 20:58:04 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1559564951; cv=none; d=zoho.com; s=zohoarc; b=JgvvgwevNUHk4IeQMXDed6YZNeRbf97ds6DNtiAUl7wROIsaI0OcWVgDRKt5sKWLGUxvmhq3hSGYVIaVbXWw6MUvRXR6caDUHsohLmhZ+Hn62MiCpS9UT8gC0RbMqM+VUA2TcEZ6P9yzffocL68BdbWxV+rMOTN7CVnyBEGadvY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559564951; h=Content-Type:Content-Transfer-Encoding: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:ARC-Authentication-Results; bh=MPGoveVAkzMxIBXXzYvnXu956aaBttPCf/6BUQi7eMU=; b=Lfz1IItl5SkhjwYH5jU3s3lNoc+E1qhrF27ZJEFD4X7dTqQX2NUCB0Jv2LYayN3/lds1gL+rxl23s/xvrNdve58NEH5PbM1Zr+vhRcKuER3slN8gaaLzhR/cIU0//3NclKqSJR4Yp7llEWmV5GELcd9dnCMs54NTUeG/SJ+fFzw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1559564951481163.70298404856703; Mon, 3 Jun 2019 05:29:11 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 529F1A3EB8; Mon, 3 Jun 2019 12:29:01 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 22B9F5D9CC; Mon, 3 Jun 2019 12:28:58 +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 2B02B1972B; Mon, 3 Jun 2019 12:28:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x53CS51f003619 for ; Mon, 3 Jun 2019 08:28:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5A1DF5D9D2; Mon, 3 Jun 2019 12:28:05 +0000 (UTC) Received: from orkuz.int.mamuti.net (unknown [10.40.205.163]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 028CC5D9CD for ; Mon, 3 Jun 2019 12:28:01 +0000 (UTC) Received: by orkuz.int.mamuti.net (Postfix, from userid 500) id 7E42A2A042B; Mon, 3 Jun 2019 14:27:59 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 3 Jun 2019 14:27:52 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 1/7] qemu: Make virQEMUCapsProbeHostCPUForEmulator more generic 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 03 Jun 2019 12:29:10 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The function is renamed as virQEMUCapsProbeHostCPU and it does not get the list of allowed CPU models from qemuCaps anymore. This is responsibility is moved to the caller. The result is just a very thin wrapper around virCPUGetHost mostly required mocking in tests. The generic function is used in place of a direct call to virCPUGetHost in virQEMUCapsInitHostCPUModel to make sure tests don't accidentally probe host CPU. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_capabilities.c | 14 ++++++-------- src/qemu/qemu_capspriv.h | 5 ++--- tests/qemucpumock.c | 5 ++--- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index a827bd24e3..5cddae06c6 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -880,12 +880,10 @@ virQEMUCapsInitGuestFromBinary(virCapsPtr caps, =20 =20 virCPUDefPtr -virQEMUCapsProbeHostCPUForEmulator(virArch hostArch, - virQEMUCapsPtr qemuCaps, - virDomainVirtType type) +virQEMUCapsProbeHostCPU(virArch hostArch, + virDomainCapsCPUModelsPtr models) { - return virCPUGetHost(hostArch, VIR_CPU_TYPE_GUEST, NULL, - virQEMUCapsGetCPUDefinitions(qemuCaps, type)); + return virCPUGetHost(hostArch, VIR_CPU_TYPE_GUEST, NULL, models); } =20 =20 @@ -3049,7 +3047,8 @@ virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps, } else if (rc =3D=3D 1) { VIR_DEBUG("No host CPU model info from QEMU; probing host CPU dire= ctly"); =20 - hostCPU =3D virQEMUCapsProbeHostCPUForEmulator(hostArch, qemuCaps,= type); + hostCPU =3D virQEMUCapsProbeHostCPU(hostArch, + virQEMUCapsGetCPUDefinitions(qem= uCaps, type)); if (!hostCPU || virCPUDefCopyModelFilter(cpu, hostCPU, true, virQEMUCapsCPUFilterFeatures, @@ -3062,8 +3061,7 @@ virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps, goto error; } else if (type =3D=3D VIR_DOMAIN_VIRT_KVM && virCPUGetHostIsSupported(qemuCaps->arch)) { - if (!(fullCPU =3D virCPUGetHost(qemuCaps->arch, VIR_CPU_TYPE_GUEST, - NULL, NULL))) + if (!(fullCPU =3D virQEMUCapsProbeHostCPU(qemuCaps->arch, NULL))) goto error; =20 if (!(cpuExpanded =3D virCPUDefCopy(cpu)) || diff --git a/src/qemu/qemu_capspriv.h b/src/qemu/qemu_capspriv.h index 2d059bee8c..3c129cbf6c 100644 --- a/src/qemu/qemu_capspriv.h +++ b/src/qemu/qemu_capspriv.h @@ -82,9 +82,8 @@ virQEMUCapsGetCPUModelX86Data(qemuMonitorCPUModelInfoPtr = model, bool migratable); =20 virCPUDefPtr -virQEMUCapsProbeHostCPUForEmulator(virArch hostArch, - virQEMUCapsPtr qemuCaps, - virDomainVirtType type) ATTRIBUTE_NOINL= INE; +virQEMUCapsProbeHostCPU(virArch hostArch, + virDomainCapsCPUModelsPtr models) ATTRIBUTE_NOINLI= NE; =20 void virQEMUCapsSetGICCapabilities(virQEMUCapsPtr qemuCaps, diff --git a/tests/qemucpumock.c b/tests/qemucpumock.c index e028ada8eb..501738df36 100644 --- a/tests/qemucpumock.c +++ b/tests/qemucpumock.c @@ -27,9 +27,8 @@ =20 =20 virCPUDefPtr -virQEMUCapsProbeHostCPUForEmulator(virArch hostArch ATTRIBUTE_UNUSED, - virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSE= D, - virDomainVirtType type ATTRIBUTE_UNUSED) +virQEMUCapsProbeHostCPU(virArch hostArch ATTRIBUTE_UNUSED, + virDomainCapsCPUModelsPtr models ATTRIBUTE_UNUSED) { const char *model =3D getenv("VIR_TEST_MOCK_FAKE_HOST_CPU"); =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list