From nobody Mon Feb 9 10:48:27 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=1585120419; cv=none; d=zohomail.com; s=zohoarc; b=b4JkmVy+s/8tC+oxri0qrTfVoVPPonJDAC4YfngN4V12eFg1Q9IP8clMi+Ud6ulGwoOjF3JnU5fP7t54Brg2FAUy222lEHCCxdElWz8MUjzYM+HORimcVa/4Cc5QCRmje6FWImEdqkWr/ELiELiU8WepsSmWcbBod+Up5Po9GwU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585120419; 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=D5ny6/GROGgbq7zGaWZ0M7DxhiTcy2fzcZnNAPTqgsM=; b=cXr6xzzEziQHOzC1vDXGg9zTf0AGzXE4OwcBo1dHf7lb9ZxLW3pXX4uZQpFE/anrnOLtSNUKYovetWwnOTGNXV6GAcWfGvjgd/5QX0RUla9D3b6CjP9Lecd6BVmjoLfWJFWoWKcb4c53kF9evxAHjUumHo61WSwEy/svp0v+V2g= 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 1585120419455576.4707906679097; Wed, 25 Mar 2020 00:13:39 -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-203-hJg8HlnbPme7OeOqJnJPEQ-1; Wed, 25 Mar 2020 03:13:34 -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 CF6341085927; Wed, 25 Mar 2020 07:13:28 +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 9F168A7FF; Wed, 25 Mar 2020 07:13:28 +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 3F27F18034FA; Wed, 25 Mar 2020 07:13:28 +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 02P7CVZv023972 for ; Wed, 25 Mar 2020 03:12:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id F36222166B2B; Wed, 25 Mar 2020 07:12:30 +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 EF71D2166B2A for ; Wed, 25 Mar 2020 07:12:28 +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 3A8418FF662 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-394--UsabqULNS2LGc2MQY_N2g-1; Wed, 25 Mar 2020 03:12:25 -0400 Received: from localhost.localdomain (unknown [123.232.151.103]) by smtp4 (Coremail) with SMTP id JedpCgD3ftNNBHtey+koAw--.408S18; Wed, 25 Mar 2020 15:12:21 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585120418; 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=D5ny6/GROGgbq7zGaWZ0M7DxhiTcy2fzcZnNAPTqgsM=; b=Ea5j6h+BNPysA12fal4rWO4bG/gseIWv99dgodb6xEvAsSzpM9F+qXfGocwt4SIG22LnUv uXKTSzx7Vv+zyusgCkkpVIjefpH2bQlwf/gbm+TBJbLpv3NSzMS90q43foHs+SO3kTiHfP FrcwFWqwAGT7R4wd5Ts25y5wZp1oXnU= X-MC-Unique: hJg8HlnbPme7OeOqJnJPEQ-1 X-MC-Unique: -UsabqULNS2LGc2MQY_N2g-1 From: Shi Lei To: libvir-list@redhat.com Subject: [RFC 16/29] conf: Replace virNetworkDNSHostDefParseXML(hardcoded) with namesake(generated) Date: Wed, 25 Mar 2020 15:11:56 +0800 Message-Id: <20200325071209.20841-17-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--.408S18 X-Coremail-Antispam: 1Uf129KBjvJXoWxXF1Utw18urW8Aw4xKF48WFg_yoWrCF4rpF sxJFsFyw48WF1akFW7AryrCrnxWrykXa15K34fuw1fZrW8Xr1xGrn7WF1xWFZ8GrWF9r45 AF4aqa98Gr4UJFUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pEX_TUUUUUU= X-Originating-IP: [123.232.151.103] X-CM-SenderInfo: pvklsz1hl6ztxvvfz0xxgvhudrp/1tbiiRXxT1tVgvnlkgAAsg 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 02P7CVZv023972 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.23 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 | 7 +++-- po/POTFILES.in | 1 + src/conf/network_conf.c | 66 +++++----------------------------------- 3 files changed, 13 insertions(+), 61 deletions(-) diff --git a/docs/schemas/network.rng b/docs/schemas/network.rng index ee4487e..c902f7e 100644 --- a/docs/schemas/network.rng +++ b/docs/schemas/network.rng @@ -337,14 +337,17 @@ "structure": {"output": "src/conf/network_conf"}, "clearfunc": {"output": "src/conf/network_conf"}, "parsefunc": { - "args.noctxt": true, + "output": "src/conf/network_conf", "args.instname": true, "post": true, "args": [ {"name": "partialOkay", "type": "Bool"} ] }, - "members": [{"id": "hostname", "name": "name"}] + "members": [ + {"id": "ip", "opt": true}, + {"id": "hostname", "name": "name", "opt": true} + ] } --> diff --git a/po/POTFILES.in b/po/POTFILES.in index 2358b01..5e2985a 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -3,6 +3,7 @@ @BUILDDIR@/src/access/viraccessapicheckqemu.c @BUILDDIR@/src/admin/admin_client.h @BUILDDIR@/src/admin/admin_server_dispatch_stubs.h +@BUILDDIR@/src/conf/network_conf.generated.c @BUILDDIR@/src/remote/remote_client_bodies.h @BUILDDIR@/src/remote/remote_daemon_dispatch_stubs.h @SRCDIR@/rng2c/directive.py diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index d9f2252..6f0722a 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -560,9 +560,10 @@ virNetworkDHCPDefParseXML(const char *networkName, } =20 =20 -static int +int virNetworkDNSHostDefParseXMLPost(xmlNodePtr curnode G_GNUC_UNUSED, virNetworkDNSHostDefPtr def, + xmlXPathContextPtr ctxt G_GNUC_UNUSED, const char *networkName, bool partialOkay, const char *ipStr, @@ -593,61 +594,6 @@ virNetworkDNSHostDefParseXMLPost(xmlNodePtr curnode G_= GNUC_UNUSED, } =20 =20 -/* virNetworkDNSHostDefParseXML will be replaced by generated namesake */ -static int -virNetworkDNSHostDefParseXML(const char *networkName, - xmlNodePtr node, - virNetworkDNSHostDefPtr def, - bool partialOkay) -{ - xmlNodePtr cur; - char *ip; - - ip =3D virXMLPropString(node, "ip"); - if (ip && (virSocketAddrParse(&def->ip, ip, AF_UNSPEC) < 0)) { - virReportError(VIR_ERR_XML_DETAIL, - _("Invalid IP address in network '%s' DNS HOST reco= rd"), - networkName); - VIR_FREE(ip); - goto error; - } - - cur =3D node->children; - while (cur !=3D NULL) { - if (cur->type =3D=3D XML_ELEMENT_NODE && - virXMLNodeNameEqual(cur, "hostname")) { - if (cur->children !=3D NULL) { - char *name =3D (char *) xmlNodeGetContent(cur); - - if (!name) { - virReportError(VIR_ERR_XML_DETAIL, - _("Missing hostname in network '%s' D= NS HOST record"), - networkName); - goto error; - } - if (VIR_APPEND_ELEMENT(def->names, def->nnames, name) < = 0) { - VIR_FREE(name); - goto error; - } - } - } - cur =3D cur->next; - } - - if (virNetworkDNSHostDefParseXMLPost(node, def, networkName, - partialOkay, ip, def->nnames) < 0) - goto error; - - VIR_FREE(ip); - return 0; - - error: - VIR_FREE(ip); - virNetworkDNSHostDefClear(def); - return -1; -} - - /* This includes all characters used in the names of current * /etc/services and /etc/protocols files (on Fedora 20), except ".", * which we can't allow because it would conflict with the use of "." @@ -907,8 +853,10 @@ virNetworkDNSDefParseXML(const char *networkName, goto cleanup; =20 for (i =3D 0; i < nhosts; i++) { - if (virNetworkDNSHostDefParseXML(networkName, hostNodes[i], - &def->hosts[def->nhosts], fal= se) < 0) { + if (virNetworkDNSHostDefParseXML(hostNodes[i], + &def->hosts[def->nhosts], + ctxt, + networkName, false) < 0) { goto cleanup; } def->nhosts++; @@ -3373,7 +3321,7 @@ virNetworkDefUpdateDNSHost(virNetworkDefPtr def, if (virNetworkDefUpdateCheckElementName(def, ctxt->node, "host") < 0) goto cleanup; =20 - if (virNetworkDNSHostDefParseXML(def->name, ctxt->node, &host, !isAdd)= < 0) + if (virNetworkDNSHostDefParseXML(ctxt->node, &host, ctxt, def->name, != isAdd) < 0) goto cleanup; =20 for (i =3D 0; i < dns->nhosts; i++) { --=20 2.17.1