From nobody Mon Feb 9 17:34:37 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=1620919950; cv=none; d=zohomail.com; s=zohoarc; b=JpfeisSW28r8xLpgzaKWrleULU/6GYAmQ6QO98myJVMKhvbXGEtu5mZpCMYWq8uBwLdmHeP8aXpgnMtA7YhrFsX8zpfovZImcLoykC7c52l+ko3KmSK5uATJXMPlRhOT0bmvyjUa6IiYLV29sp+EdF8/AyWetlAEn8QGxRfU+gc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620919950; 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=fdrmSH4rX9NW6v0wCC/nk/I5PEfQz4L9eWYAIeQP9+s=; b=fU4oemJMFAc+nlqAsiJWFGzOmNPJJ+dYiLKZFqSoCmOnEgcDsVAy5sO2TXyVms363D/PvapbMGzU7Lj6EKHJZ9aPLTeWH+qriQIEBl7fvtA3h+OB7s42nSYAEeZcrQtkFiWCVsvTCwpx3UfPwV61TtR5C30ZiRRcyuNc2G435+Y= 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 1620919950753707.7457608513563; Thu, 13 May 2021 08:32:30 -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-479-beFKhMVxNRuj2sK-4KeIgg-1; Thu, 13 May 2021 11:32:26 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B428C101371F; Thu, 13 May 2021 15:32:20 +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 96AD319C95; Thu, 13 May 2021 15:32:20 +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 5CD6A55344; Thu, 13 May 2021 15:32:20 +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 14DFWHaZ026231 for ; Thu, 13 May 2021 11:32:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3882C189A5; Thu, 13 May 2021 15:32:17 +0000 (UTC) Received: from work.redhat.com (ovpn-112-97.ams2.redhat.com [10.36.112.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 81EB718B42; Thu, 13 May 2021 15:32:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620919948; 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=fdrmSH4rX9NW6v0wCC/nk/I5PEfQz4L9eWYAIeQP9+s=; b=FEelG9ViCrncPhrBfKTFZeyyGMpLfRc+AuQBqT0klVktIHG01NqTnqVDrPR1lbG91eGYJO +JCCn7OUKQkpwLdQ/JV9tdUQiZo8/7Bpw4d56ElMpSgsI4Zqo9BA5dwUWbX+xq1Itga3DX vXHI6Q50KmnTAfNjv8hdtWCYsx4D+i4= X-MC-Unique: beFKhMVxNRuj2sK-4KeIgg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 6/6] virDomainNumaDefParseXML: Use g_autofree Date: Thu, 13 May 2021 17:32:01 +0200 Message-Id: <20210513153201.20407-7-twiederh@redhat.com> In-Reply-To: <20210513153201.20407-1-twiederh@redhat.com> References: <20210513153201.20407-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.11 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) Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake --- src/conf/numa_conf.c | 84 +++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 44 deletions(-) diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index 9fe4998951..525bc28962 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -932,20 +932,20 @@ int virDomainNumaDefParseXML(virDomainNuma *def, xmlXPathContextPtr ctxt) { - xmlNodePtr *nodes =3D NULL; - char *tmp =3D NULL; + g_autofree xmlNodePtr *cell =3D NULL; + g_autofree xmlNodePtr *interconnect =3D NULL; + int n; size_t i, j; - int ret =3D -1; =20 /* check if NUMA definition is present */ if (!virXPathNode("./cpu/numa[1]", ctxt)) return 0; =20 - if ((n =3D virXPathNodeSet("./cpu/numa[1]/cell", ctxt, &nodes)) <=3D 0= ) { + if ((n =3D virXPathNodeSet("./cpu/numa[1]/cell", ctxt, &cell)) <=3D 0)= { virReportError(VIR_ERR_XML_ERROR, "%s", _("NUMA topology defined without NUMA cells")); - goto cleanup; + return -1; } =20 def->mem_nodes =3D g_new0(struct _virDomainNumaNode, n); @@ -953,12 +953,13 @@ virDomainNumaDefParseXML(virDomainNuma *def, =20 for (i =3D 0; i < n; i++) { VIR_XPATH_NODE_AUTORESTORE(ctxt) + g_autofree char *tmp =3D NULL; int rc; unsigned int cur_cell; =20 - if ((rc =3D virXMLPropUInt(nodes[i], "id", 10, VIR_XML_PROP_NONE, + if ((rc =3D virXMLPropUInt(cell[i], "id", 10, VIR_XML_PROP_NONE, &cur_cell)) < 0) - goto cleanup; + return -1; =20 if (rc =3D=3D 0) cur_cell =3D i; @@ -969,25 +970,24 @@ virDomainNumaDefParseXML(virDomainNuma *def, _("Exactly one 'cell' element per guest " "NUMA cell allowed, non-contiguous ranges or " "ranges not starting from 0 are not allowed")= ); - goto cleanup; + return -1; } =20 if (def->mem_nodes[cur_cell].mem) { virReportError(VIR_ERR_XML_ERROR, _("Duplicate NUMA cell info for cell id '%u'"), cur_cell); - goto cleanup; + return -1; } =20 - if ((tmp =3D virXMLPropString(nodes[i], "cpus"))) { + if ((tmp =3D virXMLPropString(cell[i], "cpus"))) { g_autoptr(virBitmap) cpumask =3D NULL; =20 if (virBitmapParse(tmp, &cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0) - goto cleanup; + return -1; =20 if (!virBitmapIsAllClear(cpumask)) def->mem_nodes[cur_cell].cpumask =3D g_steal_pointer(&cpum= ask); - VIR_FREE(tmp); } =20 for (j =3D 0; j < n; j++) { @@ -1001,38 +1001,38 @@ virDomainNumaDefParseXML(virDomainNuma *def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("NUMA cells %u and %zu have overlapping v= CPU ids"), cur_cell, j); - goto cleanup; + return -1; } } =20 - ctxt->node =3D nodes[i]; + ctxt->node =3D cell[i]; if (virDomainParseMemory("./@memory", "./@unit", ctxt, &def->mem_nodes[cur_cell].mem, true, fals= e) < 0) - goto cleanup; + return -1; =20 - if (virXMLPropEnum(nodes[i], "memAccess", + if (virXMLPropEnum(cell[i], "memAccess", virDomainMemoryAccessTypeFromString, VIR_XML_PROP_NONZERO, &def->mem_nodes[cur_cell].memAccess) < 0) - goto cleanup; + return -1; =20 - if (virXMLPropTristateBool(nodes[i], "discard", VIR_XML_PROP_NONE, + if (virXMLPropTristateBool(cell[i], "discard", VIR_XML_PROP_NONE, &def->mem_nodes[cur_cell].discard) < 0) - goto cleanup; + return -1; =20 /* Parse NUMA distances info */ if (virDomainNumaDefNodeDistanceParseXML(def, ctxt, cur_cell) < 0) - goto cleanup; + return -1; =20 /* Parse cache info */ if (virDomainNumaDefNodeCacheParseXML(def, ctxt, cur_cell) < 0) - goto cleanup; + return -1; } =20 - VIR_FREE(nodes); if ((n =3D virXPathNodeSet("./cpu/numa[1]/interconnects[1]/latency|" - "./cpu/numa[1]/interconnects[1]/bandwidth", c= txt, &nodes)) < 0) - goto cleanup; + "./cpu/numa[1]/interconnects[1]/bandwidth", c= txt, + &interconnect)) < 0) + return -1; =20 def->interconnects =3D g_new0(virDomainNumaInterconnect, n); for (i =3D 0; i < n; i++) { @@ -1043,53 +1043,49 @@ virDomainNumaDefParseXML(virDomainNuma *def, virDomainMemoryLatency accessType; unsigned long long value; =20 - if (virXMLNodeNameEqual(nodes[i], "latency")) { + if (virXMLNodeNameEqual(interconnect[i], "latency")) { type =3D VIR_DOMAIN_NUMA_INTERCONNECT_TYPE_LATENCY; =20 - if (virXMLPropULongLong(nodes[i], "value", 10, + if (virXMLPropULongLong(interconnect[i], "value", 10, VIR_XML_PROP_REQUIRED, &value) < 0) - goto cleanup; - } else if (virXMLNodeNameEqual(nodes[i], "bandwidth")) { + return -1; + } else if (virXMLNodeNameEqual(interconnect[i], "bandwidth")) { VIR_XPATH_NODE_AUTORESTORE(ctxt) type =3D VIR_DOMAIN_NUMA_INTERCONNECT_TYPE_BANDWIDTH; =20 - ctxt->node =3D nodes[i]; + ctxt->node =3D interconnect[i]; =20 if (virDomainParseMemory("./@value", "./@unit", ctxt, &value, = true, false) < 0) - goto cleanup; + return -1; } else { /* Ignore yet unknown child elements. */ continue; } =20 - if (virXMLPropUInt(nodes[i], "initiator", 10, VIR_XML_PROP_REQUIRE= D, + if (virXMLPropUInt(interconnect[i], "initiator", 10, VIR_XML_PROP_= REQUIRED, &initiator) < 0) - goto cleanup; + return -1; =20 - if (virXMLPropUInt(nodes[i], "target", 10, VIR_XML_PROP_REQUIRED, + if (virXMLPropUInt(interconnect[i], "target", 10, VIR_XML_PROP_REQ= UIRED, &target) < 0) - goto cleanup; + return -1; =20 - if (virXMLPropUInt(nodes[i], "cache", 10, VIR_XML_PROP_NONE, + if (virXMLPropUInt(interconnect[i], "cache", 10, VIR_XML_PROP_NONE, &cache) < 0) - goto cleanup; + return -1; =20 - if (virXMLPropEnum(nodes[i], "type", virDomainMemoryLatencyTypeFro= mString, + if (virXMLPropEnum(interconnect[i], "type", + virDomainMemoryLatencyTypeFromString, VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO, &accessType) < 0) - goto cleanup; + return -1; =20 def->interconnects[i] =3D (virDomainNumaInterconnect) {type, initi= ator, target, cache, access= Type, value}; def->ninterconnects++; } =20 - ret =3D 0; - - cleanup: - VIR_FREE(nodes); - VIR_FREE(tmp); - return ret; + return 0; } =20 =20 --=20 2.26.3