From nobody Mon Feb 9 08:34:08 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 1551274188834776.4577381429136; Wed, 27 Feb 2019 05:29:48 -0800 (PST) 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 7D6ADA3993; Wed, 27 Feb 2019 13:29:46 +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 53BC75DD84; Wed, 27 Feb 2019 13:29:46 +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 0BD3B3FA4B; Wed, 27 Feb 2019 13:29:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x1RDTTtL004036 for ; Wed, 27 Feb 2019 08:29:29 -0500 Received: by smtp.corp.redhat.com (Postfix) id 75E8161371; Wed, 27 Feb 2019 13:29:29 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 46E7A6136A for ; Wed, 27 Feb 2019 13:29:25 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 08E5F106FB4; Wed, 27 Feb 2019 14:29:19 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Wed, 27 Feb 2019 14:28:58 +0100 Message-Id: <4ba68f4791d52dcd12ac83c08780c519f857c174.1551273809.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 08/26] cpu_x86: Separate vendor 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 27 Feb 2019 13:29:47 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The code is separated into a new x86ModelParseVendor function. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_x86.c | 50 ++++++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 163fcbf5ac..fcbc105218 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -1219,6 +1219,36 @@ x86ModelParseSignature(virCPUx86ModelPtr model, } =20 =20 +static int +x86ModelParseVendor(virCPUx86ModelPtr model, + xmlXPathContextPtr ctxt, + virCPUx86MapPtr map) +{ + VIR_AUTOFREE(char *) vendor =3D NULL; + int rc; + + if ((rc =3D virXPathBoolean("boolean(./vendor)", ctxt)) <=3D 0) + return rc; + + vendor =3D virXPathString("string(./vendor/@name)", ctxt); + if (!vendor) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid vendor element in CPU model %s"), + model->name); + return -1; + } + + if (!(model->vendor =3D x86VendorFind(map, vendor))) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown vendor %s referenced by CPU model %s"), + vendor, model->name); + return -1; + } + + return 0; +} + + static int x86ModelParse(xmlXPathContextPtr ctxt, const char *name, @@ -1227,7 +1257,6 @@ x86ModelParse(xmlXPathContextPtr ctxt, virCPUx86MapPtr map =3D data; xmlNodePtr *nodes =3D NULL; virCPUx86ModelPtr model; - char *vendor =3D NULL; size_t i; int n; int ret =3D -1; @@ -1244,22 +1273,8 @@ x86ModelParse(xmlXPathContextPtr ctxt, if (x86ModelParseSignature(model, ctxt) < 0) goto cleanup; =20 - if (virXPathBoolean("boolean(./vendor)", ctxt)) { - vendor =3D virXPathString("string(./vendor/@name)", ctxt); - if (!vendor) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid vendor element in CPU model %s"), - model->name); - goto cleanup; - } - - if (!(model->vendor =3D x86VendorFind(map, vendor))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown vendor %s referenced by CPU model %s= "), - vendor, model->name); - goto cleanup; - } - } + if (x86ModelParseVendor(model, ctxt, map) < 0) + goto cleanup; =20 n =3D virXPathNodeSet("./feature", ctxt, &nodes); if (n < 0) @@ -1295,7 +1310,6 @@ x86ModelParse(xmlXPathContextPtr ctxt, =20 cleanup: x86ModelFree(model); - VIR_FREE(vendor); VIR_FREE(nodes); return ret; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list