From nobody Sun Feb 8 11:59:26 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 1551274174842649.0010497025262; Wed, 27 Feb 2019 05:29:34 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C61DE309D044; Wed, 27 Feb 2019 13:29:32 +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 928825D707; Wed, 27 Feb 2019 13:29:32 +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 477FB3FB11; Wed, 27 Feb 2019 13:29:32 +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 x1RDTRYO003997 for ; Wed, 27 Feb 2019 08:29:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id 07FB51001F5E; Wed, 27 Feb 2019 13:29:27 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CCF681001DED for ; Wed, 27 Feb 2019 13:29:26 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 0AE71106FB5; Wed, 27 Feb 2019 14:29:19 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Wed, 27 Feb 2019 14:28:59 +0100 Message-Id: <629dd63bef4b07f2e38619ca09a95e5a7f95c9f9.1551273809.git.jdenemar@redhat.com> 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 09/26] cpu_x86: Separate feature list parsing from x86ModelParse 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Wed, 27 Feb 2019 13:29:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The code is separated into a new x86ModelParseFeatures function. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_x86.c | 68 +++++++++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index fcbc105218..82f7bcbb45 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -1249,16 +1249,51 @@ x86ModelParseVendor(virCPUx86ModelPtr model, } =20 =20 +static int +x86ModelParseFeatures(virCPUx86ModelPtr model, + xmlXPathContextPtr ctxt, + virCPUx86MapPtr map) +{ + VIR_AUTOFREE(xmlNodePtr *) nodes =3D NULL; + size_t i; + int n; + + if ((n =3D virXPathNodeSet("./feature", ctxt, &nodes)) <=3D 0) + return n; + + for (i =3D 0; i < n; i++) { + VIR_AUTOFREE(char *) ftname =3D NULL; + virCPUx86FeaturePtr feature; + + if (!(ftname =3D virXMLPropString(nodes[i], "name"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Missing feature name for CPU model %s"), + model->name); + return -1; + } + + if (!(feature =3D x86FeatureFind(map, ftname))) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Feature %s required by CPU model %s not foun= d"), + ftname, model->name); + return -1; + } + + if (x86DataAdd(&model->data, &feature->data)) + return -1; + } + + return 0; +} + + static int x86ModelParse(xmlXPathContextPtr ctxt, const char *name, void *data) { virCPUx86MapPtr map =3D data; - xmlNodePtr *nodes =3D NULL; virCPUx86ModelPtr model; - size_t i; - int n; int ret =3D -1; =20 if (!(model =3D x86ModelNew())) @@ -1276,33 +1311,9 @@ x86ModelParse(xmlXPathContextPtr ctxt, if (x86ModelParseVendor(model, ctxt, map) < 0) goto cleanup; =20 - n =3D virXPathNodeSet("./feature", ctxt, &nodes); - if (n < 0) + if (x86ModelParseFeatures(model, ctxt, map) < 0) goto cleanup; =20 - for (i =3D 0; i < n; i++) { - virCPUx86FeaturePtr feature; - char *ftname; - - if (!(ftname =3D virXMLPropString(nodes[i], "name"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Missing feature name for CPU model %s"), mod= el->name); - goto cleanup; - } - - if (!(feature =3D x86FeatureFind(map, ftname))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Feature %s required by CPU model %s not foun= d"), - ftname, model->name); - VIR_FREE(ftname); - goto cleanup; - } - VIR_FREE(ftname); - - if (x86DataAdd(&model->data, &feature->data)) - goto cleanup; - } - if (VIR_APPEND_ELEMENT(map->models, map->nmodels, model) < 0) goto cleanup; =20 @@ -1310,7 +1321,6 @@ x86ModelParse(xmlXPathContextPtr ctxt, =20 cleanup: x86ModelFree(model); - VIR_FREE(nodes); return ret; } =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list