From nobody Sun Feb 8 12:13:52 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1551274179366919.153910032926; Wed, 27 Feb 2019 05:29:39 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D97A8772CF; Wed, 27 Feb 2019 13:29:36 +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 ADD80183D9; Wed, 27 Feb 2019 13:29:36 +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 59AC53FAF4; Wed, 27 Feb 2019 13:29:36 +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 x1RDTSkL004010 for ; Wed, 27 Feb 2019 08:29:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id 27BB91001DED; Wed, 27 Feb 2019 13:29:28 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EEC481018A00 for ; Wed, 27 Feb 2019 13:29:27 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 1111B106FB8; Wed, 27 Feb 2019 14:29:19 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Wed, 27 Feb 2019 14:29:02 +0100 Message-Id: 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 12/26] qemu_capabilities: Inroduce virQEMUCapsGetCPUModelX86Data 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 27 Feb 2019 13:29:37 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The code for transforming qemuMonitorCPUModelInfo data from QEMU into virCPUDefPtr consumable by virCPU* APIs was hidden inside virQEMUCapsInitCPUModelX86. This patch moves it into a new function to make it usable in tests. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_capabilities.c | 50 ++++++++++++++++++++++++------------ src/qemu/qemu_capspriv.h | 4 +++ 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index b48bcbebee..0504d99373 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2818,28 +2818,17 @@ virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps, } =20 =20 -/** - * Returns 0 when host CPU model provided by QEMU was filled in qemuCaps, - * 1 when the caller should fall back to using virCapsPtr->host.c= pu, - * -1 on error. - */ -static int -virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps, - virDomainVirtType type, - qemuMonitorCPUModelInfoPtr model, - virCPUDefPtr cpu, - bool migratable) +virCPUDataPtr +virQEMUCapsGetCPUModelX86Data(qemuMonitorCPUModelInfoPtr model, + bool migratable) { - virCPUDataPtr data =3D NULL; unsigned long long sigFamily =3D 0; unsigned long long sigModel =3D 0; unsigned long long sigStepping =3D 0; - int ret =3D -1; + virCPUDataPtr data =3D NULL; + virCPUDataPtr ret =3D NULL; size_t i; =20 - if (!model) - return 1; - if (!(data =3D virCPUDataNew(VIR_ARCH_X86_64))) goto cleanup; =20 @@ -2880,6 +2869,35 @@ virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps, if (virCPUx86DataSetSignature(data, sigFamily, sigModel, sigStepping) = < 0) goto cleanup; =20 + VIR_STEAL_PTR(ret, data); + + cleanup: + virCPUDataFree(data); + return ret; +} + + +/** + * Returns 0 when host CPU model provided by QEMU was filled in qemuCaps, + * 1 when the caller should fall back to using virCapsPtr->host.c= pu, + * -1 on error. + */ +static int +virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps, + virDomainVirtType type, + qemuMonitorCPUModelInfoPtr model, + virCPUDefPtr cpu, + bool migratable) +{ + virCPUDataPtr data =3D NULL; + int ret =3D -1; + + if (!model) + return 1; + + if (!(data =3D virQEMUCapsGetCPUModelX86Data(model, migratable))) + goto cleanup; + if (cpuDecode(cpu, data, virQEMUCapsGetCPUDefinitions(qemuCaps, type))= < 0) goto cleanup; =20 diff --git a/src/qemu/qemu_capspriv.h b/src/qemu/qemu_capspriv.h index b995e4d5d3..c8d45d699b 100644 --- a/src/qemu/qemu_capspriv.h +++ b/src/qemu/qemu_capspriv.h @@ -73,6 +73,10 @@ virQEMUCapsSetCPUModelInfo(virQEMUCapsPtr qemuCaps, virDomainVirtType type, qemuMonitorCPUModelInfoPtr modelInfo); =20 +virCPUDataPtr +virQEMUCapsGetCPUModelX86Data(qemuMonitorCPUModelInfoPtr model, + bool migratable); + virCPUDefPtr virQEMUCapsProbeHostCPUForEmulator(virArch hostArch, virQEMUCapsPtr qemuCaps, --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list