From nobody Fri Dec 19 20:22:45 2025 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=1684226027; cv=none; d=zohomail.com; s=zohoarc; b=Qhm1m8t7x9KpTT/8V587Qi0t+wRZHzL/Oe7tQvFiLtKMWq22n9TTYhbhTjRWcTU+ri78UbiehREFHoDJBnoog6feRLuC4vCkDq6gjA+KJXu95mXkIYFKCV7kSAnBKQ98sm6PbvcUhUt0pb3pN8YyU/AGAROZhQud6hLD/R3YHAc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684226027; h=Content-Type:Content-Transfer-Encoding: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=GT1a3qw/rBIjPcDmRiSEBgo2C07gdyGw9ipglNCRf3o=; b=g35LoVPRHCbEhq62htZOaJ5CTzGoq+QYLQ4BR7+SbTaYSaJAf+Ml8Q8pgOJ8vF8HyMLvsZS7iN2AxkFm46iHjShzRXFFozT7w517BAgMQMPXsGlDn/tslHUN1WIVPvaks8KvUNvSm9J9BgjP+Bmx9pdbVK0ggt3/YhAFJfbrD5Q= 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 1684226027453193.15018141132362; Tue, 16 May 2023 01:33:47 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-196-zYdOpsh5MkSsCvWcUvfLjA-1; Tue, 16 May 2023 04:33:41 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 78D0A86C60A; Tue, 16 May 2023 08:33:39 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6504E40C6EC4; Tue, 16 May 2023 08:33:39 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3D5E31946595; Tue, 16 May 2023 08:33:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2836D19465BB for ; Tue, 16 May 2023 08:33:23 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1AD324078906; Tue, 16 May 2023 08:33:23 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9617040C6EC4 for ; Tue, 16 May 2023 08:33:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684226026; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=GT1a3qw/rBIjPcDmRiSEBgo2C07gdyGw9ipglNCRf3o=; b=Z4A11rueo0z6n5XUEvd5rsMXfBxjnDMrRkSlrlhlroor+zMv6LIgq1EMN8SA6drv7/EaQt D4Mb1JIWWP30+cNyf/wIWAETBIL6yh1tRKpW8O9w2Du7QIIyWLg+4hrDV2NnWiRZEfefhq JWPiCfowrY7Qj5W5s4HskjrrfD92hJk= X-MC-Unique: zYdOpsh5MkSsCvWcUvfLjA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/2] virDomainNumaDefNodeCacheParseXML: Refactor parsing of cache XML Date: Tue, 16 May 2023 10:33:19 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1684226028635100001 Content-Type: text/plain; charset="utf-8" Use virXMLProp* helpers to simplify the code. Signed-off-by: Peter Krempa --- src/conf/numa_conf.c | 60 +++++++++++--------------------------------- 1 file changed, 14 insertions(+), 46 deletions(-) diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index b21671f587..c2e3045280 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -815,68 +815,36 @@ virDomainNumaDefNodeCacheParseXML(virDomainNuma *def, for (i =3D 0; i < n; i++) { VIR_XPATH_NODE_AUTORESTORE(ctxt) virNumaCache *cache =3D &def->mem_nodes[cur_cell].caches[i]; - g_autofree char *tmp =3D NULL; - unsigned int level; - int associativity; - int policy; - unsigned long long size; unsigned long long line; - if (!(tmp =3D virXMLPropString(nodes[i], "level"))) { - virReportError(VIR_ERR_XML_ERROR, - _("Missing 'level' attribute in cache element f= or NUMA node %1$d"), - cur_cell); - return -1; - } - - if (virStrToLong_uip(tmp, NULL, 10, &level) < 0 || - level =3D=3D 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Invalid 'level' attribute in cache element f= or NUMA node %1$d"), - cur_cell); - return -1; - } - VIR_FREE(tmp); - - if (!(tmp =3D virXMLPropString(nodes[i], "associativity"))) { - virReportError(VIR_ERR_XML_ERROR, - _("Missing 'associativity' attribute in cache e= lement for NUMA node %1$d"), - cur_cell); + if (virXMLPropUInt(nodes[i], "level", 10, + VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO, + &cache->level) < 0) return -1; - } - if ((associativity =3D virNumaCacheAssociativityTypeFromString(tmp= )) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Invalid cache associativity '%1$s'"), - tmp); + if (virXMLPropEnum(nodes[i], "associativity", + virNumaCacheAssociativityTypeFromString, + VIR_XML_PROP_REQUIRED, + &cache->associativity) < 0) return -1; - } - VIR_FREE(tmp); - - if (!(tmp =3D virXMLPropString(nodes[i], "policy"))) { - virReportError(VIR_ERR_XML_ERROR, - _("Missing 'policy' attribute in cache element = for NUMA node %1$d"), - cur_cell); - } - if ((policy =3D virNumaCachePolicyTypeFromString(tmp)) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Invalid cache policy '%1$s'"), - tmp); + if (virXMLPropEnum(nodes[i], "policy", + virNumaCachePolicyTypeFromString, + VIR_XML_PROP_REQUIRED, + &cache->policy) < 0) return -1; - } - VIR_FREE(tmp); ctxt->node =3D nodes[i]; if (virDomainParseMemory("./size/@value", "./size/unit", - ctxt, &size, true, false) < 0) + ctxt, &cache->size, true, false) < 0) return -1; if (virParseScaledValue("./line/@value", "./line/unit", ctxt, &line, 1, ULLONG_MAX, true) < 0) return -1; - *cache =3D (virNumaCache){level, size, line, associativity, policy= }; + cache->line =3D line; + def->mem_nodes[cur_cell].ncaches++; } --=20 2.40.1