From patchwork Mon Jul 15 00:03:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 168972 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3688605ilk; Sun, 14 Jul 2019 17:04:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqzFqPU+ygVegWf0PorWLfNPV9oOCTduaCBcWEnGojK7lnAvwaFl0dXnyOJcQ+QSQXrU3vzM X-Received: by 2002:aed:3535:: with SMTP id a50mr16224194qte.237.1563149066785; Sun, 14 Jul 2019 17:04:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563149066; cv=none; d=google.com; s=arc-20160816; b=XjH7HZCkvNhtTRXqswOq4XWYBxFxc2n6PaGNLbT1vGhvPZv+gqAkudYSpthOQVafdh vGFXBqZwrxbvP9nFbcnXYDyGiOf9I9OyeOvCgWNaJdA1WNNjJ4RNKhtnS6Le/rNvLOQE fUoo20lT2e+oFL2xTSTfN4vqzxMk5IgbxGcPKAHeSUEIOfwkYQz+wg6iMdEgSwtzmqU/ z4dvH0Vpk3Oa76pdYgnzFf2hMtlt+nwRE+i1l/WJNbRhGEGjkFTH9/VIjyTHrKnwDLzk Q795ouqbAv2HfvtQZ5rIFrlWDDF/npJ4JWCZMNSYeEPhPgshExsZPnoRhCOtVvoJK2ya /yKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=o+rZ16IwZ9gXyJ7mT/07q+RTrTanIn8vtnyDhqeglhI=; b=DFQU9k5TLxm2cJN4l8FURR2Q7aZ6oivhAyM4+R/5+l87skm8rQMojWt8+9ZWkxdwA7 RxI8Mu97NTh+SVWKDpHUGS80P3OR18GUjU+sOUzWzew/vrIMCztEiaraqkHOP3GI2nBB oR8QNjWruVhZF3f0UXraUHu+98Lyrc/uUPI7PgrrfLuDgtVyTdLeDk6YlCbEOQKj76gR qaJFiYVtgVk7pF7RB0lvpgDgp8qBS1dlUen4XehafJxyqzlqOs1hxarFi6J185qA33Sf ZKaf0BMok0JRmLAGtdURpWY7J7xYW9MclvYtqqXz9bbsFPiVSnsfJx3e3IhyjkSoD1dF ZdWw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id n47si9974524qtb.345.2019.07.14.17.04.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Jul 2019 17:04:26 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 mx1.redhat.com (Postfix) with ESMTPS id 8625FC049598; Mon, 15 Jul 2019 00:04:24 +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 ADD5D5D968; Mon, 15 Jul 2019 00:04: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 5227741F63; Mon, 15 Jul 2019 00:04:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6F04ICQ030307 for ; Sun, 14 Jul 2019 20:04:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7059460C44; Mon, 15 Jul 2019 00:04:18 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from worklaptop.redhat.com (ovpn-121-2.rdu2.redhat.com [10.10.121.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 08B0E60BFB; Mon, 15 Jul 2019 00:04:17 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Sun, 14 Jul 2019 20:03:59 -0400 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/5] conf: Add virNetworkXMLNamespace 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 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 15 Jul 2019 00:04:25 +0000 (UTC) Just the plumbing, no real implementation yet Signed-off-by: Cole Robinson --- src/conf/network_conf.c | 22 ++++++++++++++++++++-- src/conf/network_conf.h | 21 ++++++++++++++++++++- src/network/bridge_driver.c | 2 +- 3 files changed, 41 insertions(+), 4 deletions(-) -- 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 067adf7936..c5a243684a 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -93,7 +93,7 @@ virNetworkXMLOnceInit(void) VIR_ONCE_GLOBAL_INIT(virNetworkXML); virNetworkXMLOptionPtr -virNetworkXMLOptionNew(void) +virNetworkXMLOptionNew(virNetworkXMLNamespacePtr xmlns) { virNetworkXMLOptionPtr xmlopt; @@ -103,6 +103,9 @@ virNetworkXMLOptionNew(void) if (!(xmlopt = virObjectNew(virNetworkXMLOptionClass))) return NULL; + if (xmlns) + xmlopt->ns = *xmlns; + return xmlopt; } @@ -268,6 +271,8 @@ virNetworkDefFree(virNetworkDefPtr def) xmlFreeNode(def->metadata); + if (def->namespaceData && def->ns.free) + (def->ns.free)(def->namespaceData); VIR_FREE(def); } @@ -1622,7 +1627,7 @@ virNetworkForwardDefParseXML(const char *networkName, virNetworkDefPtr virNetworkDefParseXML(xmlXPathContextPtr ctxt, - virNetworkXMLOptionPtr xmlopt ATTRIBUTE_UNUSED) + virNetworkXMLOptionPtr xmlopt) { virNetworkDefPtr def; char *tmp = NULL; @@ -2043,6 +2048,12 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt, virXMLNodeSanitizeNamespaces(def->metadata); } + if (xmlopt) + def->ns = xmlopt->ns; + if (def->ns.parse && + (def->ns.parse)(ctxt, &def->namespaceData) < 0) + goto error; + ctxt->node = save; return def; @@ -2422,6 +2433,8 @@ virNetworkDefFormatBuf(virBufferPtr buf, bool hasbridge = false; virBufferAddLit(buf, "namespaceData && def->ns.href) + virBufferAsprintf(buf, " %s", (def->ns.href)()); if (!(flags & VIR_NETWORK_XML_INACTIVE) && (def->connections > 0)) virBufferAsprintf(buf, " connections='%d'", def->connections); if (def->ipv6nogw) @@ -2627,6 +2640,11 @@ virNetworkDefFormatBuf(virBufferPtr buf, if (virPortGroupDefFormat(buf, &def->portGroups[i]) < 0) goto error; + if (def->namespaceData && def->ns.format) { + if ((def->ns.format)(buf, def->namespaceData) < 0) + return -1; + } + virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h index b7ce569d4a..b167b57e85 100644 --- a/src/conf/network_conf.h +++ b/src/conf/network_conf.h @@ -41,9 +41,24 @@ #include "virmacmap.h" #include "virenum.h" +typedef int (*virNetworkDefNamespaceParse)(xmlXPathContextPtr, void **); +typedef void (*virNetworkDefNamespaceFree)(void *); +typedef int (*virNetworkDefNamespaceXMLFormat)(virBufferPtr, void *); +typedef const char *(*virNetworkDefNamespaceHref)(void); + +typedef struct _virNetworkXMLNamespace virNetworkXMLNamespace; +typedef virNetworkXMLNamespace *virNetworkXMLNamespacePtr; +struct _virNetworkXMLNamespace { + virNetworkDefNamespaceParse parse; + virNetworkDefNamespaceFree free; + virNetworkDefNamespaceXMLFormat format; + virNetworkDefNamespaceHref href; +}; struct _virNetworkXMLOption { virObject parent; + + virNetworkXMLNamespace ns; }; typedef struct _virNetworkXMLOption virNetworkXMLOption; typedef virNetworkXMLOption *virNetworkXMLOptionPtr; @@ -277,6 +292,10 @@ struct _virNetworkDef { /* Application-specific custom metadata */ xmlNodePtr metadata; + + /* Network specific XML namespace data */ + void *namespaceData; + virNetworkXMLNamespace ns; }; typedef enum { @@ -298,7 +317,7 @@ enum { }; virNetworkXMLOptionPtr -virNetworkXMLOptionNew(void); +virNetworkXMLOptionNew(virNetworkXMLNamespacePtr xmlns); virNetworkDefPtr virNetworkDefCopy(virNetworkDefPtr def, diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 3353754eb5..1a4d6e7f7b 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -139,7 +139,7 @@ networkDnsmasqCapsRefresh(virNetworkDriverStatePtr driver) static virNetworkXMLOptionPtr networkDnsmasqCreateXMLConf(void) { - return virNetworkXMLOptionNew(); + return virNetworkXMLOptionNew(NULL); }