From nobody Wed Feb 11 10:11: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.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 1489768632795673.7863036630052; Fri, 17 Mar 2017 09:37:12 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E32AAC03BD5F; Fri, 17 Mar 2017 16:37:09 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5DA495DC1D; Fri, 17 Mar 2017 16:37:09 +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 DDCA95EC62; Fri, 17 Mar 2017 16:37:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2HGb01q007120 for ; Fri, 17 Mar 2017 12:37:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id BA3D65DD67; Fri, 17 Mar 2017 16:37:00 +0000 (UTC) Received: from mamuti.net (ovpn-204-109.brq.redhat.com [10.40.204.109]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 375A75DC1D for ; Fri, 17 Mar 2017 16:36:57 +0000 (UTC) Received: by mamuti.net (Postfix, from userid 500) id 296441061C6; Fri, 17 Mar 2017 17:36:55 +0100 (CET) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E32AAC03BD5F Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.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 E32AAC03BD5F From: Jiri Denemark To: libvir-list@redhat.com Date: Fri, 17 Mar 2017 17:36:42 +0100 Message-Id: <1958ededb1725541bef67b2278abc1c0645e4d23.1489768416.git.jdenemar@redhat.com> 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.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 04/14] cpu: Move feature expansion out of cpuBaseline 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 17 Mar 2017 16:37:12 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" cpuBaseline is responsible for computing a baseline CPU while feature expansion is done by virCPUExpandFeatures. The cpuBaselineXML wrapper (used by hypervisor drivers to implement virConnectBaselineCPU API) calls cpuBaseline followed by virCPUExpandFeatures if requested by VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES flag. The features in the three changed test files had to be sorted using "sort -k 3" because virCPUExpandFeatures returns a sorted list of features. Signed-off-by: Jiri Denemark --- src/cpu/cpu.c | 8 +++ src/cpu/cpu_x86.c | 33 ----------- tests/cputest.c | 8 +++ tests/cputestdata/x86_64-baseline-3-expanded.xml | 48 ++++++++-------- tests/cputestdata/x86_64-baseline-4-expanded.xml | 68 +++++++++++---------= --- tests/cputestdata/x86_64-baseline-5-expanded.xml | 70 ++++++++++++--------= ---- 6 files changed, 109 insertions(+), 126 deletions(-) diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index 33581e5fe..d53a7ef2c 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -498,6 +498,10 @@ cpuBaselineXML(const char **xmlCPUs, size_t i; =20 VIR_DEBUG("ncpus=3D%u, nmodels=3D%u", ncpus, nmodels); + + virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES | + VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL); + if (xmlCPUs) { for (i =3D 0; i < ncpus; i++) VIR_DEBUG("xmlCPUs[%zu]=3D%s", i, NULLSTR(xmlCPUs[i])); @@ -538,6 +542,10 @@ cpuBaselineXML(const char **xmlCPUs, if (!(cpu =3D cpuBaseline(cpus, ncpus, models, nmodels, flags))) goto error; =20 + if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) && + virCPUExpandFeatures(cpus[0]->arch, cpu) < 0) + goto error; + cpustr =3D virCPUDefFormat(cpu, NULL, false); =20 cleanup: diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 9c480398f..388102f35 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -967,28 +967,6 @@ x86FeaturesLoad(virCPUx86MapPtr map, return 0; } =20 -static int -x86DataFromCPUFeatures(virCPUx86Data *data, - virCPUDefPtr cpu, - virCPUx86MapPtr map) -{ - size_t i; - - for (i =3D 0; i < cpu->nfeatures; i++) { - virCPUx86FeaturePtr feature; - if (!(feature =3D x86FeatureFind(map, cpu->features[i].name))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown CPU feature %s"), cpu->features[i].n= ame); - return -1; - } - - if (x86DataAdd(data, &feature->data) < 0) - return -1; - } - - return 0; -} - =20 static virCPUx86ModelPtr x86ModelNew(void) @@ -1948,17 +1926,6 @@ x86Decode(virCPUDefPtr cpu, } } =20 - if (flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) { - if (x86DataCopy(©, &model->data) < 0 || - x86DataFromCPUFeatures(&features, cpuModel, map) < 0) - goto cleanup; - - x86DataSubtract(©, &features); - if (x86DataToCPUFeatures(cpuModel, VIR_CPU_FEATURE_REQUIRE, - ©, map) < 0) - goto cleanup; - } - if (vendor && VIR_STRDUP(cpu->vendor, vendor->name) < 0) goto cleanup; =20 diff --git a/tests/cputest.c b/tests/cputest.c index 5e205c501..6396e8670 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -325,6 +325,14 @@ cpuTestBaseline(const void *arg) goto cleanup; =20 baseline =3D cpuBaseline(cpus, ncpus, NULL, 0, data->flags); + + if (baseline && + (data->flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) && + virCPUExpandFeatures(data->arch, baseline) < 0) { + virCPUDefFree(baseline); + baseline =3D NULL; + } + if (data->result < 0) { virResetLastError(); if (!baseline) { diff --git a/tests/cputestdata/x86_64-baseline-3-expanded.xml b/tests/cpute= stdata/x86_64-baseline-3-expanded.xml index f0c2273d8..82857e3d4 100644 --- a/tests/cputestdata/x86_64-baseline-3-expanded.xml +++ b/tests/cputestdata/x86_64-baseline-3-expanded.xml @@ -1,35 +1,35 @@ Westmere - - - - - - - - + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - + - - - + diff --git a/tests/cputestdata/x86_64-baseline-4-expanded.xml b/tests/cpute= stdata/x86_64-baseline-4-expanded.xml index 7e4578e1a..e54eca026 100644 --- a/tests/cputestdata/x86_64-baseline-4-expanded.xml +++ b/tests/cputestdata/x86_64-baseline-4-expanded.xml @@ -1,46 +1,46 @@ Westmere Intel - - - - - - - - - - - - - - - - - - + - - - - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + - - - + + + + + diff --git a/tests/cputestdata/x86_64-baseline-5-expanded.xml b/tests/cpute= stdata/x86_64-baseline-5-expanded.xml index daef2a78f..2c1b40015 100644 --- a/tests/cputestdata/x86_64-baseline-5-expanded.xml +++ b/tests/cputestdata/x86_64-baseline-5-expanded.xml @@ -1,47 +1,47 @@ SandyBridge Intel - - - - - - - - - - - - - - + - - - - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + - - - + + + + + --=20 2.12.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list