From nobody Fri Dec 19 02:49:55 2025 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=1571153825; cv=none; d=zoho.com; s=zohoarc; b=WBQdDkAlEWdBeSAUfNxHr3aYiTC20eM8Acs0WF5KZsvFeNanunqfNSYcp6viHM8vwVexh4d7ADEXjTNnN8jKYF7C/XE1yYGXcWkmi6aYp2E0LZ+cDNY1lumNO+3LvwnKgXWUQccEZL5fKAMv9KOxafr+itIjwMDJLRDctaHcKDM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571153825; 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; bh=AKACQ042J0VKbJ3zVlu8H69plft8IwCf4r+kdPk09Ds=; b=GEYJtdEFk6OWnGrl2IRgASlbxCwvyvOCTxrzFozxqMJ1OE2i2l6nB6VofncUSZSSKWTWizfydMAypkmgNJQOFkAFb70Vag+69Al1qJ1zFuQspPUCWV/F2USkfeO/jKAAyu071u9b0VuiPO0TrtparNTdmsF8+x6FcwJXlyjbzb0= 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 1571153825476506.62352445314923; Tue, 15 Oct 2019 08:37:05 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B633620E4; Tue, 15 Oct 2019 15:37:03 +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 18B9D5FCDF; Tue, 15 Oct 2019 15:37:03 +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 CE8861803B4C; Tue, 15 Oct 2019 15:37:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9FFZEMw024625 for ; Tue, 15 Oct 2019 11:35:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id CD1635C1D6; Tue, 15 Oct 2019 15:35:14 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7C6435C1D4 for ; Tue, 15 Oct 2019 15:35:14 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 2E4DC101CCF; Tue, 15 Oct 2019 17:35:09 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 15 Oct 2019 17:34:42 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 06/31] qemu: Filter models in virQEMUCapsGetCPUDefinitions 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-Type: text/plain; charset="utf-8" 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.71]); Tue, 15 Oct 2019 15:37:04 +0000 (UTC) Some callers of virQEMUCapsGetCPUDefinitions will need to filter the returned list of CPU models. Let's add the filtering parameters directly to virQEMUCapsGetCPUDefinitions to avoid copying the CPU models list twice. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- Notes: Version 2: - no change src/qemu/qemu_capabilities.c | 11 ++++++++--- src/qemu/qemu_capabilities.h | 4 +++- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_process.c | 2 +- tests/cputest.c | 2 +- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index a40bf99aa3..e6a7ee4f14 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1889,7 +1889,9 @@ virQEMUCapsAddCPUDefinitions(virQEMUCapsPtr qemuCaps, =20 virDomainCapsCPUModelsPtr virQEMUCapsGetCPUDefinitions(virQEMUCapsPtr qemuCaps, - virDomainVirtType type) + virDomainVirtType type, + const char **modelWhitelist, + const char **modelBlacklist) { virDomainCapsCPUModelsPtr cpuModels; =20 @@ -1901,6 +1903,9 @@ virQEMUCapsGetCPUDefinitions(virQEMUCapsPtr qemuCaps, if (!cpuModels) return NULL; =20 + if (modelWhitelist || modelBlacklist) + return virDomainCapsCPUModelsFilter(cpuModels, modelWhitelist, mod= elBlacklist); + return virDomainCapsCPUModelsCopy(cpuModels); } =20 @@ -3142,7 +3147,7 @@ virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps, if (!(data =3D virQEMUCapsGetCPUModelX86Data(qemuCaps, model, migratab= le))) goto cleanup; =20 - cpuModels =3D virQEMUCapsGetCPUDefinitions(qemuCaps, type); + cpuModels =3D virQEMUCapsGetCPUDefinitions(qemuCaps, type, NULL, NULL); =20 if (cpuDecode(cpu, data, cpuModels) < 0) goto cleanup; @@ -3231,7 +3236,7 @@ virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps, =20 VIR_DEBUG("No host CPU model info from QEMU; probing host CPU dire= ctly"); =20 - cpuModels =3D virQEMUCapsGetCPUDefinitions(qemuCaps, type); + cpuModels =3D virQEMUCapsGetCPUDefinitions(qemuCaps, type, NULL, N= ULL); hostCPU =3D virQEMUCapsProbeHostCPU(hostArch, cpuModels); =20 if (!hostCPU || diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 10f0ce2654..67dccc522e 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -570,7 +570,9 @@ int virQEMUCapsAddCPUDefinitions(virQEMUCapsPtr qemuCap= s, size_t count, virDomainCapsCPUUsable usable); virDomainCapsCPUModelsPtr virQEMUCapsGetCPUDefinitions(virQEMUCapsPtr qemu= Caps, - virDomainVirtType t= ype); + virDomainVirtType t= ype, + const char **modelW= hitelist, + const char **modelB= lacklist); virDomainCapsCPUModelsPtr virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mo= n, virArch arch); =20 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 15c69667a5..802f07fe92 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13939,7 +13939,7 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn, if (!qemuCaps) goto cleanup; =20 - if (!(cpuModels =3D virQEMUCapsGetCPUDefinitions(qemuCaps, virttype)) = || + if (!(cpuModels =3D virQEMUCapsGetCPUDefinitions(qemuCaps, virttype, N= ULL, NULL)) || cpuModels->nmodels =3D=3D 0) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("QEMU '%s' does not support any CPU models for " diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 58192612b0..f37acab9e4 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6136,7 +6136,7 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def, VIR_QEMU_CAPS_HOST_CPU_MI= GRATABLE)) < 0) return -1; =20 - cpuModels =3D virQEMUCapsGetCPUDefinitions(qemuCaps, def->virtType= ); + cpuModels =3D virQEMUCapsGetCPUDefinitions(qemuCaps, def->virtType= , NULL, NULL); =20 if (virCPUTranslate(def->os.arch, def->cpu, cpuModels) < 0) return -1; diff --git a/tests/cputest.c b/tests/cputest.c index 3aa8fd7bf3..4428d451cf 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -550,7 +550,7 @@ cpuTestGetCPUModels(const struct data *data, if (!(qemuCaps =3D cpuTestMakeQEMUCaps(data))) return -1; =20 - *models =3D virQEMUCapsGetCPUDefinitions(qemuCaps, VIR_DOMAIN_VIRT_KVM= ); + *models =3D virQEMUCapsGetCPUDefinitions(qemuCaps, VIR_DOMAIN_VIRT_KVM= , NULL, NULL); =20 virObjectUnref(qemuCaps); =20 --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list