From nobody Sun Feb 8 18:31:05 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1505387567241734.1839493880034; Thu, 14 Sep 2017 04:12:47 -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 E094912E9; Thu, 14 Sep 2017 11:12:45 +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 92A4E5C54C; Thu, 14 Sep 2017 11:12:45 +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 2EBD33FC73; Thu, 14 Sep 2017 11:12:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8EAvQXw018283 for ; Thu, 14 Sep 2017 06:57:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id 965C66267E; Thu, 14 Sep 2017 10:57:26 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.105]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 444C867592 for ; Thu, 14 Sep 2017 10:57:23 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 9595F1002D8; Thu, 14 Sep 2017 12:57:22 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E094912E9 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Jiri Denemark To: libvir-list@redhat.com Date: Thu, 14 Sep 2017 12:57:17 +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.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/7] cpu: Drop cpuBaselineXML 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 14 Sep 2017 11:12:46 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The implementation of virConnectBaselineCPU may be different for each hypervisor. Thus it shouldn't really be implmented in the cpu code. Signed-off-by: Jiri Denemark --- src/bhyve/bhyve_driver.c | 22 +++++++++++++++--- src/cpu/cpu.c | 58 --------------------------------------------= ---- src/cpu/cpu.h | 7 ------ src/libvirt_private.syms | 1 - src/libxl/libxl_driver.c | 22 +++++++++++++++--- src/qemu/qemu_driver.c | 22 +++++++++++++++--- src/test/test_driver.c | 22 +++++++++++++++--- src/vz/vz_driver.c | 22 +++++++++++++++++- 8 files changed, 97 insertions(+), 79 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 3bcff88975..e8241f39ff 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -1420,7 +1420,9 @@ bhyveConnectBaselineCPU(virConnectPtr conn, unsigned int ncpus, unsigned int flags) { - char *cpu =3D NULL; + virCPUDefPtr *cpus =3D NULL; + virCPUDefPtr cpu =3D NULL; + char *cpustr =3D NULL; =20 virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES | VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL); @@ -1428,10 +1430,24 @@ bhyveConnectBaselineCPU(virConnectPtr conn, if (virConnectBaselineCPUEnsureACL(conn) < 0) goto cleanup; =20 - cpu =3D cpuBaselineXML(xmlCPUs, ncpus, NULL, 0, flags); + if (!(cpus =3D virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_HOST))) + goto cleanup; + + if (!(cpu =3D cpuBaseline(cpus, ncpus, NULL, 0, + !!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE= )))) + goto cleanup; + + if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) && + virCPUExpandFeatures(cpus[0]->arch, cpu) < 0) + goto cleanup; + + cpustr =3D virCPUDefFormat(cpu, NULL, false); =20 cleanup: - return cpu; + virCPUDefListFree(cpus); + virCPUDefFree(cpu); + + return cpustr; } =20 static int diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index e75f406040..a7c7c381b9 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -495,64 +495,6 @@ virCPUProbeHost(virArch arch) } =20 =20 -/** - * cpuBaselineXML: - * - * @xmlCPUs: list of host CPU XML descriptions - * @ncpus: number of CPUs in @xmlCPUs - * @models: list of CPU models that can be considered for the baseline CPU - * @nmodels: number of CPU models in @models - * @flags: bitwise-OR of virConnectBaselineCPUFlags - * - * Computes the most feature-rich CPU which is compatible with all given - * host CPUs. If @models array is NULL, all models supported by libvirt wi= ll - * be considered when computing the baseline CPU model, otherwise the base= line - * CPU model will be one of the provided CPU @models. - * - * If @flags includes VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES then libvirt - * will explicitly list all CPU features that are part of the host CPU, - * without this flag features that are part of the CPU model will not be - * listed. - * - * Returns XML description of the baseline CPU or NULL on error. - */ -char * -cpuBaselineXML(const char **xmlCPUs, - unsigned int ncpus, - const char **models, - unsigned int nmodels, - unsigned int flags) -{ - virCPUDefPtr *cpus =3D NULL; - virCPUDefPtr cpu =3D NULL; - char *cpustr =3D NULL; - - VIR_DEBUG("ncpus=3D%u, nmodels=3D%u", ncpus, nmodels); - - virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES | - VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL); - - if (!(cpus =3D virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_HOST))) - goto cleanup; - - if (!(cpu =3D cpuBaseline(cpus, ncpus, models, nmodels, - !!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE= )))) - goto cleanup; - - if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) && - virCPUExpandFeatures(cpus[0]->arch, cpu) < 0) - goto cleanup; - - cpustr =3D virCPUDefFormat(cpu, NULL, false); - - cleanup: - virCPUDefListFree(cpus); - virCPUDefFree(cpu); - - return cpustr; -} - - /** * cpuBaseline: * diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index c6ca111e97..5dda46ee70 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -196,13 +196,6 @@ virCPUGetHost(virArch arch, virCPUDefPtr virCPUProbeHost(virArch arch); =20 -char * -cpuBaselineXML(const char **xmlCPUs, - unsigned int ncpus, - const char **models, - unsigned int nmodels, - unsigned int flags); - virCPUDefPtr cpuBaseline (virCPUDefPtr *cpus, unsigned int ncpus, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 857e417f94..888e4e329b 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1077,7 +1077,6 @@ virStoragePoolObjVolumeListExport; =20 # cpu/cpu.h cpuBaseline; -cpuBaselineXML; cpuDecode; cpuEncode; virCPUCheckFeature; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 8fefce6631..4861e5db21 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -6450,7 +6450,9 @@ libxlConnectBaselineCPU(virConnectPtr conn, unsigned int ncpus, unsigned int flags) { - char *cpu =3D NULL; + virCPUDefPtr *cpus =3D NULL; + virCPUDefPtr cpu =3D NULL; + char *cpustr =3D NULL; =20 virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES | VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL); @@ -6458,10 +6460,24 @@ libxlConnectBaselineCPU(virConnectPtr conn, if (virConnectBaselineCPUEnsureACL(conn) < 0) goto cleanup; =20 - cpu =3D cpuBaselineXML(xmlCPUs, ncpus, NULL, 0, flags); + if (!(cpus =3D virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_HOST))) + goto cleanup; + + if (!(cpu =3D cpuBaseline(cpus, ncpus, NULL, 0, + !!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE= )))) + goto cleanup; + + if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) && + virCPUExpandFeatures(cpus[0]->arch, cpu) < 0) + goto cleanup; + + cpustr =3D virCPUDefFormat(cpu, NULL, false); =20 cleanup: - return cpu; + virCPUDefListFree(cpus); + virCPUDefFree(cpu); + + return cpustr; } =20 static virHypervisorDriver libxlHypervisorDriver =3D { diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b334cf20be..e92c114f3e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12989,7 +12989,9 @@ qemuConnectBaselineCPU(virConnectPtr conn ATTRIBUTE= _UNUSED, unsigned int ncpus, unsigned int flags) { - char *cpu =3D NULL; + virCPUDefPtr *cpus =3D NULL; + virCPUDefPtr cpu =3D NULL; + char *cpustr =3D NULL; =20 virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES | VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL); @@ -12997,10 +12999,24 @@ qemuConnectBaselineCPU(virConnectPtr conn ATTRIBU= TE_UNUSED, if (virConnectBaselineCPUEnsureACL(conn) < 0) goto cleanup; =20 - cpu =3D cpuBaselineXML(xmlCPUs, ncpus, NULL, 0, flags); + if (!(cpus =3D virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_HOST))) + goto cleanup; + + if (!(cpu =3D cpuBaseline(cpus, ncpus, NULL, 0, + !!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE= )))) + goto cleanup; + + if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) && + virCPUExpandFeatures(cpus[0]->arch, cpu) < 0) + goto cleanup; + + cpustr =3D virCPUDefFormat(cpu, NULL, false); =20 cleanup: - return cpu; + virCPUDefListFree(cpus); + virCPUDefFree(cpu); + + return cpustr; } =20 =20 diff --git a/src/test/test_driver.c b/src/test/test_driver.c index aa38f54dd9..6e8a4b5782 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1535,13 +1535,29 @@ testConnectBaselineCPU(virConnectPtr conn ATTRIBUTE= _UNUSED, unsigned int ncpus, unsigned int flags) { - char *cpu; + virCPUDefPtr *cpus =3D NULL; + virCPUDefPtr cpu =3D NULL; + char *cpustr =3D NULL; =20 virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES, NULL); =20 - cpu =3D cpuBaselineXML(xmlCPUs, ncpus, NULL, 0, flags); + if (!(cpus =3D virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_HOST))) + goto cleanup; =20 - return cpu; + if (!(cpu =3D cpuBaseline(cpus, ncpus, NULL, 0, false))) + goto cleanup; + + if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) && + virCPUExpandFeatures(cpus[0]->arch, cpu) < 0) + goto cleanup; + + cpustr =3D virCPUDefFormat(cpu, NULL, false); + + cleanup: + virCPUDefListFree(cpus); + virCPUDefFree(cpu); + + return cpustr; } =20 static int testNodeGetInfo(virConnectPtr conn, diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 6f4aee3652..daeed5f114 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -945,12 +945,32 @@ vzConnectBaselineCPU(virConnectPtr conn, unsigned int ncpus, unsigned int flags) { + virCPUDefPtr *cpus =3D NULL; + virCPUDefPtr cpu =3D NULL; + char *cpustr =3D NULL; + virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES, NULL); =20 if (virConnectBaselineCPUEnsureACL(conn) < 0) return NULL; =20 - return cpuBaselineXML(xmlCPUs, ncpus, NULL, 0, flags); + if (!(cpus =3D virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_HOST))) + goto cleanup; + + if (!(cpu =3D cpuBaseline(cpus, ncpus, NULL, 0, false))) + goto cleanup; + + if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) && + virCPUExpandFeatures(cpus[0]->arch, cpu) < 0) + goto cleanup; + + cpustr =3D virCPUDefFormat(cpu, NULL, false); + + cleanup: + virCPUDefListFree(cpus); + virCPUDefFree(cpu); + + return cpustr; } =20 =20 --=20 2.14.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list