From nobody Mon Feb 9 01:47:40 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 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=1572960517; cv=none; d=zoho.com; s=zohoarc; b=mk+nrEO2XKZWVJoFj1mFxLqJqescdpyN5Dc1zgjshJaBiHer5POg9NkI+FJ4BhIuWvBZ9hlJEwWVEDtN0jLJndLND1Xaw4PaDLN4ddoiQGQoq9cgQlb/+NnwRlcKZjs41q2Ath34EhVt5XPCCbcaJeFD9F0pQs1mseflnuCt37k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572960517; 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=tIbjBXH8mohyjCfBMhUccd/sJr0vN/MKSM7qDSNrhyw=; b=T0GC2OO2dZwuaqIRSpZtLu4mpa16NPBimZqT2gccpqOV22zkVyZ6kR1VKzBuD+s4kEJxTBvVEvT5JR988JBGlZ4NLAo8L/95wkvXCHQhu3DdWHWhR9NQQrQSAtwEJoF4EohoDxvpQ+aXRXueoc+KLphqHaQ1eDXjtX8TyVvulb4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1572960517642501.26094177921493; Tue, 5 Nov 2019 05:28:37 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-396-gcrHWdsEMFyM00CI34eTIg-1; Tue, 05 Nov 2019 08:28:34 -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 793121804979; Tue, 5 Nov 2019 13:28:28 +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 49D6E1001B00; Tue, 5 Nov 2019 13:28:28 +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 DA24F4E56F; Tue, 5 Nov 2019 13:28:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xA5DRvwJ003885 for ; Tue, 5 Nov 2019 08:27:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id E2E77600C8; Tue, 5 Nov 2019 13:27:57 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9188D600C4 for ; Tue, 5 Nov 2019 13:27:57 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 7149C105B22; Tue, 5 Nov 2019 14:27:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572960516; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=tIbjBXH8mohyjCfBMhUccd/sJr0vN/MKSM7qDSNrhyw=; b=QjO7E+o8C3Zw9k+pgAFO+m9wO8xB2zNIToMkqfZvOzozVPshLSGMsuhbGOxKn6SIk76c9/ 5T2jbNQTrLM1P0njR+tb9vTpEvmz3yrY+d4OJZB99g9oIL8DwFeP/YXcEMl7cKFiSjKnIc 6lKh1flm+ZBFsjWETmuOBFACMeAO5bA= From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 5 Nov 2019 14:27:03 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 05/52] 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: gcrHWdsEMFyM00CI34eTIg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) 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 --- Notes: Version 2: - no change =20 Version 3: - g_autoptr src/conf/domain_capabilities.h | 2 ++ src/qemu/qemu_capabilities.c | 23 ++++++++++++++++++----- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_process.c | 7 +++++-- tests/cputest.c | 1 - 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h index 264c7fc429..36500435fd 100644 --- a/src/conf/domain_capabilities.h +++ b/src/conf/domain_capabilities.h @@ -139,6 +139,8 @@ struct _virDomainCapsCPUModels { virDomainCapsCPUModelPtr models; }; =20 +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainCapsCPUModels, virObjectUnref); + typedef struct _virDomainCapsCPU virDomainCapsCPU; typedef virDomainCapsCPU *virDomainCapsCPUPtr; struct _virDomainCapsCPU { diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 8fd503a49c..afac77c1e4 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1885,10 +1885,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 @@ -3112,6 +3119,7 @@ virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps, virCPUDefPtr cpu, bool migratable) { + g_autoptr(virDomainCapsCPUModels) cpuModels =3D NULL; virCPUDataPtr data =3D NULL; int ret =3D -1; =20 @@ -3121,7 +3129,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; @@ -3204,10 +3214,13 @@ virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps, if ((rc =3D virQEMUCapsInitCPUModel(qemuCaps, type, cpu, false)) < 0) { goto error; } else if (rc =3D=3D 1) { + g_autoptr(virDomainCapsCPUModels) 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 d17c18705b..380943dda3 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13704,7 +13704,7 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn, g_autoptr(virQEMUCaps) qemuCaps =3D NULL; virArch arch; virDomainVirtType virttype; - virDomainCapsCPUModelsPtr cpuModels; + g_autoptr(virDomainCapsCPUModels) 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 ed8666e9d1..5bc13035a4 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6110,6 +6110,8 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def, =20 /* nothing to update for host-passthrough */ if (def->cpu->mode !=3D VIR_CPU_MODE_HOST_PASSTHROUGH) { + g_autoptr(virDomainCapsCPUModels) cpuModels =3D NULL; + if (def->cpu->check =3D=3D VIR_CPU_CHECK_PARTIAL && virCPUCompare(caps->host.arch, virQEMUCapsGetHostModel(qemuCaps, def->virtType, @@ -6122,8 +6124,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 6ead9e0982..e75e8bf906 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -549,7 +549,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