From nobody Wed May 15 23:45:36 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=1620745586; cv=none; d=zohomail.com; s=zohoarc; b=D19YHrCoGn3zZvzIlRbQgSqKr3ljX91Dy9+wejMbbpmemnuoix27YiSLq+FMEIyivRIynDHC/s+PKSdxnzduclWzc3dWXubkvrs8MkbuGPKUEsZR+KBPwhRYxKVa5wcxCLCSuyp40weZf8YOmiPiXpwhQBJPagKq2Ynebyha81A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620745586; 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=FePzd0WBuX0wRP+za68TyLrzKdmkEvfMrKzk3DAPhmI=; b=Wu5WNqcKSN8SRz0GuIgdHEuWfOLLbT82xeWnI2g+SpM362sLHoX74MnOR+RwpSY/fAeHvoCdSuQLRu1OZ5XjoITXtShjt66Bf58yd6tzy8nJt0WiaBdsc6ftFRSgjFCV+eja5QXbXtHPKNI03pxGWaKs0x2k3iBrQvHSYaS0rRM= 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 16207455862521017.6037570666548; Tue, 11 May 2021 08:06:26 -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-261-sAKzJqmCM82Uwk60w1FwRg-1; Tue, 11 May 2021 11:02:21 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C0BC9818426; Tue, 11 May 2021 15:02:13 +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 954EA5D9E3; Tue, 11 May 2021 15:02:13 +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 17D9655344; Tue, 11 May 2021 15:02:13 +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 14BF1xZ3005477 for ; Tue, 11 May 2021 11:01:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id E9E8360CDE; Tue, 11 May 2021 15:01:59 +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 409C01B427; Tue, 11 May 2021 15:01:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620745344; 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=FePzd0WBuX0wRP+za68TyLrzKdmkEvfMrKzk3DAPhmI=; b=B0ed1D2D8lxP6xxAEWAYjktkkiySUvnaR2c6oHQSA1smJDLLbS++c0LMpy7SbfWRZYoVbv a/vPxFZCtrr1TVbx5h9odwQ9bXTIg3Z785Uvxsp8po7GXJolp1B89ve5yMKeIotlz3KCk+ EqWBgSwXA8UM8LOQ8B3JcnJSEkmmlDE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620745585; 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=FePzd0WBuX0wRP+za68TyLrzKdmkEvfMrKzk3DAPhmI=; b=jM0CCNsMKuvTet/tRtWTD0stOIl6GXXr2PXe7TDg8cjWBkNttfmThBE9WVbRqjj0+fU5c0 yPRu/NvOyqyRnWCn05tx0MWtAtj9Q1L7AvITjQp5diz+UyzAD2KX6v7pWX6co3+/E7xfEJ Yx1fqyDg/zIR/2OIl+5xD/znPlxMdsg= X-MC-Unique: sAKzJqmCM82Uwk60w1FwRg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 01/10] virNodeDeviceDefParseXML: Use g_auto* Date: Tue, 11 May 2021 17:01:48 +0200 Message-Id: <20210511150157.26027-2-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.14 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/node_device_conf.c | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 4477a8d9d2..5ac046f768 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -2059,21 +2059,19 @@ 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 *nodes =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"); @@ -2083,7 +2081,7 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, =20 /* Parse devnodes */ if ((n =3D virXPathNodeSet("./devnode", ctxt, &nodes)) < 0) - goto error; + return NULL; =20 def->devlinks =3D g_new0(char *, n + 1); =20 @@ -2093,16 +2091,16 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, =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 +2116,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,7 +2124,7 @@ 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); @@ -2134,13 +2132,13 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, /* Parse device capabilities */ VIR_FREE(nodes); if ((n =3D virXPathNodeSet("./capability", ctxt, &nodes)) < 0) - goto error; + 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; @@ -2150,18 +2148,12 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, create, virt_type); if (!*next_cap) - goto error; + return NULL; =20 next_cap =3D &(*next_cap)->next; } - VIR_FREE(nodes); =20 - return def; - - error: - virNodeDeviceDefFree(def); - VIR_FREE(nodes); - return NULL; + return g_steal_pointer(&def); } =20 =20 --=20 2.26.3 From nobody Wed May 15 23:45:36 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=1620745461; cv=none; d=zohomail.com; s=zohoarc; b=XCUaEPNv/bKCzuibK369sbeHQ1OieMbTuuy2GGkUyLwOZAcL1nSlPzHcXX+niAwfo9W66q3XCEJyUe2ZX3Hw0uGMfbBksyELUPuwvsmR5m7vnDnhzGxD9q1M+wW7Zm10TBYAi0DTaVS5lUviyDeQj6RF7cbj4MXefWzyVq48f1Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620745461; 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=lxVt42glZB4vNhSl3tQPfZ2EvLQmMscRG79JuOGiSUpNfm7kGPCk2bkJrmLGffXA/ouDH+7T+6wj76ti1/WlU6Uol4t0I6bLcBIlkTGqPrLdZuKVFjyG6EOZlnQSAOloJBXxHhE1v/yXv3ZyL425FjpfNf0IeR9UmCnxpPePszA= 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 1620745461288435.0649741888884; Tue, 11 May 2021 08:04:21 -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-523-vuD45fsiM6aSxw5g5JNVFg-1; Tue, 11 May 2021 11:02:24 -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 4466D8C8640; Tue, 11 May 2021 15:02:17 +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 1E943BA6F; Tue, 11 May 2021 15:02: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 D4BD0180C69B; Tue, 11 May 2021 15:02:16 +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 14BF21af005491 for ; Tue, 11 May 2021 11:02:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 03ED92B0B1; Tue, 11 May 2021 15:02:01 +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 4A2C860CDE; Tue, 11 May 2021 15:02:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620745457; 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=Rb878iOTpSxUKiCFMBye84cDnkQdcaztJfEE6Jr18BNvx+uvBd446ohDAJCW8HTWJzgYcU gPsg+K9ai/pzWJGU+poDnJCERdYh9TyxOVHkp1vjiy86TMk8d93kS8pcHAd6fPBTl+somB KeZopUbvWjpiK26UC7PWd/sn18SdYf0= X-MC-Unique: vuD45fsiM6aSxw5g5JNVFg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 02/10] virDomainNumatuneNodeParseXML: Use virXMLProp* Date: Tue, 11 May 2021 17:01:49 +0200 Message-Id: <20210511150157.26027-3-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.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 --- 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 Wed May 15 23:45:36 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=1620745409; cv=none; d=zohomail.com; s=zohoarc; b=lIvNVaPvLEYk70zV10tLHohUMwPD1psbkdb2XAZF6cIJJ4kTjBDu1fnrvOZMa0DchKEUAWgTaMG46MM7n1Juzkuc8STOEpZYVZBt0rjbfZ83SRk/YtUtgOqPaUYqV6nX6RsR4Xq3KhVUhvsbqlRoM5yxjGr3QHw+cbEn0+lq82Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620745409; 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=seyAFy0DPnDTcF0WF4d/CjMsZtOst1qZDCs9Cd6yrqo=; b=NjSG2apaH5R2yrDe3/L8tpQ8RQBXvbofxd0iNOEZb9VGoVb1uOqUlN0FtbM5Hj4r7wik8vCEUwiJx7Ah42i9VBkI5OwdyzDKr45TYMs8FklncFrYRTzgsiOV5T02WkYkAYT86DheZkc7Zvjegvj8ingbv1ofS6G7qE9fsVE44lQ= 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 1620745409781383.34854128407915; Tue, 11 May 2021 08:03:29 -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-219-Qgp3_Bl_MF-6TqRbBoU7Sw-1; Tue, 11 May 2021 11:02:28 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8C6958186F2; Tue, 11 May 2021 15:02: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 5C2673A3; Tue, 11 May 2021 15:02: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 087C95535F; Tue, 11 May 2021 15:02:20 +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 14BF22HY005498 for ; Tue, 11 May 2021 11:02:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 08F3560CDE; Tue, 11 May 2021 15:02:02 +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 5241A50E2F; Tue, 11 May 2021 15:02:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620745405; 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=seyAFy0DPnDTcF0WF4d/CjMsZtOst1qZDCs9Cd6yrqo=; b=YlfpMty4R6B0yNY+SOENZM3CDynzquJtC/4+bb0DZB9Qn55KiydGSq8g5suwPqSFUouyPd 4D7WCUfoeOu8RpbuHvF8Uj3/nQmLww0FtLpAqK+Q7OXyAPsBxAoWfRX4Q8er6mhQM0+Lnb sqa5ohwdjfrskQUeF00KoReeqjFagck= X-MC-Unique: Qgp3_Bl_MF-6TqRbBoU7Sw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 03/10] virDomainNumatuneNodeParseXML: Use g_autofree Date: Tue, 11 May 2021 17:01:50 +0200 Message-Id: <20210511150157.26027-4-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.84 on 10.5.11.23 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 | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index bae59ac7b8..531bdc6eba 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -155,16 +155,15 @@ static int virDomainNumatuneNodeParseXML(virDomainNuma *numa, xmlXPathContextPtr ctxt) { - char *tmp =3D NULL; + g_autofree 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,14 +174,14 @@ 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++) { @@ -192,13 +191,13 @@ virDomainNumatuneNodeParseXML(virDomainNuma *numa, =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,20 @@ 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 Wed May 15 23:45:36 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=1620745597; cv=none; d=zohomail.com; s=zohoarc; b=nNZ68bhY+kX6jgjcmSyCg3nfJFUV/jsjMWWOXKmPu8BlJ840tU2PNuOWewkaZ9uV8S+9VWA39kWMvea61Tk29AaeM5ub04gcIOSh5J6EG3zIWsAMmL9j7zvzn5cDGEuqh34rbJ2fMAv2W3AV1YLyT1lQpCk+zoFMnHBAJgvlR2s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620745597; 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=MYZUjyapQjyazUQoNO6RXNzgjtOPQKCVl9yBi0zpcto=; b=LqdUKON4F3O0nWrX4Ga6PjLi7AmjoOrgaoKi/60oGftYUpgQQwzj5OuAvfC+d7/moxHP3IrZ09wrly1Pb8wiFYTrS6d5BWudQ9gjeYhPi0HGYEqcJ9JcCEp99J+8/qmJyl+LhlXciL80+0Es0X2Nb2dawggWdGftYXWGwcpXCFs= 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 162074559701823.288500315308966; Tue, 11 May 2021 08:06:37 -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-408-N4xqVgtsNdeTpLMJ7tG2aA-1; Tue, 11 May 2021 11:02:31 -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 BAF198186F0; Tue, 11 May 2021 15:02:23 +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 982FC50E2F; Tue, 11 May 2021 15:02:23 +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 5F73B1801263; Tue, 11 May 2021 15:02:23 +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 14BF23AA005506 for ; Tue, 11 May 2021 11:02:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 10F512B0B1; Tue, 11 May 2021 15:02:03 +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 5929D614EB; Tue, 11 May 2021 15:02:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620745354; 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=MYZUjyapQjyazUQoNO6RXNzgjtOPQKCVl9yBi0zpcto=; b=iYCCJW7iCyMVY5wprx6J2wW/5PHzy7mX/KE0vzCfqjjjGl1UqdvhcYWqaWWoIYI5FvtqJz 0fJU+YpKN8lmJFD9ZgFke0E8049q1yZBzQlpqhuxP2t8Dw9zZAlDTgrg29NvQ9dbhbRviL BsdYsPoYpT3N2k17cZNTizuVN3AdB+c= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620745596; 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=MYZUjyapQjyazUQoNO6RXNzgjtOPQKCVl9yBi0zpcto=; b=Q26l64G3DOcIn/Pwq3RFZJxtGbwxfvuAAfVDwHVK7CDZYFwCqwStSVCZ6158YmQDh+NcLe DuIgtMZmFeI9nmCYwW1oSJ6U+hy5d31Zm08GY2Bvm4l64epejOzsnVZ73K0h5+xsguM9N4 ZeiN7RdZPJ8J8OIlhMvSe5LssulF3K0= X-MC-Unique: N4xqVgtsNdeTpLMJ7tG2aA-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 04/10] virDomainNumaDefNodeDistanceParseXML: Use virXMLProp* Date: Tue, 11 May 2021 17:01:51 +0200 Message-Id: <20210511150157.26027-5-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.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) (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake --- 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 531bdc6eba..e631bfa341 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -743,7 +743,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 @@ -765,24 +764,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) { @@ -793,26 +777,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. @@ -867,7 +834,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 Wed May 15 23:45:36 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=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 From nobody Wed May 15 23:45:36 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=1620745481; cv=none; d=zohomail.com; s=zohoarc; b=j7O2s2erxiH+pnVnc1z+rNnF/BKXZ405Vji7WNEwZCd6wpE6RdVif4eImkGLVCg95CzA2NdrSFOA92jH4zyLhqysIpZdXQBI/UIMgFMt3od0a6Jkuzr6nimF2GYQoW2pHegMxG2pW4GHhwRn4cYY/Z/o+Y1xQB8Gi04J8IPRpsA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620745481; 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=i5bAPphsLef1euxf08kMA88bbRyGq6uPvaGs1vRH/4g=; b=kt1cLcYrRNxOUZNAp0gPTKeq/FOsAsFBfe4K+5hpuhBVaf66/G7ZeY05RnIeZIS0sFL1c8HVPl7GUzUg/MP81vPHlS8KXqiQmu9W6AHO+nshjnNwWLTciTPTFb0MNP6CIhD4A6OaYITUx/aVzcRl0X9k4H2fNMS4SmIjTaha3Y4= 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 1620745481374670.3333234460781; Tue, 11 May 2021 08:04: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-557-AutyIUVDMDCOi0yQLPXRSw-1; Tue, 11 May 2021 11:02:33 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E45FCFC89; Tue, 11 May 2021 15:02:26 +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 C24AC5DEAD; Tue, 11 May 2021 15:02:26 +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 76A8B1801267; Tue, 11 May 2021 15:02:26 +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 14BF25dg005539 for ; Tue, 11 May 2021 11:02:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 297041B427; Tue, 11 May 2021 15:02:05 +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 726AE60CDE; Tue, 11 May 2021 15:02:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620745356; 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=i5bAPphsLef1euxf08kMA88bbRyGq6uPvaGs1vRH/4g=; b=SnCYlDHmvB3+jRNvLdgOM8eDpe9bYEm46pw03LRsnR4NatmRGPyGi/CuIB2RQpbCp5M1sj sUH9cWJOtI4cztLRydDcsKxrCAlAo1qFQBEfkfPDw6FbtFfU1/O+aZG0PLqUuILOIKJohn iXuDLEGhhuU0WFW2NFVqGeMCXwFlyGw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620745480; 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=i5bAPphsLef1euxf08kMA88bbRyGq6uPvaGs1vRH/4g=; b=E6lBrDsWmZEKD2B579s0swXYBarHSxlpwEGXnWiDs5SJYrXuw1Pwzwyg1EJOWekEUR/1Ym Fk3vu/jQNL5mVIXXDlMp6LOQv2msX6iqVJeJHr+A/2XyysbnigagfzK9pkoA0Hr+mXxQ0I xxvpcKpKrNymYg5E29TiBz6an+Zn6+U= X-MC-Unique: AutyIUVDMDCOi0yQLPXRSw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 06/10] virDomainNumaDefParseXML: Use g_autofree Date: Tue, 11 May 2021 17:01:53 +0200 Message-Id: <20210511150157.26027-7-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.14 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 | 49 +++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index 27aac87a8d..abb39a36ac 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -933,11 +933,9 @@ int virDomainNumaDefParseXML(virDomainNuma *def, xmlXPathContextPtr ctxt) { - xmlNodePtr *nodes =3D NULL; - char *tmp =3D NULL; + g_autofree xmlNodePtr *nodes =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)) @@ -946,7 +944,7 @@ virDomainNumaDefParseXML(virDomainNuma *def, if ((n =3D virXPathNodeSet("./cpu/numa[1]/cell", ctxt, &nodes)) <=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); @@ -954,12 +952,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, &cur_cell)) < 0) - goto cleanup; + return -1; =20 if (rc =3D=3D 0) cur_cell =3D i; @@ -970,25 +969,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"))) { 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++) { @@ -1002,38 +1000,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]; 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", 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, &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; + return -1; =20 def->interconnects =3D g_new0(virDomainNumaInterconnect, n); for (i =3D 0; i < n; i++) { @@ -1049,7 +1047,7 @@ virDomainNumaDefParseXML(virDomainNuma *def, =20 if (virXMLPropULongLong(nodes[i], "value", 10, VIR_XML_PROP_REQUIRED, &value) < 0) - goto cleanup; + return -1; } else if (virXMLNodeNameEqual(nodes[i], "bandwidth")) { VIR_XPATH_NODE_AUTORESTORE(ctxt) type =3D VIR_DOMAIN_NUMA_INTERCONNECT_TYPE_BANDWIDTH; @@ -1057,7 +1055,7 @@ virDomainNumaDefParseXML(virDomainNuma *def, ctxt->node =3D nodes[i]; =20 if (virDomainParseMemory("./@value", "./@unit", ctxt, &value, = true, false) < 0) - goto cleanup; + return -1; } else { /* Ignore yet unknown child elements. */ continue; @@ -1065,32 +1063,27 @@ virDomainNumaDefParseXML(virDomainNuma *def, =20 if (virXMLPropUInt(nodes[i], "initiator", 10, VIR_XML_PROP_REQUIRE= D, &initiator) < 0) - goto cleanup; + return -1; =20 if (virXMLPropUInt(nodes[i], "target", 10, VIR_XML_PROP_REQUIRED, &target) < 0) - goto cleanup; + return -1; =20 if (virXMLPropUInt(nodes[i], "cache", 10, VIR_XML_PROP_NONE, &cache) < 0) - goto cleanup; + return -1; =20 if (virXMLPropEnum(nodes[i], "type", virDomainMemoryLatencyTypeFro= mString, 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 From nobody Wed May 15 23:45:36 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=1620745645; cv=none; d=zohomail.com; s=zohoarc; b=YqFxj+WDNJarMD3HHz45ZIbvpU9zoXUuJYnK6Aqnh/hBMsISVJRONE1GixP0RqB24x+9q7jMgj+w1aFuZEpguDjmH2MbhlWSzBTAWNpqnTVn8bbTN69fo2pmejvxu3iAcNZcVH8GoVIsyMjL2RetUV74FVhhgS3uIHx7wlv/91w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620745645; 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=KtZuFWJQN5Q72kAEDWPdJou2QKuFeGcTsqlKnUdA2ds=; b=Gv4Je0Yr94BsygiuV6FsL68IIfWWaWtm/azRF7+5aDR31kiS7lm0NQ0LTDYSvj18Zq2rQVeJjybwUpDLAIqTtGWw+kkbGX+O+DpDcUwo5dfm9tgOodIkw2RoMigHmdLxL5MqQw4q20OOuSitvlNrRz7Jz06hDGzgwweoJ6Ka1sI= 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 16207456459826.528018529486076; Tue, 11 May 2021 08:07:25 -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-23-vfqlpLZuO725AhWKlE_gHA-1; Tue, 11 May 2021 11:02:22 -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 51FF0FC9C; Tue, 11 May 2021 15:02:14 +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 91F951037F3D; Tue, 11 May 2021 15:02:13 +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 1A1D7180B464; Tue, 11 May 2021 15:02:13 +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 14BF26u3005552 for ; Tue, 11 May 2021 11:02:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2FF5B53CC6; Tue, 11 May 2021 15:02:06 +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 7B69B50E2F; Tue, 11 May 2021 15:02:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620745345; 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=KtZuFWJQN5Q72kAEDWPdJou2QKuFeGcTsqlKnUdA2ds=; b=ZUSxLwzChlP+tTsKrZ7co4rv1JpL5MzM9gximwwosw3cE0Clg6RWgfcX9clAs51LXT33a3 HNhFsoOvs6mOvAYO4FctRxiL52YXy1F1gmMuko184fgHfkpR+8Cq2cfDP5dJ0ydkacjARo xHuSWtVUgbRwwA0fxy9HPw6KzupQD8o= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620745645; 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=KtZuFWJQN5Q72kAEDWPdJou2QKuFeGcTsqlKnUdA2ds=; b=TFp6mfnDhtqc2Rubn7oYigv62ONRjCoyhwlKxhCIkMelb/FCcySMxypyIb3OKJHQAjRXhC NRQm9zHWYyUJJv9JO5LXRuJb+bA1GWLBc3WT7PZEw8lDtgcdMWJ2zFIcW15+KIz4hlIspK bY3Z6b8nFPsCpVa3+ydGSJve8+fghz4= X-MC-Unique: vfqlpLZuO725AhWKlE_gHA-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 07/10] virStorageAdapterParseXMLFCHost: Use virXMLProp* Date: Tue, 11 May 2021 17:01:54 +0200 Message-Id: <20210511150157.26027-8-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.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) (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Laine Stump --- src/conf/storage_adapter_conf.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/conf/storage_adapter_conf.c b/src/conf/storage_adapter_con= f.c index 142489f6cd..6b5a58e1e7 100644 --- a/src/conf/storage_adapter_conf.c +++ b/src/conf/storage_adapter_conf.c @@ -64,28 +64,17 @@ static int virStorageAdapterParseXMLFCHost(xmlNodePtr node, virStorageAdapterFCHost *fchost) { - char *managed =3D NULL; + if (virXMLPropTristateBool(node, "managed", VIR_XML_PROP_NONE, + &fchost->managed) < 0) + return -1; =20 fchost->parent =3D virXMLPropString(node, "parent"); - if ((managed =3D virXMLPropString(node, "managed"))) { - int value; - if ((value =3D virTristateBoolTypeFromString(managed)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown fc_host managed setting '%s'"), - managed); - VIR_FREE(managed); - return -1; - } - fchost->managed =3D value; - } - fchost->parent_wwnn =3D virXMLPropString(node, "parent_wwnn"); fchost->parent_wwpn =3D virXMLPropString(node, "parent_wwpn"); fchost->parent_fabric_wwn =3D virXMLPropString(node, "parent_fabric_ww= n"); fchost->wwpn =3D virXMLPropString(node, "wwpn"); fchost->wwnn =3D virXMLPropString(node, "wwnn"); =20 - VIR_FREE(managed); return 0; } =20 --=20 2.26.3 From nobody Wed May 15 23:45:36 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=1620745348; cv=none; d=zohomail.com; s=zohoarc; b=IEydGchXvAoDL9cMPdVClG8bF/bJpfA8trhWUAz3bCmm44DOqksQzFq2W2e3js5FP+OlAbqPzS/tiAxI/3hC66+KOo9LzpHNkF3H5TeQa3cBsdbiepTHm1oVIb2TDk9WtKPjRL4SIY99tdmKqqxWqySRa1B688MQGT4SePv4h+4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620745348; 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=Lw1XM0XoK0Fv0He7om8Jk+XM7UbGttR3btshg2g/Dn8=; b=aIKKTIZn8Bz58YCJYatrOCpDhBOEZaH25IQuaN990/PXqpGiRZZmJIIMdjoZ+0UQJjNQF9Cdzp60tgRsMlN32EVh8NQ52fPROGpv+mawuf2rXJpgHSzSpbxOGt4oijQM4RQ3vrsbXBRGgL/0GmRXgPIYf3ga+WLg7qrzyA5Ncxc= 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 1620745348839489.0093735174712; Tue, 11 May 2021 08:02: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-501-9JrczoIbN9-EyZq6OhAbDw-1; Tue, 11 May 2021 11:02:23 -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 B655E8C864C; Tue, 11 May 2021 15:02:13 +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 90EB213470; Tue, 11 May 2021 15:02:13 +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 4924155345; Tue, 11 May 2021 15:02:13 +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 14BF2BSP005578 for ; Tue, 11 May 2021 11:02:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 70D9D2B0B1; Tue, 11 May 2021 15:02:11 +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 B8D1F1B427; Tue, 11 May 2021 15:02:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620745347; 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=Lw1XM0XoK0Fv0He7om8Jk+XM7UbGttR3btshg2g/Dn8=; b=YY0sRraEbk5DU4KnuQ1ISoxgwAaJ4dsfrrJr96rY87B8MOLZAsuG1bR5sPc6roRm+GDOI6 A7ofmjzXOjskp6zSzwLxzS5uhZZNgyP43KDKKdsB7C29R1ivUlTKTLpbYjEfEPIhHKctlX JPyZ5ksbW+sz7Dw6lTalHqmhjddERag= X-MC-Unique: 9JrczoIbN9-EyZq6OhAbDw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 08/10] virStoragePoolDefParseSource: Use virXMLProp* Date: Tue, 11 May 2021 17:01:55 +0200 Message-Id: <20210511150157.26027-9-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.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/storage_conf.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 328650bd6a..435a029b4e 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -531,7 +531,6 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, virStoragePoolOptions *options; int n; g_autoptr(virStorageAuthDef) authdef =3D NULL; - g_autofree char *port =3D NULL; g_autofree char *ver =3D NULL; g_autofree xmlNodePtr *nodeset =3D NULL; g_autofree char *sourcedir =3D NULL; @@ -580,16 +579,9 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, goto cleanup; } =20 - port =3D virXMLPropString(nodeset[i], "port"); - if (port) { - if (virStrToLong_i(port, NULL, 10, &source->hosts[i].port)= < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Invalid port number: %s"), - port); - goto cleanup; - } - } - VIR_FREE(port); + if (virXMLPropInt(nodeset[i], "port", 10, VIR_XML_PROP_NONE, + &source->hosts[i].port, 0) < 0) + goto cleanup; } } =20 @@ -602,7 +594,6 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, goto cleanup; =20 for (i =3D 0; i < nsource; i++) { - g_autofree char *partsep =3D NULL; virStoragePoolSourceDevice dev =3D { .path =3D NULL }; dev.path =3D virXMLPropString(nodeset[i], "path"); =20 @@ -612,17 +603,11 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, goto cleanup; } =20 - partsep =3D virXMLPropString(nodeset[i], "part_separator"); - if (partsep) { - int value =3D virTristateBoolTypeFromString(partsep); - if (value <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("invalid part_separator setting '%s'"), - partsep); - virStoragePoolSourceDeviceClear(&dev); - goto cleanup; - } - dev.part_separator =3D value; + if (virXMLPropTristateBool(nodeset[i], "part_separator", + VIR_XML_PROP_NONE, + &dev.part_separator) < 0) { + virStoragePoolSourceDeviceClear(&dev); + goto cleanup; } =20 if (VIR_APPEND_ELEMENT(source->devices, source->ndevice, dev) < 0)= { --=20 2.26.3 From nobody Wed May 15 23:45:36 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=1620745535; cv=none; d=zohomail.com; s=zohoarc; b=mfBPAVCdr0exzxu6YsrkyEO9ne4JC35Eckvre3O2ed2ExpRVEqzO9+l4GLrvgOYDntzAeAVru6XuOU+peCBFp1qpkFdf+y8PcMI4oT/Jc84zhKqEfPqYZrMxFfhgVvQVnikfiuUqwzIHtVqOemSfRub60PgpOsVVWVfQhmfLYV8= 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=CQmdQTQtuE3hoXwh3wiBgOK4BAC4CiN9fSHxrqyR0YI=; b=nnNyQna7Db5wcpgYi5jq+mhEtS44/mEhMXyaszqW/oZF6cRLjs3NWI3NEi4ZbqkHjzfb0Nq7/Ak8Y5p+VgoLOchzJhZwSGmk/bTRyDNL3iVgdZgKckTprvvj3WS+Lbr6xK53swel0oCfY6hThJopkWkEnEBO9gaGqEGW5nweG8c= 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 1620745535276200.95942170187482; 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-418-R7IgCCt0MeyCiA24nM_TPg-1; Tue, 11 May 2021 11:02:25 -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 5150A1006C88; Tue, 11 May 2021 15:02:17 +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 2D53B13905; Tue, 11 May 2021 15:02: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 DD0D05535C; Tue, 11 May 2021 15:02:16 +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 14BF2C2U005589 for ; Tue, 11 May 2021 11:02:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7A9351B427; Tue, 11 May 2021 15:02:12 +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 C449A60CDE; Tue, 11 May 2021 15:02:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620745532; 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=CQmdQTQtuE3hoXwh3wiBgOK4BAC4CiN9fSHxrqyR0YI=; b=fXFB5XS9eqDuYbJaPI7nfG0B5znoSHoWzzVlCiuzoLoaF2N6fIoZyDdjD3QxzGGZbACEZA c7XKsBQSsiqg2J3F/1TVYSRmnta9ed5wbYhyF7GAezpQCIkk7mJivE608mHeoSWbC0WDLn kREMTP93GUOFMYeNed9SNimJ2XY2bfM= X-MC-Unique: R7IgCCt0MeyCiA24nM_TPg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 09/10] virStoragePoolDefParseSource: Use VIR_XPATH_NODE_AUTORESTORE Date: Tue, 11 May 2021 17:01:56 +0200 Message-Id: <20210511150157.26027-10-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.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/storage_conf.c | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 435a029b4e..10b46ac368 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -523,8 +523,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, int pool_type, xmlNodePtr node) { - int ret =3D -1; - xmlNodePtr relnode, authnode; + xmlNodePtr authnode; xmlNodePtr adapternode; int nsource; size_t i; @@ -534,18 +533,18 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, g_autofree char *ver =3D NULL; g_autofree xmlNodePtr *nodeset =3D NULL; g_autofree char *sourcedir =3D NULL; + VIR_XPATH_NODE_AUTORESTORE(ctxt) =20 - relnode =3D ctxt->node; ctxt->node =3D node; =20 if ((options =3D virStoragePoolOptionsForPoolType(pool_type)) =3D=3D N= ULL) - goto cleanup; + return -1; =20 source->name =3D virXPathString("string(./name)", ctxt); if (pool_type =3D=3D VIR_STORAGE_POOL_RBD && source->name =3D=3D NULL)= { virReportError(VIR_ERR_XML_ERROR, "%s", _("element 'name' is mandatory for RBD pool")); - goto cleanup; + return -1; } =20 if (options->formatFromString) { @@ -560,12 +559,12 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, if (source->format < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown pool format type %s"), format); - goto cleanup; + return -1; } } =20 if ((n =3D virXPathNodeSet("./host", ctxt, &nodeset)) < 0) - goto cleanup; + return -1; =20 if (n) { source->hosts =3D g_new0(virStoragePoolSourceHost, n); @@ -576,12 +575,12 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, if (!source->hosts[i].name) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing storage pool host name")); - goto cleanup; + return -1; } =20 if (virXMLPropInt(nodeset[i], "port", 10, VIR_XML_PROP_NONE, &source->hosts[i].port, 0) < 0) - goto cleanup; + return -1; } } =20 @@ -591,7 +590,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, =20 nsource =3D virXPathNodeSet("./device", ctxt, &nodeset); if (nsource < 0) - goto cleanup; + return -1; =20 for (i =3D 0; i < nsource; i++) { virStoragePoolSourceDevice dev =3D { .path =3D NULL }; @@ -600,19 +599,19 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, if (dev.path =3D=3D NULL) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing storage pool source device path")); - goto cleanup; + return -1; } =20 if (virXMLPropTristateBool(nodeset[i], "part_separator", VIR_XML_PROP_NONE, &dev.part_separator) < 0) { virStoragePoolSourceDeviceClear(&dev); - goto cleanup; + return -1; } =20 if (VIR_APPEND_ELEMENT(source->devices, source->ndevice, dev) < 0)= { virStoragePoolSourceDeviceClear(&dev); - goto cleanup; + return -1; } =20 } @@ -626,17 +625,17 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, =20 if ((adapternode =3D virXPathNode("./adapter", ctxt))) { if (virStorageAdapterParseXML(&source->adapter, adapternode, ctxt)= < 0) - goto cleanup; + return -1; } =20 if ((authnode =3D virXPathNode("./auth", ctxt))) { if (!(authdef =3D virStorageAuthDefParse(authnode, ctxt))) - goto cleanup; + return -1; =20 if (authdef->authType =3D=3D VIR_STORAGE_AUTH_TYPE_NONE) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("storage pool missing auth type")); - goto cleanup; + return -1; } =20 source->auth =3D g_steal_pointer(&authdef); @@ -650,24 +649,20 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, _("storage pool protocol ver unsupported for " "pool type '%s'"), virStoragePoolFormatFileSystemNetTypeToString(s= ource->format)); - goto cleanup; + return -1; } if (virStrToLong_uip(ver, NULL, 0, &source->protocolVer) < 0) { virReportError(VIR_ERR_XML_ERROR, _("storage pool protocol ver '%s' is malformed"= ), ver); - goto cleanup; + return -1; } } =20 source->vendor =3D virXPathString("string(./vendor/@name)", ctxt); source->product =3D virXPathString("string(./product/@name)", ctxt); =20 - ret =3D 0; - cleanup: - ctxt->node =3D relnode; - - return ret; + return 0; } =20 =20 --=20 2.26.3 From nobody Wed May 15 23:45:36 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=1620745622; cv=none; d=zohomail.com; s=zohoarc; b=NodlC+UBFXo2NxrcGHK20yngaCaL9dRfJcqRibhvL55Hm7H3TIgOHCmOQ/f9k1yIqtsfxxr0nRU9t9XFmmJv+uoXITWoVkY/HcJg0Pz7UxVYNa8IbUjfkHQc8eAFURsouk92rWo67gAIKikGsPwP4osJlaKN5bth4gYuEJdIqrE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620745622; 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=gSvgrS9VGjBKENPTT4YpHE5plAG+JVf1IyAbp4AajFE=; b=KJFNTOVEDs+qnTj0bYsXSZwl0Nml5GQiqbJ7+oWAjrC55OtHp5Bv4hx0zxIgFoqQmQyiER7BLJeVNP/pPJTN54ItwsEqe7nFPFGJ7FPx0OzwxNlir+6iUOOcd4gLDnYGoulcY2Ozl/H9fNJqtAjqrOvtFJjM9PHyNcyidSqNsYQ= 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 1620745622718123.96725148766393; Tue, 11 May 2021 08:07:02 -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-520-K9qg_hKZPIau2-Nyb5XWIw-1; Tue, 11 May 2021 11:02:35 -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 D63568186E6; Tue, 11 May 2021 15:02: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 AFD5060C04; Tue, 11 May 2021 15:02: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 48C5C59CCF; Tue, 11 May 2021 15:02:29 +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 14BF2Dkd005599 for ; Tue, 11 May 2021 11:02:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7DC071B427; Tue, 11 May 2021 15:02:13 +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 CB8A0614EB; Tue, 11 May 2021 15:02:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620745358; 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=gSvgrS9VGjBKENPTT4YpHE5plAG+JVf1IyAbp4AajFE=; b=LbWh2C2RakyoaY7Sb12yRklNQ8ybiAkzmYo/U3xWQ5YWUTGY5d1Gy/YzUvZt33VpV7uDIy VvXu9NIJJYzeduZhWFXfMinmGALzwdqp0Z190IdcFCX874hCzHh7vH4OR/v0MoGWRIe799 +mpFw0/jzytWcDxrIcWHbEsxIrbRDWs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620745621; 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=gSvgrS9VGjBKENPTT4YpHE5plAG+JVf1IyAbp4AajFE=; b=WEzgWDywSua/kqW+Po3u/NLWHvxDBTNoQ1em3f/HxxKPaWBy5g0W7lCJ2YwnAZxqNRobz+ H1pOJPKzxcdic2lswUYBI6y8wUccT+EJVCHoGtQ6QlKDsZGJAUHazcX4PeUrGmSQXpkdFT 0EBZaK2OPnPtLYMfUFNuoSMsFV2C8ls= X-MC-Unique: K9qg_hKZPIau2-Nyb5XWIw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 10/10] virStoragePoolDefParseXML: Use virXMLProp* Date: Tue, 11 May 2021 17:01:57 +0200 Message-Id: <20210511150157.26027-11-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.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) (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Laine Stump --- src/conf/storage_conf.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 10b46ac368..e481cac75c 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -841,24 +841,17 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) virStoragePoolOptions *options; xmlNodePtr source_node; g_autoptr(virStoragePoolDef) def =3D NULL; - g_autofree char *type =3D NULL; + virStoragePoolType type; g_autofree char *uuid =3D NULL; g_autofree char *target_path =3D NULL; =20 def =3D g_new0(virStoragePoolDef, 1); =20 - type =3D virXPathString("string(./@type)", ctxt); - if (type =3D=3D NULL) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("storage pool missing type attribute")); + if (virXMLPropEnum(ctxt->node, "type", virStoragePoolTypeFromString, + VIR_XML_PROP_REQUIRED, &type) < 0) return NULL; - } =20 - if ((def->type =3D virStoragePoolTypeFromString(type)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown storage pool type %s"), type); - return NULL; - } + def->type =3D type; =20 if ((options =3D virStoragePoolOptionsForPoolType(def->type)) =3D=3D N= ULL) return NULL; --=20 2.26.3