From nobody Sun Feb 8 12:43:25 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=1570111690; cv=none; d=zoho.com; s=zohoarc; b=nIOLLXxMFHdhYAWXQ1PDiRbCKjkOV82zYGjwbKMuKlR7XS6qnd5HT7K8zs+I0HoV04eyul6kwViA6aEislyorOGIbLpB/ULMOrabA+QZmQyoYyfFKLbJ8IcjBR4VX1pEfNUpDlpRBl0JRv8oZrsyoC3J6ILQPmM9Dc9iJMk+cSE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570111690; 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=TJgFusx3Q+OjDTIMlDLVrvuWuJP1kRVyrb6YXwUMgXk=; b=K1rIjw5FnqAYMrYYI5F8xApwvtQw1ILVSaGvQSfcVrlqpYoEsf6jF8qXSHdcuaGQvBJw3B98fF/d8YqPRt6Hn/Q4DWCPuCC8q6SlZneML7xu5C3Y2cG4lZQO6LKsviPoO302OTb0OMwprl4ZVoeIMXBD3EtCGc2/xhaDGkhyZcg= 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 1570111690532842.9296113872907; Thu, 3 Oct 2019 07:08:10 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 51CC810CC1FE; Thu, 3 Oct 2019 14:08:08 +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 1A0305D721; Thu, 3 Oct 2019 14:08:08 +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 BF4B918005A0; Thu, 3 Oct 2019 14:08:07 +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 x93E5l1P021012 for ; Thu, 3 Oct 2019 10:05:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id AE24C5C22C; Thu, 3 Oct 2019 14:05:47 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5D0F65C290 for ; Thu, 3 Oct 2019 14:05:44 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 51B0E1005D7; Thu, 3 Oct 2019 16:05:43 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Thu, 3 Oct 2019 16:00:22 +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 04/22] 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-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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.65]); Thu, 03 Oct 2019 14:08:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" 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 --- 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 705e3a87b0..dac3d3b633 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1881,7 +1881,9 @@ virQEMUCapsAddCPUDefinitions(virQEMUCapsPtr qemuCaps, =20 virDomainCapsCPUModelsPtr virQEMUCapsGetCPUDefinitions(virQEMUCapsPtr qemuCaps, - virDomainVirtType type) + virDomainVirtType type, + const char **modelWhitelist, + const char **modelBlacklist) { virDomainCapsCPUModelsPtr cpuModels; =20 @@ -1893,6 +1895,9 @@ virQEMUCapsGetCPUDefinitions(virQEMUCapsPtr qemuCaps, if (!cpuModels) return NULL; =20 + if (modelWhitelist || modelBlacklist) + return virDomainCapsCPUModelsFilter(cpuModels, modelWhitelist, mod= elBlacklist); + return virDomainCapsCPUModelsCopy(cpuModels); } =20 @@ -3101,7 +3106,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; @@ -3190,7 +3195,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 5e990ce01e..f1510f3a7b 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -564,7 +564,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); =20 typedef enum { diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 9e681a22b3..265e10b466 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13780,7 +13780,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 9405bdc3f9..50f6df9dbd 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6147,7 +6147,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 40b843dd8f..a7cac82d84 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -541,7 +541,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