From nobody Mon Feb 9 05:00:58 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=1570111553; cv=none; d=zoho.com; s=zohoarc; b=Ns4qjYmEbZxl+aRw/0b9LUfg3f8rnF+FCtDVTTKtGi9o/VYxQpI2xJXnH5IJBOAnydJBPEY0d+KyJx5/2HNVfDEWGiKmjUZHc3BPb75tXSxVeEldOnfF42wZYbD0VRY62Rbf5w/UqSiNUQ8o8rlzaM9+AJxPPDk+9ncU31y1UDU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570111553; 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=soGrObgf6+jXXAYa0jDL7u0jhjuQQOD+NOHgEvPP5ZM=; b=E+Tff7Iq1xmMXvjSC/W66CiTriMysIX2Hm56bptnXeN87DhRAjUlWhfLDYwnM0NYSruqgqkFLSCfsW5mUhiugYpMmwYw3XDO7LtWQAr51PZwvMLRvyWdjJHml8Xfw0zR7ki3f4V2SMFCiFzb3qgxgAhGG1jKlAO68EKuyIrsZTM= 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 1570111553361524.8660113263027; Thu, 3 Oct 2019 07:05:53 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F3EFF641C9; Thu, 3 Oct 2019 14:05:50 +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 52EBA5C226; Thu, 3 Oct 2019 14:05:50 +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 7CDE762CF9; Thu, 3 Oct 2019 14:05:48 +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 x93E5luZ020997 for ; Thu, 3 Oct 2019 10:05:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 52AE11001B23; 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 01F561001B13 for ; Thu, 3 Oct 2019 14:05:44 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 4C5061005D6; Thu, 3 Oct 2019 16:05:43 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Thu, 3 Oct 2019 16:00:21 +0200 Message-Id: <578c6b45a5509fe060bc96b51265186abc1a5e9f.1570111135.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 03/22] qemu: Copy CPU 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 03 Oct 2019 14:05:51 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Rather than returning a direct pointer the list stored in qemuCaps the function now creates a new copy of the CPU models list. The main purpose of this seemingly useless change is to update callers to free the result returned by virQEMUCapsGetCPUDefinitions because the internals of this function will change significantly in the following patches. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_capabilities.c | 23 ++++++++++++++++++----- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_process.c | 7 +++++-- tests/cputest.c | 1 - 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 806d102efd..705e3a87b0 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1883,10 +1883,17 @@ virDomainCapsCPUModelsPtr virQEMUCapsGetCPUDefinitions(virQEMUCapsPtr qemuCaps, virDomainVirtType type) { + virDomainCapsCPUModelsPtr cpuModels; + if (type =3D=3D VIR_DOMAIN_VIRT_KVM) - return qemuCaps->kvmCPUModels; + cpuModels =3D qemuCaps->kvmCPUModels; else - return qemuCaps->tcgCPUModels; + cpuModels =3D qemuCaps->tcgCPUModels; + + if (!cpuModels) + return NULL; + + return virDomainCapsCPUModelsCopy(cpuModels); } =20 =20 @@ -3084,6 +3091,7 @@ virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps, virCPUDefPtr cpu, bool migratable) { + VIR_AUTOUNREF(virDomainCapsCPUModelsPtr) cpuModels =3D NULL; virCPUDataPtr data =3D NULL; int ret =3D -1; =20 @@ -3093,7 +3101,9 @@ virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps, if (!(data =3D virQEMUCapsGetCPUModelX86Data(qemuCaps, model, migratab= le))) goto cleanup; =20 - if (cpuDecode(cpu, data, virQEMUCapsGetCPUDefinitions(qemuCaps, type))= < 0) + cpuModels =3D virQEMUCapsGetCPUDefinitions(qemuCaps, type); + + if (cpuDecode(cpu, data, cpuModels) < 0) goto cleanup; =20 ret =3D 0; @@ -3176,10 +3186,13 @@ virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps, if ((rc =3D virQEMUCapsInitCPUModel(qemuCaps, type, cpu, false)) < 0) { goto error; } else if (rc =3D=3D 1) { + VIR_AUTOUNREF(virDomainCapsCPUModelsPtr) cpuModels =3D NULL; + VIR_DEBUG("No host CPU model info from QEMU; probing host CPU dire= ctly"); =20 - hostCPU =3D virQEMUCapsProbeHostCPU(hostArch, - virQEMUCapsGetCPUDefinitions(qem= uCaps, type)); + cpuModels =3D virQEMUCapsGetCPUDefinitions(qemuCaps, type); + hostCPU =3D virQEMUCapsProbeHostCPU(hostArch, cpuModels); + if (!hostCPU || virCPUDefCopyModelFilter(cpu, hostCPU, true, virQEMUCapsCPUFilterFeatures, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 95fe844c34..9e681a22b3 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13754,7 +13754,7 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn, virQEMUCapsPtr qemuCaps =3D NULL; virArch arch; virDomainVirtType virttype; - virDomainCapsCPUModelsPtr cpuModels; + VIR_AUTOUNREF(virDomainCapsCPUModelsPtr) cpuModels =3D NULL; bool migratable; virCPUDefPtr cpu =3D NULL; char *cpustr =3D NULL; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index a50cd54393..9405bdc3f9 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6133,6 +6133,8 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def, =20 /* nothing to update for host-passthrough */ if (def->cpu->mode !=3D VIR_CPU_MODE_HOST_PASSTHROUGH) { + VIR_AUTOUNREF(virDomainCapsCPUModelsPtr) cpuModels =3D NULL; + if (def->cpu->check =3D=3D VIR_CPU_CHECK_PARTIAL && virCPUCompare(caps->host.arch, virQEMUCapsGetHostModel(qemuCaps, def->virtType, @@ -6145,8 +6147,9 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def, VIR_QEMU_CAPS_HOST_CPU_MI= GRATABLE)) < 0) return -1; =20 - if (virCPUTranslate(def->os.arch, def->cpu, - virQEMUCapsGetCPUDefinitions(qemuCaps, def->vi= rtType)) < 0) + cpuModels =3D virQEMUCapsGetCPUDefinitions(qemuCaps, def->virtType= ); + + if (virCPUTranslate(def->os.arch, def->cpu, cpuModels) < 0) return -1; =20 def->cpu->fallback =3D VIR_CPU_FALLBACK_FORBID; diff --git a/tests/cputest.c b/tests/cputest.c index 403d23b961..40b843dd8f 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -542,7 +542,6 @@ cpuTestGetCPUModels(const struct data *data, return -1; =20 *models =3D virQEMUCapsGetCPUDefinitions(qemuCaps, VIR_DOMAIN_VIRT_KVM= ); - virObjectRef(*models); =20 virObjectUnref(qemuCaps); =20 --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list