From nobody Tue May 14 08:42:02 2024 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=1620919958; cv=none; d=zohomail.com; s=zohoarc; b=dhBDyuXuKOel9YB8WDbu20IpMiPkymexc746VvgGxWaOfpjwv8snA6EeHJiUuWM56OgUMs4Iyp/9jdmFRTnWXAVGX7qzTdSyvXrGqB/psrfP1v4HmPxIkSo5MybvKP88bIqeEZzWGyxe7lJPqg0R776rFgztMjjakFqdu9Ifivo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620919958; 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=nQm32h8AjrI5rFfqvkHJ5w7KjBDswbIWMhrRMZ0kO0I=; b=XanpUdeXybxiYA4neFRUq+kXUED/xkLPKNajWseovsYiEOsksH2XURs1VC0oCJMcYbB+apxBsmsaqlASSg7+5HhFmBCxZBbFjHCH+/5IxdCVrmZIzh6eSMXxwswDGWelCHG7x7LpjjZjqbSRKyIKoFVrlhGdqhsIAGrr5jNWa5g= 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) header.from= 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 1620919958532378.6196933194783; Thu, 13 May 2021 08:32:38 -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-582-_3YhjwKIOhmFx2E5Z7j1Ew-1; Thu, 13 May 2021 11:32:34 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D505C107ACE3; Thu, 13 May 2021 15:32:29 +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 B458060CC6; Thu, 13 May 2021 15:32:29 +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 7541B55349; Thu, 13 May 2021 15:32:29 +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 14DFWC67026177 for ; Thu, 13 May 2021 11:32:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 02F2D18B42; Thu, 13 May 2021 15:32:12 +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 4AC36189C4; Thu, 13 May 2021 15:32:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620919956; 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=nQm32h8AjrI5rFfqvkHJ5w7KjBDswbIWMhrRMZ0kO0I=; b=JC6KbMf+n7otw0bUHCV5U4jiNpGv/kwmwvXvPPK99WwtgtkWl1hnR0mJZpmBRxItLz3sK4 OnnAKkuAx8w+n3nz/DMrH29clNOXENtoIzG460j2s/Z9IplwPyWkAXqqB7dkpNCxrzhkEh tpTO87KnTqvuL00L/JZISmCIP0PDGD4= X-MC-Unique: _3YhjwKIOhmFx2E5Z7j1Ew-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 1/6] virNodeDeviceDefParseXML: Use g_auto* Date: Thu, 13 May 2021 17:31:56 +0200 Message-Id: <20210513153201.20407-2-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.12 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 Reviewed-by: Laine Stump --- src/conf/node_device_conf.c | 44 +++++++++++++++---------------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 4477a8d9d2..861f43f6c4 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -2059,21 +2059,20 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, int create, const char *virt_type) { - virNodeDeviceDef *def; + g_autoptr(virNodeDeviceDef) def =3D g_new0(virNodeDeviceDef, 1); virNodeDevCapsDef **next_cap; - xmlNodePtr *nodes =3D NULL; + g_autofree xmlNodePtr *devnode =3D NULL; + g_autofree xmlNodePtr *capability =3D NULL; int n, m; size_t i; =20 - def =3D g_new0(virNodeDeviceDef, 1); - /* Extract device name */ if (create =3D=3D EXISTING_DEVICE) { def->name =3D virXPathString("string(./name[1])", ctxt); =20 if (!def->name) { virReportError(VIR_ERR_NO_NAME, NULL); - goto error; + return NULL; } } else { def->name =3D g_strdup("new device"); @@ -2082,27 +2081,27 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, def->sysfs_path =3D virXPathString("string(./path[1])", ctxt); =20 /* Parse devnodes */ - if ((n =3D virXPathNodeSet("./devnode", ctxt, &nodes)) < 0) - goto error; + if ((n =3D virXPathNodeSet("./devnode", ctxt, &devnode)) < 0) + return NULL; =20 def->devlinks =3D g_new0(char *, n + 1); =20 for (i =3D 0, m =3D 0; i < n; i++) { - xmlNodePtr node =3D nodes[i]; + xmlNodePtr node =3D devnode[i]; virNodeDevDevnodeType val; =20 if (virXMLPropEnum(node, "type", virNodeDevDevnodeTypeFromString, VIR_XML_PROP_REQUIRED, &val) < 0) - goto error; + return NULL; =20 switch (val) { case VIR_NODE_DEV_DEVNODE_DEV: if (!(def->devnode =3D virXMLNodeContentString(node))) - goto error; + return NULL; break; case VIR_NODE_DEV_DEVNODE_LINK: if (!(def->devlinks[m++] =3D virXMLNodeContentString(node))) - goto error; + return NULL; break; case VIR_NODE_DEV_DEVNODE_LAST: break; @@ -2118,7 +2117,7 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, _("when providing parent wwnn=3D'%s', the " "wwpn must also be provided"), def->parent_wwnn); - goto error; + return NULL; } =20 if (!def->parent_wwnn && def->parent_wwpn) { @@ -2126,42 +2125,35 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, _("when providing parent wwpn=3D'%s', the " "wwnn must also be provided"), def->parent_wwpn); - goto error; + return NULL; } def->parent_fabric_wwn =3D virXPathString("string(./parent[1]/@fabric_= wwn)", ctxt); =20 /* Parse device capabilities */ - VIR_FREE(nodes); - if ((n =3D virXPathNodeSet("./capability", ctxt, &nodes)) < 0) - goto error; + if ((n =3D virXPathNodeSet("./capability", ctxt, &capability)) < 0) + return NULL; =20 if (n =3D=3D 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("no device capabilities for '%s'"), def->name); - goto error; + return NULL; } =20 next_cap =3D &def->caps; for (i =3D 0; i < n; i++) { *next_cap =3D virNodeDevCapsDefParseXML(ctxt, def, - nodes[i], + capability[i], create, virt_type); if (!*next_cap) - goto error; + return NULL; =20 next_cap =3D &(*next_cap)->next; } - VIR_FREE(nodes); - - return def; =20 - error: - virNodeDeviceDefFree(def); - VIR_FREE(nodes); - return NULL; + return g_steal_pointer(&def); } =20 =20 --=20 2.26.3 From nobody Tue May 14 08:42:02 2024 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=1620919961; cv=none; d=zohomail.com; s=zohoarc; b=c0XHRvxCLxKig4BmDE6N8922a+EeKhMwXzRiCPgAhK7mdLne4rczwyz1T8JL9IKK940oyFjfgtongJBbjxpqGiebr2wt3dLEHfJ8q5LGPX+G5H6hy7N0lfUSJsnSRxDXX1KDOYBlaEfyvpC6aIOivV52IvKxb7PT6toQfnxZkfs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620919961; 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=qnYMJoDO/Wfjo4VFkE/7E7j0F/PB8U/RvY8V/Xs78hU=; b=Ih/Q6pNo/JHLXXN7LrN82t5K7/krBi8ZHCVeC1j7LutYBEhbdaE64rrPpzSGm/0KejuXneZIQuM309WaTP8+tG0PHJaIvdNTEv6s1Zgy1aHGFuQYRXVcpjUAfU/EOP/iziJv8Q67rnzCM7cE8J9fzz6INDTXWJrFhOTEhm5yJ1E= 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) header.from= 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 1620919961709947.9162679056687; Thu, 13 May 2021 08:32:41 -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-478-_gEirSHlMR-S4Z58bhauNQ-1; Thu, 13 May 2021 11:32:37 -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 B1A23107ACF3; Thu, 13 May 2021 15:32:32 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 94CF5687E7; Thu, 13 May 2021 15:32:32 +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 5FC9A180B463; Thu, 13 May 2021 15:32:32 +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 14DFWDbc026188 for ; Thu, 13 May 2021 11:32:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0FBF3189C4; Thu, 13 May 2021 15:32:13 +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 57E2D19C95; Thu, 13 May 2021 15:32:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620919960; 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=qnYMJoDO/Wfjo4VFkE/7E7j0F/PB8U/RvY8V/Xs78hU=; b=giGixMGKz8GJPkedcXFFK32VMKgc0w4feZ7yO9wG7thu/YR3xJCBDfHnscwrRIIJUgkyqD YjUDyKl/zTCjZP5G54Ld1RyEGCfbuHWx1Pi17+c7xGU4fZWbW3IszLJcQv4x1uRwetdQWt tJo5bTjSjZINdGlmTtjEItF9RE62q9I= X-MC-Unique: _gEirSHlMR-S4Z58bhauNQ-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 2/6] virDomainNumatuneNodeParseXML: Use virXMLProp* Date: Thu, 13 May 2021 17:31:57 +0200 Message-Id: <20210513153201.20407-3-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.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) Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Laine Stump --- src/conf/numa_conf.c | 45 +++++++++++++------------------------------- 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index 932af4a185..bae59ac7b8 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -186,25 +186,13 @@ virDomainNumatuneNodeParseXML(virDomainNuma *numa, } =20 for (i =3D 0; i < n; i++) { - int mode =3D 0; unsigned int cellid =3D 0; virDomainNumaNode *mem_node =3D NULL; xmlNodePtr cur_node =3D nodes[i]; =20 - tmp =3D virXMLPropString(cur_node, "cellid"); - if (!tmp) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Missing required cellid attribute " - "in memnode element")); + if (virXMLPropUInt(cur_node, "cellid", 10, VIR_XML_PROP_REQUIRED, + &cellid) < 0) goto cleanup; - } - if (virStrToLong_uip(tmp, NULL, 10, &cellid) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Invalid cellid attribute in memnode element:= %s"), - tmp); - goto cleanup; - } - VIR_FREE(tmp); =20 if (cellid >=3D numa->nmem_nodes) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -222,25 +210,18 @@ virDomainNumatuneNodeParseXML(virDomainNuma *numa, goto cleanup; } =20 - tmp =3D virXMLPropString(cur_node, "mode"); - if (!tmp) { - mem_node->mode =3D VIR_DOMAIN_NUMATUNE_MEM_STRICT; - } else { - if ((mode =3D virDomainNumatuneMemModeTypeFromString(tmp)) < 0= ) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Invalid mode attribute in memnode elemen= t")); - goto cleanup; - } + if (virXMLPropEnumDefault(cur_node, "mode", + virDomainNumatuneMemModeTypeFromString, + VIR_XML_PROP_NONE, &mem_node->mode, + VIR_DOMAIN_NUMATUNE_MEM_STRICT) < 0) + goto cleanup; =20 - if (numa->memory.mode =3D=3D VIR_DOMAIN_NUMATUNE_MEM_RESTRICTI= VE && - mode !=3D VIR_DOMAIN_NUMATUNE_MEM_RESTRICTIVE) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("'restrictive' mode is required in memnod= e element " - "when mode is 'restrictive' in memory ele= ment")); - goto cleanup; - } - VIR_FREE(tmp); - mem_node->mode =3D mode; + if (numa->memory.mode =3D=3D VIR_DOMAIN_NUMATUNE_MEM_RESTRICTIVE && + mem_node->mode !=3D VIR_DOMAIN_NUMATUNE_MEM_RESTRICTIVE) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("'restrictive' mode is required in memnode el= ement " + "when mode is 'restrictive' in memory element= ")); + goto cleanup; } =20 tmp =3D virXMLPropString(cur_node, "nodeset"); --=20 2.26.3 From nobody Tue May 14 08:42:02 2024 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=1620919948; cv=none; d=zohomail.com; s=zohoarc; b=F2QYRA+VDXONbHy41s4xMA5SXAbprDw3QGv5oReMdH0RJgbrafz+hcqm2fSnW9KVU4LSqVgG6T0oZ6AWOHx8udky2rF1QDZTU0Mp5DCSnOv9/mM0U01yIGgtobtOIBmxgBGfiIyo/4h8X6hZp8J4Xa/JO/nCLuk5ZYNApWYf1Zo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620919948; 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=LFzmbNacM3sSopAuvXNDHQawXM4n8sJdn7ymGn3qTPY=; b=jTNyVnVjL05YAcnUUZjc1gEk3cEKtA+Fpv/KynD5Vv7OCawH/zDMQLotGHwHCYz5hCaJQyl/ptVT6iTggV5I63Pw9bdt9tcWs0PUTZk/WCuEaFpbBuS01DXLguXkZM20BKPuWJlm2MmLItPrbiZCDITz6Ksd7O3p/ebk1fsHjic= 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 1620919948919943.0029048554974; Thu, 13 May 2021 08:32:28 -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-255-w6qQVna6N1WRfFt3iU_89w-1; Thu, 13 May 2021 11:32:24 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D0D1B101371B; Thu, 13 May 2021 15:32:18 +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 B71271002F12; Thu, 13 May 2021 15:32:17 +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 B0FE255341; Thu, 13 May 2021 15:32:16 +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 14DFWEK4026196 for ; Thu, 13 May 2021 11:32:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 181BA19CB6; Thu, 13 May 2021 15:32:14 +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 61BEE189A5; Thu, 13 May 2021 15:32:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620919947; 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=LFzmbNacM3sSopAuvXNDHQawXM4n8sJdn7ymGn3qTPY=; b=YItV0eRMKMrHusDBovJkZd0Oxo68ojUosBF2gXHljpe6qiVgI427UGKGjEJa6kc3WMXP5p QjaljgT8+nDjPaN+h+tPTFcL9ahr2WQOUF4jrhkU9Vgz7anNo5PoHUGKecNDgqlIvTv9+c b4em9dZMygPLKM9k/vhOtD2Fi2pYc7c= X-MC-Unique: w6qQVna6N1WRfFt3iU_89w-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 3/6] virDomainNumatuneNodeParseXML: Use g_autofree Date: Thu, 13 May 2021 17:31:58 +0200 Message-Id: <20210513153201.20407-4-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.84 on 10.5.11.22 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 Reviewed-by: Laine Stump --- src/conf/numa_conf.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index bae59ac7b8..15bfda3aa1 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -155,16 +155,14 @@ static int virDomainNumatuneNodeParseXML(virDomainNuma *numa, xmlXPathContextPtr ctxt) { - char *tmp =3D NULL; int n =3D 0; - int ret =3D -1; size_t i =3D 0; - xmlNodePtr *nodes =3D NULL; + g_autofree xmlNodePtr *nodes =3D NULL; =20 if ((n =3D virXPathNodeSet("./numatune/memnode", ctxt, &nodes)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cannot extract memnode nodes")); - goto cleanup; + return -1; } =20 if (!n) @@ -175,30 +173,31 @@ virDomainNumatuneNodeParseXML(virDomainNuma *numa, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Per-node binding is not compatible with " "automatic NUMA placement.")); - goto cleanup; + return -1; } =20 if (!numa->nmem_nodes) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Element 'memnode' is invalid without " "any guest NUMA cells")); - goto cleanup; + return -1; } =20 for (i =3D 0; i < n; i++) { unsigned int cellid =3D 0; virDomainNumaNode *mem_node =3D NULL; xmlNodePtr cur_node =3D nodes[i]; + g_autofree char *tmp =3D NULL; =20 if (virXMLPropUInt(cur_node, "cellid", 10, VIR_XML_PROP_REQUIRED, &cellid) < 0) - goto cleanup; + return -1; =20 if (cellid >=3D numa->nmem_nodes) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Argument 'cellid' in memnode element must " "correspond to existing guest's NUMA cell")); - goto cleanup; + return -1; } =20 mem_node =3D &numa->mem_nodes[cellid]; @@ -207,21 +206,21 @@ virDomainNumatuneNodeParseXML(virDomainNuma *numa, virReportError(VIR_ERR_XML_ERROR, _("Multiple memnode elements with cellid %u"), cellid); - goto cleanup; + return -1; } =20 if (virXMLPropEnumDefault(cur_node, "mode", virDomainNumatuneMemModeTypeFromString, VIR_XML_PROP_NONE, &mem_node->mode, VIR_DOMAIN_NUMATUNE_MEM_STRICT) < 0) - goto cleanup; + return -1; =20 if (numa->memory.mode =3D=3D VIR_DOMAIN_NUMATUNE_MEM_RESTRICTIVE && mem_node->mode !=3D VIR_DOMAIN_NUMATUNE_MEM_RESTRICTIVE) { virReportError(VIR_ERR_XML_ERROR, "%s", _("'restrictive' mode is required in memnode el= ement " "when mode is 'restrictive' in memory element= ")); - goto cleanup; + return -1; } =20 tmp =3D virXMLPropString(cur_node, "nodeset"); @@ -229,24 +228,19 @@ virDomainNumatuneNodeParseXML(virDomainNuma *numa, virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing required nodeset attribute " "in memnode element")); - goto cleanup; + return -1; } if (virBitmapParse(tmp, &mem_node->nodeset, VIR_DOMAIN_CPUMASK_LEN= ) < 0) - goto cleanup; + return -1; =20 if (virBitmapIsAllClear(mem_node->nodeset)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Invalid value of 'nodeset': %s"), tmp); - goto cleanup; + return -1; } - VIR_FREE(tmp); } =20 - ret =3D 0; - cleanup: - VIR_FREE(nodes); - VIR_FREE(tmp); - return ret; + return 0; } =20 int --=20 2.26.3 From nobody Tue May 14 08:42:02 2024 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=1620919960; cv=none; d=zohomail.com; s=zohoarc; b=n56QWyLGUg4LPNFL90GreOR2YOMMmXK+H4hhkpEn12r+FchCH4O3gJKJyuOrFd0Y/BgY0jGLVKXbSCfxCMj0/g4YvbDWGog5biY7Tbn/dyx/Tb1ANEzqsA46J/Ls3I2jgwNUH6Ga/bf5LG1k/dkb2klksm/KXubnbHRHt4OQY8s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620919960; 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=/9UsthooWqXf/puA4s0ctRkUKkrGJtcOmN0F5J3R0GE=; b=b5yRR/YC+Pw0wzKlgq0rMNPsL9tPyh2k+mxIFAKESvqjbXbgQwlFA8w5C1J1GHrpqTwr+Cn7vsj79wXbVPHYoK5jyjXei0AmIrWLzpjBO3hrZncickxwy5WKFKdW9HjXI2G8M3BY5yhzOdoZGxsyQuZAOGyOwJVRC1v9Y5O2vGY= 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 1620919960513242.86356001718718; Thu, 13 May 2021 08:32:40 -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-411-fCYiKbGcMTCP4QSDKAsShA-1; Thu, 13 May 2021 11:32:36 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D93C1801817; Thu, 13 May 2021 15:32:29 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B14971002F12; Thu, 13 May 2021 15:32:29 +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 764AA180B463; Thu, 13 May 2021 15:32:29 +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 14DFWFT2026208 for ; Thu, 13 May 2021 11:32:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 27D49189A5; Thu, 13 May 2021 15:32:15 +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 6DDA039A66; Thu, 13 May 2021 15:32:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620919959; 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=/9UsthooWqXf/puA4s0ctRkUKkrGJtcOmN0F5J3R0GE=; b=LiWUotZaIyVW82MJO22D3okSNtWUBZutbmkTiTNSsHt1ycB7hdHp+g4LQfLdYIeMwb7Omo D9IH3B96xdvJlmjLaE+eaTeqRB0htrR1EJogl1LmM4CuWt03lSC1z8Hl1K9DC4QTna1Lhf z0rTaXbmcUiIY44SxaRs5B2pUUchBnw= X-MC-Unique: fCYiKbGcMTCP4QSDKAsShA-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 4/6] virDomainNumaDefNodeDistanceParseXML: Use virXMLProp* Date: Thu, 13 May 2021 17:31:59 +0200 Message-Id: <20210513153201.20407-5-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.84 on 10.5.11.22 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 Reviewed-by: Laine Stump --- src/conf/numa_conf.c | 42 ++++-------------------------------------- 1 file changed, 4 insertions(+), 38 deletions(-) diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index 15bfda3aa1..60cd7767ef 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -742,7 +742,6 @@ virDomainNumaDefNodeDistanceParseXML(virDomainNuma *def, { int ret =3D -1; int sibling; - char *tmp =3D NULL; xmlNodePtr *nodes =3D NULL; size_t i, ndistances =3D def->nmem_nodes; =20 @@ -764,24 +763,9 @@ virDomainNumaDefNodeDistanceParseXML(virDomainNuma *de= f, virDomainNumaDistance *rdist; unsigned int sibling_id, sibling_value; =20 - /* siblings are in order of parsing or explicitly numbered */ - if (!(tmp =3D virXMLPropString(nodes[i], "id"))) { - virReportError(VIR_ERR_XML_ERROR, - _("Missing 'id' attribute in NUMA " - "distances under 'cell id %d'"), - cur_cell); - goto cleanup; - } - - /* The "id" needs to be applicable */ - if (virStrToLong_uip(tmp, NULL, 10, &sibling_id) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Invalid 'id' attribute in NUMA " - "distances for sibling: '%s'"), - tmp); + if (virXMLPropUInt(nodes[i], "id", 10, VIR_XML_PROP_REQUIRED, + &sibling_id) < 0) goto cleanup; - } - VIR_FREE(tmp); =20 /* The "id" needs to be within numa/cell range */ if (sibling_id >=3D ndistances) { @@ -792,26 +776,9 @@ virDomainNumaDefNodeDistanceParseXML(virDomainNuma *de= f, goto cleanup; } =20 - /* We need a locality value. Check and correct - * distance to local and distance to remote node. - */ - if (!(tmp =3D virXMLPropString(nodes[i], "value"))) { - virReportError(VIR_ERR_XML_ERROR, - _("Missing 'value' attribute in NUMA distances " - "under 'cell id %d' for 'sibling id %d'"), - cur_cell, sibling_id); - goto cleanup; - } - - /* The "value" needs to be applicable */ - if (virStrToLong_uip(tmp, NULL, 10, &sibling_value) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("'value %s' is invalid for " - "'sibling id %d' under NUMA 'cell id %d'"), - tmp, sibling_id, cur_cell); + if (virXMLPropUInt(nodes[i], "value", 10, VIR_XML_PROP_REQUIRED, + &sibling_value) < 0) goto cleanup; - } - VIR_FREE(tmp); =20 /* Assure LOCAL_DISTANCE <=3D "value" <=3D UNREACHABLE * and correct LOCAL_DISTANCE setting if such applies. @@ -866,7 +833,6 @@ virDomainNumaDefNodeDistanceParseXML(virDomainNuma *def, def->mem_nodes[i].ndistances =3D 0; } VIR_FREE(nodes); - VIR_FREE(tmp); =20 return ret; } --=20 2.26.3 From nobody Tue May 14 08:42:02 2024 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=1620919962; cv=none; d=zohomail.com; s=zohoarc; b=OMegwvBhwk8Kg9ZmOQ7e+l1/kJYu1i3/4hOCLKiHpHbLXlGiyLT/C5tBL0vFRFSpXaacYcJg2OfBTFsFvEBgwzVEWzd5YE4jxisiQGJ+hGTAT2Gt1OjH4FElSVRtpak2H5W9wEjmXJvo++VLpEDdvwG4xe7/1eguPSdEWgITd5U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620919962; 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=H+GH/VwjeB+tAKs4e007Q6CCoM4eGSpkKtPjTqiakHE=; b=ZXQrEmtZt88uFnKXKfp3oLsncw2tRvPHq1cviHJbb5sB7Dv5cbItKvvm6dKWVDEtSKHo/l6FXf+5VU8d4Y71kSMySe/wpBJnedF2q/L3/8OUekY0uZO4RqDZvG+AP4tirrrf+d/qCbAp+sj2fdwcQiS+5UqDnoVo1dImftPGZW8= 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 1620919962210687.0208029518046; Thu, 13 May 2021 08:32:42 -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-271-PY7Gy9ZhOrKBopAgOcdBqg-1; Thu, 13 May 2021 11:32:38 -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 6F6BD1854E2A; Thu, 13 May 2021 15:32:32 +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 52E231ABE5; Thu, 13 May 2021 15:32:32 +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 19ACD55351; Thu, 13 May 2021 15:32:32 +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 14DFWG3m026218 for ; Thu, 13 May 2021 11:32:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2FE94189A5; Thu, 13 May 2021 15:32:16 +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 78BD063BA7; Thu, 13 May 2021 15:32:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620919960; 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=H+GH/VwjeB+tAKs4e007Q6CCoM4eGSpkKtPjTqiakHE=; b=gXZAqbE2YJZFrKeCqdACvG6WRYMoLd8sgBZel8OOgrCnxi5X58hVtJCn+ymDV/kz3qgD2+ EgGhtENSjNqhKpmJ69AtpXJpgQ5KwA6avWHQ6Ci5+/T5a376YRmzlLifrYq4utWX97bDYo y0LR3WiRYwwyliMSWXlxMwUjgLIjEsw= X-MC-Unique: PY7Gy9ZhOrKBopAgOcdBqg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 5/6] virDomainNumaDefParseXML: Use virXMLProp* Date: Thu, 13 May 2021 17:32:00 +0200 Message-Id: <20210513153201.20407-6-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.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) Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Laine Stump --- 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 60cd7767ef..9fe4998951 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -954,26 +954,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, @@ -1013,29 +1010,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) @@ -1057,24 +1040,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; @@ -1088,56 +1062,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 From nobody Tue May 14 08:42:02 2024 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 Reviewed-by: Laine Stump --- 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