From nobody Mon Feb 9 19:53:04 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1620745535; cv=none; d=zohomail.com; s=zohoarc; b=hHtNIt9+9MvN23XrJYXzoBmwR+XyqVZGHoMBbqidGUQRG2Wa/4PPvPay1LlCjDwvhE34EQgyGmgyUpEsJ0AZUtzhAIUHLTxpo4NDT4vjABEF2HuJNbQN6NyuMIrZK5kFFx+nZmSaPKHo6WiNDxhsnJk5N8JlPASQn1P4NTA0buw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620745535; 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=0oBWNQmHMMI8Hh54p0TvbxZqRnJkTmbquVIIGKogC9k=; b=ESiIj3ao/lI84FngN8ywEkXvHuu7YFcj/PETGG1Sbmn1Oipf5eF3oayv2nfGp6mI80cFrmj0RJeS+uJS9GLIE4i87R48p3Ur5Uv70tpNJeds1ErM5Mo6+47k77q8gX3p0JdmeToG0R6de7ybyjVwoEMJSIqup2fFutS4n/sVx0A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1620745535653420.8945092217799; Tue, 11 May 2021 08:05:35 -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-327-XPRjCd-kPQm_xIS_gkQOxw-1; Tue, 11 May 2021 11:02:14 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id F33F1FC80; Tue, 11 May 2021 15:02:07 +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 C9A2C5D762; Tue, 11 May 2021 15:02:07 +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 4927444A6D; Tue, 11 May 2021 15:02:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14BF24WT005526 for ; Tue, 11 May 2021 11:02:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2050060CDE; Tue, 11 May 2021 15:02:04 +0000 (UTC) Received: from work.redhat.com (ovpn-113-41.ams2.redhat.com [10.36.113.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 628501B427; Tue, 11 May 2021 15:02:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620745337; 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=0oBWNQmHMMI8Hh54p0TvbxZqRnJkTmbquVIIGKogC9k=; b=CwzEJ4MF3LgBfWlufVawnap+b86HArx3zmC0kI5BbKa5crsqIKEmkzJEC8y/FbmzEShOh3 AnBzR9YmqAzPBLJAYCpfSR82EtmtnI63QJZ04WFCmETg31oRgbSdvyWdJknqAVAdDK9San NojBPM5JDNC0dFsJFDj+lIe62qhuT7U= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620745535; 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=0oBWNQmHMMI8Hh54p0TvbxZqRnJkTmbquVIIGKogC9k=; b=RMT87tgQcrXpIJp9+uztrkN54aM4oGsLfEWAi+WNM3Y6quAMkIMiDAxwpddYs15Cm1jI74 klmTglyAF7NbCt4Btx9iedlHP9HUJ2bqQceyjkLPfx7GQDA9QGJQFj6nyTKKctSguaoZBj Tu/RiAjUMxAmfM5hf0lsrKMHHcF7keY= X-MC-Unique: XPRjCd-kPQm_xIS_gkQOxw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 05/10] virDomainNumaDefParseXML: Use virXMLProp* Date: Tue, 11 May 2021 17:01:52 +0200 Message-Id: <20210511150157.26027-6-twiederh@redhat.com> In-Reply-To: <20210511150157.26027-1-twiederh@redhat.com> References: <20210511150157.26027-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.15 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) (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake --- src/conf/numa_conf.c | 128 +++++------------- .../hugepages-memaccess-invalid.err | 2 +- 2 files changed, 35 insertions(+), 95 deletions(-) diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index e631bfa341..27aac87a8d 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -955,26 +955,23 @@ virDomainNumaDefParseXML(virDomainNuma *def, for (i =3D 0; i < n; i++) { VIR_XPATH_NODE_AUTORESTORE(ctxt) int rc; - unsigned int cur_cell =3D i; + unsigned int cur_cell; =20 - /* cells are in order of parsing or explicitly numbered */ - if ((tmp =3D virXMLPropString(nodes[i], "id"))) { - if (virStrToLong_uip(tmp, NULL, 10, &cur_cell) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Invalid 'id' attribute in NUMA cell: '%s= '"), - tmp); - goto cleanup; - } + if ((rc =3D virXMLPropUInt(nodes[i], "id", 10, VIR_XML_PROP_NONE, + &cur_cell)) < 0) + goto cleanup; =20 - if (cur_cell >=3D n) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Exactly one 'cell' element per guest " - "NUMA cell allowed, non-contiguous ranges= or " - "ranges not starting from 0 are not allow= ed")); - goto cleanup; - } + if (rc =3D=3D 0) + cur_cell =3D i; + + /* cells are in order of parsing or explicitly numbered */ + if (cur_cell >=3D n) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Exactly one 'cell' element per guest " + "NUMA cell allowed, non-contiguous ranges or " + "ranges not starting from 0 are not allowed")= ); + goto cleanup; } - VIR_FREE(tmp); =20 if (def->mem_nodes[cur_cell].mem) { virReportError(VIR_ERR_XML_ERROR, @@ -1014,29 +1011,15 @@ virDomainNumaDefParseXML(virDomainNuma *def, &def->mem_nodes[cur_cell].mem, true, fals= e) < 0) goto cleanup; =20 - if ((tmp =3D virXMLPropString(nodes[i], "memAccess"))) { - if ((rc =3D virDomainMemoryAccessTypeFromString(tmp)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Invalid 'memAccess' attribute value '%s'= "), - tmp); - goto cleanup; - } - - def->mem_nodes[cur_cell].memAccess =3D rc; - VIR_FREE(tmp); - } - - if ((tmp =3D virXMLPropString(nodes[i], "discard"))) { - if ((rc =3D virTristateBoolTypeFromString(tmp)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Invalid 'discard' attribute value '%s'"), - tmp); - goto cleanup; - } + if (virXMLPropEnum(nodes[i], "memAccess", + virDomainMemoryAccessTypeFromString, + VIR_XML_PROP_NONZERO, + &def->mem_nodes[cur_cell].memAccess) < 0) + goto cleanup; =20 - def->mem_nodes[cur_cell].discard =3D rc; - VIR_FREE(tmp); - } + if (virXMLPropTristateBool(nodes[i], "discard", VIR_XML_PROP_NONE, + &def->mem_nodes[cur_cell].discard) < 0) + goto cleanup; =20 /* Parse NUMA distances info */ if (virDomainNumaDefNodeDistanceParseXML(def, ctxt, cur_cell) < 0) @@ -1058,24 +1041,15 @@ virDomainNumaDefParseXML(virDomainNuma *def, unsigned int initiator; unsigned int target; unsigned int cache =3D 0; - int accessType; + virDomainMemoryLatency accessType; unsigned long long value; =20 if (virXMLNodeNameEqual(nodes[i], "latency")) { type =3D VIR_DOMAIN_NUMA_INTERCONNECT_TYPE_LATENCY; =20 - if (!(tmp =3D virXMLPropString(nodes[i], "value"))) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Missing 'value' attribute in NUMA interc= onnects")); - goto cleanup; - } - - if (virStrToLong_ullp(tmp, NULL, 10, &value) < 0) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Invalid 'value' attribute in NUMA interc= onnects")); + if (virXMLPropULongLong(nodes[i], "value", 10, + VIR_XML_PROP_REQUIRED, &value) < 0) goto cleanup; - } - VIR_FREE(tmp); } else if (virXMLNodeNameEqual(nodes[i], "bandwidth")) { VIR_XPATH_NODE_AUTORESTORE(ctxt) type =3D VIR_DOMAIN_NUMA_INTERCONNECT_TYPE_BANDWIDTH; @@ -1089,56 +1063,22 @@ virDomainNumaDefParseXML(virDomainNuma *def, continue; } =20 - if (!(tmp =3D virXMLPropString(nodes[i], "initiator"))) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Missing 'initiator' attribute in NUMA interc= onnects")); + if (virXMLPropUInt(nodes[i], "initiator", 10, VIR_XML_PROP_REQUIRE= D, + &initiator) < 0) goto cleanup; - } - - if (virStrToLong_uip(tmp, NULL, 10, &initiator) < 0) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Invalid 'initiator' attribute in NUMA interc= onnects")); - goto cleanup; - } - VIR_FREE(tmp); - - if (!(tmp =3D virXMLPropString(nodes[i], "target"))) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Missing 'target' attribute in NUMA interconn= ects")); - goto cleanup; - } =20 - if (virStrToLong_uip(tmp, NULL, 10, &target) < 0) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Invalid 'target' attribute in NUMA interconn= ects")); + if (virXMLPropUInt(nodes[i], "target", 10, VIR_XML_PROP_REQUIRED, + &target) < 0) goto cleanup; - } - VIR_FREE(tmp); - =20 - /* cache attribute is optional */ - if ((tmp =3D virXMLPropString(nodes[i], "cache"))) { - if (virStrToLong_uip(tmp, NULL, 10, &cache) < 0 || - cache =3D=3D 0) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Invalid 'cache' attribute in NUMA interc= onnects")); - goto cleanup; - } - } - VIR_FREE(tmp); - - if (!(tmp =3D virXMLPropString(nodes[i], "type"))) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Missing 'type' attribute in NUMA interconnec= ts")); + if (virXMLPropUInt(nodes[i], "cache", 10, VIR_XML_PROP_NONE, + &cache) < 0) goto cleanup; - } =20 - if ((accessType =3D virDomainMemoryLatencyTypeFromString(tmp)) <= =3D 0) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Invalid 'type' attribute in NUMA interconnec= ts")); + if (virXMLPropEnum(nodes[i], "type", virDomainMemoryLatencyTypeFro= mString, + VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO, + &accessType) < 0) goto cleanup; - } - VIR_FREE(tmp); =20 def->interconnects[i] =3D (virDomainNumaInterconnect) {type, initi= ator, target, cache, access= Type, value}; diff --git a/tests/qemuxml2argvdata/hugepages-memaccess-invalid.err b/tests= /qemuxml2argvdata/hugepages-memaccess-invalid.err index 75ddd3e282..a1f07fb04d 100644 --- a/tests/qemuxml2argvdata/hugepages-memaccess-invalid.err +++ b/tests/qemuxml2argvdata/hugepages-memaccess-invalid.err @@ -1 +1 @@ -unsupported configuration: Invalid 'memAccess' attribute value 'invalid' +XML error: Invalid value for attribute 'memAccess' in element 'cell': 'inv= alid'. --=20 2.26.3