From nobody Mon Feb 9 21:37:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636043271; cv=none; d=zohomail.com; s=zohoarc; b=e4yC3yawOVxnK1Rab7ZteIWEEDvejLF8tiHwoJIbQpP3zZ5iMwFv7tTCn/q5qmwyMc9nb/Xls83aof5VrOt6hpW0LQQMN/z0WO/A+fxmZxb10GDCbP7S9vJJd9nMDoRDcgrmt01g9OLPHlCSjT1az7cTHWbqFQe+XnizOHF9TcY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636043271; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qATWJ9GE8x+asjWlfESBNuxr3YoEUjHXFsLSD5OUr7I=; b=WdaiBQuMgiML0Aj7t/ixN2M3gAqIwxvQUx0zwyweZonZCu/1EC/aN41ux7YC7KIKHimWc77VyImZBwJbLcupwtzzDayD++HeY3nVhnozc+RR9hMjh0Pjhrm+uz+4VKor1IGWnMNU9hKpIIVxGJEKr7h6/WHoQnAeq8HEiDi2eRM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1636043271540871.8031992343552; Thu, 4 Nov 2021 09:27:51 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-508-T1blv1QpOQyZ80zopwEh8g-1; Thu, 04 Nov 2021 12:27:48 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 826DA1023F59; Thu, 4 Nov 2021 16:27:43 +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 576F77086C; Thu, 4 Nov 2021 16:27:43 +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 1DA124EA2A; Thu, 4 Nov 2021 16:27:43 +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 1A4GRMD1026329 for ; Thu, 4 Nov 2021 12:27:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id B35AA19723; Thu, 4 Nov 2021 16:27:22 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A02219C79; Thu, 4 Nov 2021 16:27:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636043270; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=qATWJ9GE8x+asjWlfESBNuxr3YoEUjHXFsLSD5OUr7I=; b=HLTZQyWcGi6ELxqiQNXNfS1alHvNbtmtpKBRGOX07GNxSB7jA1Pb+qTlPTfX43OJYoGgKI wtLqbNh7idnAM4X477mnfXqXPcB8M6jCRceew+6Lxeh6+eIudnV+N5D6vcrbfny7K0zTjh jOL3EmNpJvK+vTiCtr27L/DAInGANgc= X-MC-Unique: T1blv1QpOQyZ80zopwEh8g-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 01/20] cpu_x86: Simplify x86ParseCPUID Date: Thu, 4 Nov 2021 17:27:01 +0100 Message-Id: <20211104162720.108973-2-twiederh@redhat.com> In-Reply-To: <20211104162720.108973-1-twiederh@redhat.com> References: <20211104162720.108973-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636043275299100001 Content-Type: text/plain; charset="utf-8" ... by using virXMLProp*() helpers. These only require a xmlNodePtr and do not need a xmlXPathContextPtr. Reflect that in the function signature. Signed-off-by: Tim Wiederhake --- src/cpu/cpu_x86.c | 43 +++++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 1b829e5658..b0f6fa8f34 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -1021,37 +1021,28 @@ x86FeatureNames(virCPUx86Map *map, =20 =20 static int -x86ParseCPUID(xmlXPathContextPtr ctxt, +x86ParseCPUID(xmlNodePtr node, virCPUx86DataItem *item) { - virCPUx86CPUID *cpuid; - unsigned long eax_in, ecx_in; - unsigned long eax, ebx, ecx, edx; - int ret_eax_in, ret_ecx_in, ret_eax, ret_ebx, ret_ecx, ret_edx; - - memset(item, 0, sizeof(*item)); + virCPUx86CPUID cpuid; =20 - eax_in =3D ecx_in =3D 0; - eax =3D ebx =3D ecx =3D edx =3D 0; - ret_eax_in =3D virXPathULongHex("string(@eax_in)", ctxt, &eax_in); - ret_ecx_in =3D virXPathULongHex("string(@ecx_in)", ctxt, &ecx_in); - ret_eax =3D virXPathULongHex("string(@eax)", ctxt, &eax); - ret_ebx =3D virXPathULongHex("string(@ebx)", ctxt, &ebx); - ret_ecx =3D virXPathULongHex("string(@ecx)", ctxt, &ecx); - ret_edx =3D virXPathULongHex("string(@edx)", ctxt, &edx); + memset(&cpuid, 0, sizeof(cpuid)); =20 - if (ret_eax_in < 0 || ret_ecx_in =3D=3D -2 || - ret_eax =3D=3D -2 || ret_ebx =3D=3D -2 || ret_ecx =3D=3D -2 || ret= _edx =3D=3D -2) + if (virXMLPropUInt(node, "eax_in", 0, VIR_XML_PROP_REQUIRED, &cpuid.ea= x_in) < 0) + return -1; + if (virXMLPropUInt(node, "ecx_in", 0, VIR_XML_PROP_NONE, &cpuid.ecx_in= ) < 0) + return -1; + if (virXMLPropUInt(node, "eax", 0, VIR_XML_PROP_NONE, &cpuid.eax) < 0) + return -1; + if (virXMLPropUInt(node, "ebx", 0, VIR_XML_PROP_NONE, &cpuid.ebx) < 0) + return -1; + if (virXMLPropUInt(node, "ecx", 0, VIR_XML_PROP_NONE, &cpuid.ecx) < 0) + return -1; + if (virXMLPropUInt(node, "edx", 0, VIR_XML_PROP_NONE, &cpuid.edx) < 0) return -1; =20 item->type =3D VIR_CPU_X86_DATA_CPUID; - cpuid =3D &item->data.cpuid; - cpuid->eax_in =3D eax_in; - cpuid->ecx_in =3D ecx_in; - cpuid->eax =3D eax; - cpuid->ebx =3D ebx; - cpuid->ecx =3D ecx; - cpuid->edx =3D edx; + item->data.cpuid =3D cpuid; return 0; } =20 @@ -1122,7 +1113,7 @@ x86FeatureParse(xmlXPathContextPtr ctxt, for (i =3D 0; i < n; i++) { ctxt->node =3D nodes[i]; if (virXMLNodeNameEqual(nodes[i], "cpuid")) { - if (x86ParseCPUID(ctxt, &item) < 0) { + if (x86ParseCPUID(ctxt->node, &item) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid cpuid[%zu] in %s feature"), i, feature->name); @@ -1812,7 +1803,7 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt) for (i =3D 0; i < n; i++) { ctxt->node =3D nodes[i]; if (virXMLNodeNameEqual(nodes[i], "cpuid")) { - if (x86ParseCPUID(ctxt, &item) < 0) { + if (x86ParseCPUID(ctxt->node, &item) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse cpuid[%zu]"), i); return NULL; --=20 2.31.1