From nobody Sun Feb 8 11:59:17 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 1551274279546727.1019482086216; Wed, 27 Feb 2019 05:31:19 -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 73BD830BEF07; Wed, 27 Feb 2019 13:31:17 +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 AE0C05B6A8; Wed, 27 Feb 2019 13:31:15 +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 7085824FC2; Wed, 27 Feb 2019 13:31:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x1RDTZdP004128 for ; Wed, 27 Feb 2019 08:29:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id 55C0819C7A; Wed, 27 Feb 2019 13:29:35 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 284D119C7C for ; Wed, 27 Feb 2019 13:29:24 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 0485B106FB0; Wed, 27 Feb 2019 14:29:19 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Wed, 27 Feb 2019 14:28:56 +0100 Message-Id: <0be6e7cf4861bc2be6d7a15fe86be0c225f04cf2.1551273809.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 06/26] cpu_x86: Separate ancestor model 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.46]); Wed, 27 Feb 2019 13:31:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The code is separated into a new x86ModelParseAncestor function. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_x86.c | 65 +++++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 27 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index d3a88da21d..8a0ff50afe 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -1150,6 +1150,42 @@ x86ModelCompare(virCPUx86ModelPtr model1, } =20 =20 +static int +x86ModelParseAncestor(virCPUx86ModelPtr model, + xmlXPathContextPtr ctxt, + virCPUx86MapPtr map) +{ + VIR_AUTOFREE(char *) name =3D NULL; + virCPUx86ModelPtr ancestor; + int rc; + + if ((rc =3D virXPathBoolean("boolean(./model)", ctxt)) <=3D 0) + return rc; + + name =3D virXPathString("string(./model/@name)", ctxt); + if (!name) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Missing ancestor's name in CPU model %s"), + model->name); + return -1; + } + + if (!(ancestor =3D x86ModelFind(map, name))) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Ancestor model %s not found for CPU model %s"), + name, model->name); + return -1; + } + + model->vendor =3D ancestor->vendor; + model->signature =3D ancestor->signature; + if (x86DataCopy(&model->data, &ancestor->data) < 0) + return -1; + + return 0; +} + + static int x86ModelParse(xmlXPathContextPtr ctxt, const char *name, @@ -1169,33 +1205,8 @@ x86ModelParse(xmlXPathContextPtr ctxt, if (VIR_STRDUP(model->name, name) < 0) goto cleanup; =20 - if (virXPathNode("./model", ctxt)) { - virCPUx86ModelPtr ancestor; - char *anname; - - anname =3D virXPathString("string(./model/@name)", ctxt); - if (!anname) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Missing ancestor's name in CPU model %s"), - model->name); - goto cleanup; - } - - if (!(ancestor =3D x86ModelFind(map, anname))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Ancestor model %s not found for CPU model %s= "), - anname, model->name); - VIR_FREE(anname); - goto cleanup; - } - - VIR_FREE(anname); - - model->vendor =3D ancestor->vendor; - model->signature =3D ancestor->signature; - if (x86DataCopy(&model->data, &ancestor->data) < 0) - goto cleanup; - } + if (x86ModelParseAncestor(model, ctxt, map) < 0) + goto cleanup; =20 if (virXPathBoolean("boolean(./signature)", ctxt)) { unsigned int sigFamily =3D 0; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list