From nobody Sun Feb 8 21:49:04 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 1551778867660844.1180126996032; Tue, 5 Mar 2019 01:41:07 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A73DC81F19; Tue, 5 Mar 2019 09:41:04 +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 7DF5051F02; Tue, 5 Mar 2019 09:41:04 +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 3AD6241F3F; Tue, 5 Mar 2019 09:41:04 +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 x259eqTb026284 for ; Tue, 5 Mar 2019 04:40:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id E9A081001DFD; Tue, 5 Mar 2019 09:40:52 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BC3051001DD7 for ; Tue, 5 Mar 2019 09:40:52 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 33D29106FB6; Tue, 5 Mar 2019 10:40:47 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 5 Mar 2019 10:40:26 +0100 Message-Id: <9aa8943b6f557c984b025c7d1b60245ad3910a5f.1551778706.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 v2 10/30] 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-Type: text/plain; charset="utf-8" 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 05 Mar 2019 09:41:05 +0000 (UTC) The code is separated into a new x86ModelParseFeatures function. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- Notes: Version 2: - no change 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 9a7e5e4f63..c54b09396f 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