From nobody Mon Feb 9 09:22:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591752413; cv=none; d=zohomail.com; s=zohoarc; b=OgjfkH3b/hI9KB7TwsREfujrQ2GAOaMjFOQOlE9oOl8BjOdRkIH4DqfjkiHGhqDtKI63MDh7MqohBf8ErXOZc6+uMrXKT7q2g8caHA84IG0H5f2ntYWdzv15vABZgq6cEeoBFRAkk+qTQViXALkG8df3cYFrGf+EW8dJ/j4gbSk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591752413; h=Content-Type:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=RuXlSgd0h86K/1QRvchcqU7/WNLiuhYWR4sI2132Qus=; b=afIFeSaDvSqSUw6ZPpQ45V/H1t0C56bdy1nR5TOh3wnDLQNui5kTgCRuMGU0iIzQAZ/qX1HMaBQcrpGns5wiWwraDSK82WV3BXPAfQ4WJk51lLL1LNvLSyO+j0QML2uk07+MRBk6Mxz2CwoRSHphhot2ZkpObyd+ECHjh4CyJ4Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1591752413714420.0998255698379; Tue, 9 Jun 2020 18:26:53 -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-449-sy4h-LkEP2mFI0ub7pETbA-1; Tue, 09 Jun 2020 21:26:49 -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 D400B8014D4; Wed, 10 Jun 2020 01:26:44 +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 A74497A8D3; Wed, 10 Jun 2020 01:26:44 +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 762B5B34AA; Wed, 10 Jun 2020 01:26:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05A1Qhe5027260 for ; Tue, 9 Jun 2020 21:26:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id E884E10E60DD; Wed, 10 Jun 2020 01:26:42 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E3DBD10EE6DD for ; Wed, 10 Jun 2020 01:26:41 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1E808811E7A for ; Wed, 10 Jun 2020 01:26:41 +0000 (UTC) Received: from mail-m24147.qiye.163.com (mail-m24147.qiye.163.com [220.194.24.147]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-510-Ex7axMcyMqy_pygZDiOd_A-1; Tue, 09 Jun 2020 21:26:37 -0400 Received: from localhost.localdomain (unknown [58.56.27.130]) by smtp4 (Coremail) with SMTP id JedpCgCnxdh_NeBeVKS4Bw--.7295S8; Wed, 10 Jun 2020 09:21:24 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591752412; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:content-type:content-type: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=RuXlSgd0h86K/1QRvchcqU7/WNLiuhYWR4sI2132Qus=; b=bAe6GRpCJZTU/FXkIs/WPZJTlVeZcY8V2PL2+mSMFNs/FcOcs1VzS3ikjJoiup5IYekCQG uRvBIK9m82Zkl14cT4UIr9Ua4eBW8r7J+a4z3+zCs0DA3nvWxKJrWDcfaTHeA9zT0mHfDy LJlEdtTBKQN4BGJ6LrFoUgi4bHh9s3E= X-MC-Unique: sy4h-LkEP2mFI0ub7pETbA-1 X-MC-Unique: Ex7axMcyMqy_pygZDiOd_A-1 From: Shi Lei To: libvir-list@redhat.com Subject: [RFC 06/21] conf: Extract error-checking code from virNetworkDNSTxtDefParseXML Date: Wed, 10 Jun 2020 09:20:34 +0800 Message-Id: <20200610012049.10774-7-shi_lei@massclouds.com> In-Reply-To: <20200610012049.10774-1-shi_lei@massclouds.com> References: <20200610012049.10774-1-shi_lei@massclouds.com> X-CM-TRANSID: JedpCgCnxdh_NeBeVKS4Bw--.7295S8 X-Coremail-Antispam: 1Uf129KBjDUn29KB7ZKAUJUUUU5529EdanIXcx71UUUUU7v73 VFW2AGmfu7bjvjm3AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvj4Rbo7iUUUUU X-Originating-IP: [58.56.27.130] X-CM-SenderInfo: pvklsz1hl6ztxvvfz0xxgvhudrp/1tbiiBU-T1tVg1i3fgAAsx X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com 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 X-Mimecast-Spam-Score: 2 X-Mimecast-Originator: redhat.com X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Shi Lei --- src/conf/network_conf.c | 48 +++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index f1d22b2..47aaef3 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -904,26 +904,25 @@ virNetworkDNSSrvDefParseXML(const char *networkName, =20 =20 static int -virNetworkDNSTxtDefParseXML(const char *networkName, - xmlNodePtr node, - virNetworkDNSTxtDefPtr def, - bool partialOkay) +virNetworkDNSTxtDefParseXMLHook(xmlNodePtr node G_GNUC_UNUSED, + virNetworkDNSTxtDefPtr def, + const char *networkName, + void *opaque) { const char *bad =3D " ,"; + bool partialOkay =3D false; + + if (opaque) + partialOkay =3D *((bool *) opaque); =20 - if (!(def->name =3D virXMLPropString(node, "name"))) { - virReportError(VIR_ERR_XML_DETAIL, - _("missing required name attribute in DNS TXT recor= d " - "of network %s"), networkName); - goto error; - } if (strcspn(def->name, bad) !=3D strlen(def->name)) { virReportError(VIR_ERR_XML_DETAIL, _("prohibited character in DNS TXT record " "name '%s' of network %s"), def->name, networkNam= e); goto error; } - if (!(def->value =3D virXMLPropString(node, "value")) && !partialOkay)= { + + if (!def->value && !partialOkay) { virReportError(VIR_ERR_XML_DETAIL, _("missing required value attribute in DNS TXT reco= rd " "named '%s' of network %s"), def->name, networkNa= me); @@ -936,6 +935,33 @@ virNetworkDNSTxtDefParseXML(const char *networkName, "in DNS TXT record of network %s"), networkName); goto error; } + + return 0; + + error: + return -1; +} + + +static int +virNetworkDNSTxtDefParseXML(const char *networkName, + xmlNodePtr node, + virNetworkDNSTxtDefPtr def, + bool partialOkay) +{ + if (!(def->name =3D virXMLPropString(node, "name"))) { + virReportError(VIR_ERR_XML_DETAIL, + _("missing required name attribute in DNS TXT recor= d " + "of network %s"), networkName); + goto error; + } + + def->value =3D virXMLPropString(node, "value"); + + if (virNetworkDNSTxtDefParseXMLHook(node, def, networkName, + &partialOkay) < 0) + goto error; + return 0; =20 error: --=20 2.17.1