From nobody Sun Feb 8 19:24:30 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 1551778968268253.8526933578546; Tue, 5 Mar 2019 01:42:48 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 206D0307EAA2; Tue, 5 Mar 2019 09:42:46 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E86C5226EE; Tue, 5 Mar 2019 09:42: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 9D4D2181A136; Tue, 5 Mar 2019 09:42:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x259espN026343 for ; Tue, 5 Mar 2019 04:40:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id BBA1C61B68; Tue, 5 Mar 2019 09:40:54 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8FC7F61D07 for ; Tue, 5 Mar 2019 09:40:52 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 2CEC6106FB3; Tue, 5 Mar 2019 10:40:47 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 5 Mar 2019 10:40:23 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 07/30] 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-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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Tue, 05 Mar 2019 09:42:47 +0000 (UTC) The code is separated into a new x86ModelParseAncestor function. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- Notes: Version 2: - no change 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