From nobody Mon Feb 9 21:19:37 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) client-ip=63.128.21.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 63.128.21.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1585120423; cv=none; d=zohomail.com; s=zohoarc; b=fmP+fDnH5lmuJb534a0QTzKrGL4rtKGYKUTfHL5pQz6i6gUd7p469q8iZKTYH8D9BHtpg8JJXBK0c5iNkC2Z5ftMvpKAdKBUyTC/BE67/6CC9I0/T4A1LBFbC9OYsREGceMPBMpKhoM2nGmyfb5HSATU1beVOsHaEjPmPh3Ce3o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585120423; 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=oK2zqNZv5O7FGcfcQbiISD1en/mO56K6DrCY51JzUko=; b=G06l1cpsjkPQiBvtv18xNzznb2u5UAs9XuNyVKx0mqR/BoK9LtZJTo6GIt6Etm7AIykzaNzbxDVzkjCgrs81p90jITq91qg2kf7nNXf6ptRTPJE8Ue7sOYA5y00pVSNnurbZgj8ybmysp0IfzkwvWMqK/QfSjWau8hXno1tOScI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.74]) by mx.zohomail.com with SMTPS id 1585120423008235.3293763035041; Wed, 25 Mar 2020 00:13:43 -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-110-YLUBsK7lPGSN6EFmAYkG8w-1; Wed, 25 Mar 2020 03:13:39 -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 E461F108442A; Wed, 25 Mar 2020 07:13:32 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BCCA792D39; Wed, 25 Mar 2020 07:13:32 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 746C18A038; Wed, 25 Mar 2020 07:13:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02P7CUdA023897 for ; Wed, 25 Mar 2020 03:12:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id A65762026D67; Wed, 25 Mar 2020 07:12:29 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A2FA82037E4F for ; Wed, 25 Mar 2020 07:12:29 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.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 89EA58007D9 for ; Wed, 25 Mar 2020 07:12:29 +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-100-_YRaZt-2OBCa9xqsj3P1ZQ-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--.408S26; 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=1585120421; 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=oK2zqNZv5O7FGcfcQbiISD1en/mO56K6DrCY51JzUko=; b=T5pWtAGZhz6aLpwajQUWGK0i72dMTJI3fJM05JcNINctN3ctXUWLh+2cNuPpBUtyW1q2MA HwG3tPnnSq555kOYpP4OfPcJN4bsocJV5mYIOejdgH6QVDC/v9tgR/Xtpjrl+yQel8gvJU fpxQRy8+MQKfL7NDNnmQVY3wnFs+R4I= X-MC-Unique: YLUBsK7lPGSN6EFmAYkG8w-1 X-MC-Unique: _YRaZt-2OBCa9xqsj3P1ZQ-1 From: Shi Lei To: libvir-list@redhat.com Subject: [RFC 24/29] conf: Replace virNetworkDNSDefParseXML(hardcoded) with namesake(generated) Date: Wed, 25 Mar 2020 15:12:04 +0800 Message-Id: <20200325071209.20841-25-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--.408S26 X-Coremail-Antispam: 1Uf129KBjvJXoWxCFW5tw4UXF48Ww1UKF43GFg_yoW7Gry7pF nYqFyDKFWrWFnag3yI9w10krn8uF18GF45KryxuwnrZ34UGw13Gr1fWryxXrWDWrZ5XrsI y3WagFn8Gw4UGF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zujqWDUUUUU= X-Originating-IP: [123.232.151.103] X-CM-SenderInfo: pvklsz1hl6ztxvvfz0xxgvhudrp/1tbiRxbxT1dqAIIyagAAsI X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 02P7CUdA023897 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.13 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 | 1 + src/conf/network_conf.c | 150 +-------------------------------------- 2 files changed, 3 insertions(+), 148 deletions(-) diff --git a/docs/schemas/network.rng b/docs/schemas/network.rng index 884cd64..7084248 100644 --- a/docs/schemas/network.rng +++ b/docs/schemas/network.rng @@ -261,6 +261,7 @@ "structure": {"output": "src/conf/network_conf"}, "clearfunc": {"output": "src/conf/network_conf"}, "parsefunc": { + "output": "src/conf/network_conf", "post": true, "args.instname": true } diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index d231fea..905c01f 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -764,7 +764,7 @@ virNetworkDNSHostDefParseXMLPost(xmlNodePtr curnode G_G= NUC_UNUSED, } =20 =20 -static int +int virNetworkDNSDefParseXMLPost(xmlNodePtr curnode G_GNUC_UNUSED, virNetworkDNSDefPtr def, xmlXPathContextPtr ctxt G_GNUC_UNUSED, @@ -788,152 +788,6 @@ virNetworkDNSDefParseXMLPost(xmlNodePtr curnode G_GNU= C_UNUSED, } =20 =20 -static int -virNetworkDNSDefParseXML(const char *networkName, - xmlNodePtr node, - xmlXPathContextPtr ctxt, - virNetworkDNSDefPtr def) -{ - xmlNodePtr *hostNodes =3D NULL; - xmlNodePtr *srvNodes =3D NULL; - xmlNodePtr *txtNodes =3D NULL; - xmlNodePtr *fwdNodes =3D NULL; - char *forwardPlainNames =3D NULL; - char *enable =3D NULL; - int nhosts, nsrvs, ntxts, nfwds; - size_t i; - int ret =3D -1; - xmlNodePtr save =3D ctxt->node; - - ctxt->node =3D node; - - enable =3D virXPathString("string(./@enable)", ctxt); - if (enable) { - def->enable =3D virTristateBoolTypeFromString(enable); - if (def->enable <=3D 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Invalid dns enable setting '%s' " - "in network '%s'"), - enable, networkName); - goto cleanup; - } - } - - forwardPlainNames =3D virXPathString("string(./@forwardPlainNames)", c= txt); - if (forwardPlainNames) { - def->forwardPlainNames =3D virTristateBoolTypeFromString(forwardPl= ainNames); - if (def->forwardPlainNames <=3D 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Invalid dns forwardPlainNames setting '%s' " - "in network '%s'"), - forwardPlainNames, networkName); - goto cleanup; - } - } - - nfwds =3D virXPathNodeSet("./forwarder", ctxt, &fwdNodes); - if (nfwds < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("invalid element found in of ne= twork %s"), - networkName); - goto cleanup; - } - if (nfwds > 0) { - if (VIR_ALLOC_N(def->forwarders, nfwds) < 0) - goto cleanup; - - for (i =3D 0; i < nfwds; i++) { - if (virNetworkDNSForwarderParseXML(fwdNodes[i], - &def->forwarders[i], - networkName) < 0) - goto cleanup; - - def->nforwarders++; - } - } - - nhosts =3D virXPathNodeSet("./host", ctxt, &hostNodes); - if (nhosts < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("invalid element found in of network= %s"), - networkName); - goto cleanup; - } - if (nhosts > 0) { - if (VIR_ALLOC_N(def->hosts, nhosts) < 0) - goto cleanup; - - for (i =3D 0; i < nhosts; i++) { - if (virNetworkDNSHostDefParseXML(hostNodes[i], - &def->hosts[def->nhosts], - ctxt, - networkName, false) < 0) { - goto cleanup; - } - def->nhosts++; - } - } - - nsrvs =3D virXPathNodeSet("./srv", ctxt, &srvNodes); - if (nsrvs < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("invalid element found in of network = %s"), - networkName); - goto cleanup; - } - if (nsrvs > 0) { - if (VIR_ALLOC_N(def->srvs, nsrvs) < 0) - goto cleanup; - - for (i =3D 0; i < nsrvs; i++) { - if (virNetworkDNSSrvDefParseXML(srvNodes[i], - &def->srvs[def->nsrvs], ctxt, - networkName, false) < 0) { - goto cleanup; - } - def->nsrvs++; - } - } - - ntxts =3D virXPathNodeSet("./txt", ctxt, &txtNodes); - if (ntxts < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("invalid element found in of network = %s"), - networkName); - goto cleanup; - } - if (ntxts > 0) { - if (VIR_ALLOC_N(def->txts, ntxts) < 0) - goto cleanup; - - for (i =3D 0; i < ntxts; i++) { - if (virNetworkDNSTxtDefParseXML(txtNodes[i], - &def->txts[def->ntxts], - networkName, false) < 0) { - goto cleanup; - } - def->ntxts++; - } - } - - if (virNetworkDNSDefParseXMLPost(node, def, ctxt, networkName, enable, - forwardPlainNames, nfwds, ntxts, - nsrvs, nhosts) < 0) - goto cleanup; - - ret =3D 0; - cleanup: - VIR_FREE(enable); - VIR_FREE(forwardPlainNames); - VIR_FREE(fwdNodes); - VIR_FREE(hostNodes); - VIR_FREE(srvNodes); - VIR_FREE(txtNodes); - ctxt->node =3D save; - return ret; -} - - static int virNetworkIPDefParseXML(const char *networkName, xmlNodePtr node, @@ -1726,7 +1580,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt, =20 dnsNode =3D virXPathNode("./dns", ctxt); if (dnsNode !=3D NULL && - virNetworkDNSDefParseXML(def->name, dnsNode, ctxt, &def->dns) < 0)= { + virNetworkDNSDefParseXML(dnsNode, &def->dns, ctxt, def->name) < 0)= { goto error; } =20 --=20 2.17.1