From nobody Mon Feb 9 10:48:30 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) client-ip=216.205.24.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1585120385; cv=none; d=zohomail.com; s=zohoarc; b=D52GZr5Co5r9sILZvsBI90FpywaF54PREzh/CPQ/GZhmA0LP9yNOsW9sqP6iCgEP8XZRT73spsLJhOrQkHsFNjZr1oIDFK3pogITVYryb0rUxZXEp141YtaRl85bbii39QlToD9ECWaRR8sKjLcRgy4N1kUreSKuTLTa9CaMpio= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585120385; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=RVpu8z3VJl7SHzAqtz5EXVdmmh/KwP92Ay2UFABZ7P8=; b=WuA6RXE42mn0T0XFZAche8v7/zDvfda2sgS0DjUGtywr7YqT7woM5p3f0yM1w12Z2YRCxLNqfBVGRTPGsXrsf8ikmgEaLv2oYXZBIDFqw9ThVxlp1mD4Kr1cc3JCJ9Yjl3Q7NHvX1c20+pmhPjRF1LqXzLpr/oGf/2S5VibpymQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) by mx.zohomail.com with SMTPS id 15851203852551015.8380705924271; Wed, 25 Mar 2020 00:13:05 -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-9-bnsbWonuPpi1oF6kg6DL4A-1; Wed, 25 Mar 2020 03:13:02 -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 816391005512; Wed, 25 Mar 2020 07:12:56 +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 4EB291001F43; Wed, 25 Mar 2020 07:12:56 +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 0B8AD944C4; Wed, 25 Mar 2020 07:12:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02P7CSTN023846 for ; Wed, 25 Mar 2020 03:12:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1E4152166B2B; Wed, 25 Mar 2020 07:12:29 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1A1542166B2A for ; Wed, 25 Mar 2020 07:12:29 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (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 E6DBB101A55D for ; Wed, 25 Mar 2020 07:12:28 +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-193-dnJrCpxkMTCnA-D6BKB_hw-1; Wed, 25 Mar 2020 03:12:26 -0400 Received: from localhost.localdomain (unknown [123.232.151.103]) by smtp4 (Coremail) with SMTP id JedpCgD3ftNNBHtey+koAw--.408S21; Wed, 25 Mar 2020 15:12:22 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585120384; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=RVpu8z3VJl7SHzAqtz5EXVdmmh/KwP92Ay2UFABZ7P8=; b=A/yoXhwJJd6t/+Q3xCVBzDoss646sR9kzwVC3aypZ9X2VZltlDxYd3UhyY11hpL8Cipn0z 2ZumULvdzRdcnseOeUPtCoGWFh2qemTZu+ZvfTVggIb4th/wWP246UBgfPAeLnb2CnuvLO tJbCTSHASdH1elJQ9c7KsXwilHyPeX8= X-MC-Unique: bnsbWonuPpi1oF6kg6DL4A-1 X-MC-Unique: dnJrCpxkMTCnA-D6BKB_hw-1 From: Shi Lei To: libvir-list@redhat.com Subject: [RFC 19/29] conf: Extract error-checking code from virNetworkDNSTxtDefParseXML Date: Wed, 25 Mar 2020 15:11:59 +0800 Message-Id: <20200325071209.20841-20-shi_lei@massclouds.com> In-Reply-To: <20200325071209.20841-1-shi_lei@massclouds.com> References: <20200325071209.20841-1-shi_lei@massclouds.com> X-CM-TRANSID: JedpCgD3ftNNBHtey+koAw--.408S21 X-Coremail-Antispam: 1Uf129KBjvJXoWxZryUZr4ftF17ZFy7ZF1fZwb_yoW5tr17pF s5XF9xtr4kWr13trWxKas5Gwn0ga4kGw1YkryfuwnrZrWrWw1xJF4fXr4xuw4DWr9Yqr43 AF45X398Gw4UXaUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pio7KDUUUUU= X-Originating-IP: [123.232.151.103] X-CM-SenderInfo: pvklsz1hl6ztxvvfz0xxgvhudrp/1tbiShbxT1dqANzw4QAAsS X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 02P7CSTN023846 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.84 on 10.5.11.22 X-Mimecast-Spam-Score: 2 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Shi Lei --- docs/schemas/network.rng | 13 ++++++++- src/conf/network_conf.c | 60 +++++++++++++++++++++++++++------------- 2 files changed, 53 insertions(+), 20 deletions(-) diff --git a/docs/schemas/network.rng b/docs/schemas/network.rng index 4caea02..b0f4a64 100644 --- a/docs/schemas/network.rng +++ b/docs/schemas/network.rng @@ -292,7 +292,18 @@ diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 0469f03..f83799f 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -488,6 +488,41 @@ virSocketAddrRangeParseXML(const char *networkName, } =20 =20 +static int +virNetworkDNSTxtDefParseXMLPost(xmlNodePtr curnode G_GNUC_UNUSED, + virNetworkDNSTxtDefPtr def, + const char *networkName, + bool partialOkay, + const char *nameStr G_GNUC_UNUSED, + const char *valueStr G_GNUC_UNUSED) +{ + const char *bad =3D " ,"; + + 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); + return -1; + } + + 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); + return -1; + } + + if (!(def->name || def->value)) { + virReportError(VIR_ERR_XML_DETAIL, + _("Missing required name or value " + "in DNS TXT record of network %s"), networkName); + return -1; + } + + return 0; +} + + static int virNetworkDHCPHostDefParseXML(const char *networkName, virNetworkIPDefPtr def, @@ -717,33 +752,20 @@ virNetworkDNSTxtDefParseXML(const char *networkName, virNetworkDNSTxtDefPtr def, bool partialOkay) { - const char *bad =3D " ,"; - 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)= { - virReportError(VIR_ERR_XML_DETAIL, - _("missing required value attribute in DNS TXT reco= rd " - "named '%s' of network %s"), def->name, networkNa= me); - goto error; - } =20 - if (!(def->name || def->value)) { - virReportError(VIR_ERR_XML_DETAIL, - _("Missing required name or value " - "in DNS TXT record of network %s"), networkName); + def->value =3D virXMLPropString(node, "value"); + + if (virNetworkDNSTxtDefParseXMLPost(node, def, + networkName, partialOkay, + def->name, def->value) < 0) goto error; - } + return 0; =20 error: --=20 2.17.1