mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-18 10:35: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);
|
VIR_ONCE_GLOBAL_INIT(virNetworkXML);
|
||||||
|
|
||||||
virNetworkXMLOptionPtr
|
virNetworkXMLOptionPtr
|
||||||
virNetworkXMLOptionNew(void)
|
virNetworkXMLOptionNew(virNetworkXMLNamespacePtr xmlns)
|
||||||
{
|
{
|
||||||
virNetworkXMLOptionPtr xmlopt;
|
virNetworkXMLOptionPtr xmlopt;
|
||||||
|
|
||||||
@ -103,6 +103,9 @@ virNetworkXMLOptionNew(void)
|
|||||||
if (!(xmlopt = virObjectNew(virNetworkXMLOptionClass)))
|
if (!(xmlopt = virObjectNew(virNetworkXMLOptionClass)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if (xmlns)
|
||||||
|
xmlopt->ns = *xmlns;
|
||||||
|
|
||||||
return xmlopt;
|
return xmlopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,6 +271,8 @@ virNetworkDefFree(virNetworkDefPtr def)
|
|||||||
|
|
||||||
xmlFreeNode(def->metadata);
|
xmlFreeNode(def->metadata);
|
||||||
|
|
||||||
|
if (def->namespaceData && def->ns.free)
|
||||||
|
(def->ns.free)(def->namespaceData);
|
||||||
VIR_FREE(def);
|
VIR_FREE(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1622,7 +1627,7 @@ virNetworkForwardDefParseXML(const char *networkName,
|
|||||||
|
|
||||||
virNetworkDefPtr
|
virNetworkDefPtr
|
||||||
virNetworkDefParseXML(xmlXPathContextPtr ctxt,
|
virNetworkDefParseXML(xmlXPathContextPtr ctxt,
|
||||||
virNetworkXMLOptionPtr xmlopt ATTRIBUTE_UNUSED)
|
virNetworkXMLOptionPtr xmlopt)
|
||||||
{
|
{
|
||||||
virNetworkDefPtr def;
|
virNetworkDefPtr def;
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
@ -2043,6 +2048,12 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt,
|
|||||||
virXMLNodeSanitizeNamespaces(def->metadata);
|
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;
|
ctxt->node = save;
|
||||||
return def;
|
return def;
|
||||||
|
|
||||||
@ -2422,6 +2433,8 @@ virNetworkDefFormatBuf(virBufferPtr buf,
|
|||||||
bool hasbridge = false;
|
bool hasbridge = false;
|
||||||
|
|
||||||
virBufferAddLit(buf, "<network");
|
virBufferAddLit(buf, "<network");
|
||||||
|
if (def->namespaceData && def->ns.href)
|
||||||
|
virBufferAsprintf(buf, " %s", (def->ns.href)());
|
||||||
if (!(flags & VIR_NETWORK_XML_INACTIVE) && (def->connections > 0))
|
if (!(flags & VIR_NETWORK_XML_INACTIVE) && (def->connections > 0))
|
||||||
virBufferAsprintf(buf, " connections='%d'", def->connections);
|
virBufferAsprintf(buf, " connections='%d'", def->connections);
|
||||||
if (def->ipv6nogw)
|
if (def->ipv6nogw)
|
||||||
@ -2627,6 +2640,11 @@ virNetworkDefFormatBuf(virBufferPtr buf,
|
|||||||
if (virPortGroupDefFormat(buf, &def->portGroups[i]) < 0)
|
if (virPortGroupDefFormat(buf, &def->portGroups[i]) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
if (def->namespaceData && def->ns.format) {
|
||||||
|
if ((def->ns.format)(buf, def->namespaceData) < 0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
virBufferAdjustIndent(buf, -2);
|
virBufferAdjustIndent(buf, -2);
|
||||||
virBufferAddLit(buf, "</network>\n");
|
virBufferAddLit(buf, "</network>\n");
|
||||||
|
|
||||||
|
@ -41,9 +41,24 @@
|
|||||||
#include "virmacmap.h"
|
#include "virmacmap.h"
|
||||||
#include "virenum.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 {
|
struct _virNetworkXMLOption {
|
||||||
virObject parent;
|
virObject parent;
|
||||||
|
|
||||||
|
virNetworkXMLNamespace ns;
|
||||||
};
|
};
|
||||||
typedef struct _virNetworkXMLOption virNetworkXMLOption;
|
typedef struct _virNetworkXMLOption virNetworkXMLOption;
|
||||||
typedef virNetworkXMLOption *virNetworkXMLOptionPtr;
|
typedef virNetworkXMLOption *virNetworkXMLOptionPtr;
|
||||||
@ -277,6 +292,10 @@ struct _virNetworkDef {
|
|||||||
|
|
||||||
/* Application-specific custom metadata */
|
/* Application-specific custom metadata */
|
||||||
xmlNodePtr metadata;
|
xmlNodePtr metadata;
|
||||||
|
|
||||||
|
/* Network specific XML namespace data */
|
||||||
|
void *namespaceData;
|
||||||
|
virNetworkXMLNamespace ns;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -298,7 +317,7 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
virNetworkXMLOptionPtr
|
virNetworkXMLOptionPtr
|
||||||
virNetworkXMLOptionNew(void);
|
virNetworkXMLOptionNew(virNetworkXMLNamespacePtr xmlns);
|
||||||
|
|
||||||
virNetworkDefPtr
|
virNetworkDefPtr
|
||||||
virNetworkDefCopy(virNetworkDefPtr def,
|
virNetworkDefCopy(virNetworkDefPtr def,
|
||||||
|
@ -139,7 +139,7 @@ networkDnsmasqCapsRefresh(virNetworkDriverStatePtr driver)
|
|||||||
static virNetworkXMLOptionPtr
|
static virNetworkXMLOptionPtr
|
||||||
networkDnsmasqCreateXMLConf(void)
|
networkDnsmasqCreateXMLConf(void)
|
||||||
{
|
{
|
||||||
return virNetworkXMLOptionNew();
|
return virNetworkXMLOptionNew(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user