From nobody Sun Feb 8 10:04:16 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.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; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1492090442267179.14657307844595; Thu, 13 Apr 2017 06:34:02 -0700 (PDT) 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 412437AEB6; Thu, 13 Apr 2017 13:34:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E13E360BE5; Thu, 13 Apr 2017 13:33:59 +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 9F0EE4ED27; Thu, 13 Apr 2017 13:33:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v3DDX6q9013093 for ; Thu, 13 Apr 2017 09:33:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8C4D778355; Thu, 13 Apr 2017 13:33:06 +0000 (UTC) Received: from virval.usersys.redhat.com (dhcp129-92.brq.redhat.com [10.34.129.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 203037820E for ; Thu, 13 Apr 2017 13:33:04 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id BA1961041AB; Thu, 13 Apr 2017 15:32:59 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 412437AEB6 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 412437AEB6 From: Jiri Denemark To: libvir-list@redhat.com Date: Thu, 13 Apr 2017 15:32:54 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/9] qemu: Prepare qemuCaps for multiple host CPU defs 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: , MIME-Version: 1.0 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.25]); Thu, 13 Apr 2017 13:34:01 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Soon we will need to store multiple host CPU definitions in virQEMUCapsHostCPUData and qemuCaps users will want to request the one they need. This patch introduces virQEMUCapsHostCPUType enum which will be used for specifying the requested CPU definition. Signed-off-by: Jiri Denemark --- src/qemu/qemu_capabilities.c | 16 ++++++++++++---- src/qemu/qemu_capabilities.h | 10 +++++++++- src/qemu/qemu_command.c | 3 ++- src/qemu/qemu_process.c | 6 ++++-- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index f914154be..3bfc79c09 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2475,11 +2475,17 @@ virQEMUCapsGetHostCPUData(virQEMUCapsPtr qemuCaps, =20 virCPUDefPtr virQEMUCapsGetHostModel(virQEMUCapsPtr qemuCaps, - virDomainVirtType type) + virDomainVirtType type, + virQEMUCapsHostCPUType cpuType) { virQEMUCapsHostCPUDataPtr cpuData =3D virQEMUCapsGetHostCPUData(qemuCa= ps, type); =20 - return cpuData->reported; + switch (cpuType) { + case VIR_QEMU_CAPS_HOST_CPU_REPORTED: + return cpuData->reported; + } + + return NULL; } =20 =20 @@ -2508,7 +2514,8 @@ virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps, virQEMUCapsGuestIsNative(caps->host.arch, qemuCaps->arch); =20 case VIR_CPU_MODE_HOST_MODEL: - return !!virQEMUCapsGetHostModel(qemuCaps, type); + return !!virQEMUCapsGetHostModel(qemuCaps, type, + VIR_QEMU_CAPS_HOST_CPU_REPORTED); =20 case VIR_CPU_MODE_CUSTOM: if (type =3D=3D VIR_DOMAIN_VIRT_KVM) @@ -5521,7 +5528,8 @@ virQEMUCapsFillDomainCPUCaps(virCapsPtr caps, =20 if (virQEMUCapsIsCPUModeSupported(qemuCaps, caps, domCaps->virttype, VIR_CPU_MODE_HOST_MODEL)) { - virCPUDefPtr cpu =3D virQEMUCapsGetHostModel(qemuCaps, domCaps->vi= rttype); + virCPUDefPtr cpu =3D virQEMUCapsGetHostModel(qemuCaps, domCaps->vi= rttype, + VIR_QEMU_CAPS_HOST_CPU_= REPORTED); domCaps->cpu.hostModel =3D virCPUDefCopy(cpu); } =20 diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index cca9a12b5..bd147c009 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -449,8 +449,16 @@ int virQEMUCapsGetCPUDefinitions(virQEMUCapsPtr qemuCa= ps, virDomainVirtType type, char ***names, size_t *count); + +typedef enum { + /* Host CPU definition reported in domain capabilities. */ + VIR_QEMU_CAPS_HOST_CPU_REPORTED, +} virQEMUCapsHostCPUType; + virCPUDefPtr virQEMUCapsGetHostModel(virQEMUCapsPtr qemuCaps, - virDomainVirtType type); + virDomainVirtType type, + virQEMUCapsHostCPUType cpuType); + bool virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps, virCapsPtr caps, virDomainVirtType type, diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 57654246c..7e5cb3209 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6899,7 +6899,8 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, if (def->cpu->mode =3D=3D VIR_CPU_MODE_CUSTOM) cpuDef =3D def->cpu; else if (def->cpu->mode =3D=3D VIR_CPU_MODE_HOST_PASSTHROUGH) - cpuDef =3D virQEMUCapsGetHostModel(qemuCaps, def->virtType= ); + cpuDef =3D virQEMUCapsGetHostModel(qemuCaps, def->virtType, + VIR_QEMU_CAPS_HOST_CPU_RE= PORTED); =20 if (cpuDef) { int svm =3D virCPUCheckFeature(def->os.arch, cpuDef, "svm"= ); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 5e119a237..c05cd9e7a 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5304,12 +5304,14 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def, =20 if (def->cpu->check =3D=3D VIR_CPU_CHECK_PARTIAL && virCPUCompare(caps->host.arch, - virQEMUCapsGetHostModel(qemuCaps, def->virtType), + virQEMUCapsGetHostModel(qemuCaps, def->virtType, + VIR_QEMU_CAPS_HOST_CPU_REPOR= TED), def->cpu, true) < 0) return -1; =20 if (virCPUUpdate(def->os.arch, def->cpu, - virQEMUCapsGetHostModel(qemuCaps, def->virtType)) < 0) + virQEMUCapsGetHostModel(qemuCaps, def->virtType, + VIR_QEMU_CAPS_HOST_CPU_REPORT= ED)) < 0) goto cleanup; =20 if (virQEMUCapsGetCPUDefinitions(qemuCaps, def->virtType, --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list