mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
conf: Add virNetworkXMLNamespace
Just the plumbing, no real implementation yet Reviewed-by: Laine Stump <laine@laine.org> Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
8911d843f3
commit
2dde2dbba1
@ -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, "<network");
|
||||
if (def->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, "</network>\n");
|
||||
|
||||
|
@ -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,
|
||||
|
@ -139,7 +139,7 @@ networkDnsmasqCapsRefresh(virNetworkDriverStatePtr driver)
|
||||
static virNetworkXMLOptionPtr
|
||||
networkDnsmasqCreateXMLConf(void)
|
||||
{
|
||||
return virNetworkXMLOptionNew();
|
||||
return virNetworkXMLOptionNew(NULL);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user