提交 8911d843 编写于 作者: C Cole Robinson

conf: Add network xmlopt argument

Pass an xmlopt argument through all the needed network conf
functions, like is done for domain XML handling. No functional
change for now
Reviewed-by: NLaine Stump <laine@laine.org>
Signed-off-by: NCole Robinson <crobinso@redhat.com>
上级 dc2c4f84
...@@ -30936,7 +30936,7 @@ virDomainNetResolveActualType(virDomainNetDefPtr iface) ...@@ -30936,7 +30936,7 @@ virDomainNetResolveActualType(virDomainNetDefPtr iface)
if (!(xml = virNetworkGetXMLDesc(net, 0))) if (!(xml = virNetworkGetXMLDesc(net, 0)))
goto cleanup; goto cleanup;
if (!(def = virNetworkDefParseString(xml))) if (!(def = virNetworkDefParseString(xml, NULL)))
goto cleanup; goto cleanup;
switch ((virNetworkForwardType) def->forward.type) { switch ((virNetworkForwardType) def->forward.type) {
......
...@@ -282,7 +282,9 @@ virNetworkDefFree(virNetworkDefPtr def) ...@@ -282,7 +282,9 @@ virNetworkDefFree(virNetworkDefPtr def)
* Returns a new NetworkDef on success, or NULL on failure. * Returns a new NetworkDef on success, or NULL on failure.
*/ */
virNetworkDefPtr virNetworkDefPtr
virNetworkDefCopy(virNetworkDefPtr def, unsigned int flags) virNetworkDefCopy(virNetworkDefPtr def,
virNetworkXMLOptionPtr xmlopt,
unsigned int flags)
{ {
char *xml = NULL; char *xml = NULL;
virNetworkDefPtr newDef = NULL; virNetworkDefPtr newDef = NULL;
...@@ -294,9 +296,9 @@ virNetworkDefCopy(virNetworkDefPtr def, unsigned int flags) ...@@ -294,9 +296,9 @@ virNetworkDefCopy(virNetworkDefPtr def, unsigned int flags)
} }
/* deep copy with a format/parse cycle */ /* deep copy with a format/parse cycle */
if (!(xml = virNetworkDefFormat(def, flags))) if (!(xml = virNetworkDefFormat(def, xmlopt, flags)))
goto cleanup; goto cleanup;
newDef = virNetworkDefParseString(xml); newDef = virNetworkDefParseString(xml, xmlopt);
cleanup: cleanup:
VIR_FREE(xml); VIR_FREE(xml);
return newDef; return newDef;
...@@ -1619,7 +1621,8 @@ virNetworkForwardDefParseXML(const char *networkName, ...@@ -1619,7 +1621,8 @@ virNetworkForwardDefParseXML(const char *networkName,
virNetworkDefPtr virNetworkDefPtr
virNetworkDefParseXML(xmlXPathContextPtr ctxt) virNetworkDefParseXML(xmlXPathContextPtr ctxt,
virNetworkXMLOptionPtr xmlopt ATTRIBUTE_UNUSED)
{ {
virNetworkDefPtr def; virNetworkDefPtr def;
char *tmp = NULL; char *tmp = NULL;
...@@ -2059,14 +2062,15 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt) ...@@ -2059,14 +2062,15 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
static virNetworkDefPtr static virNetworkDefPtr
virNetworkDefParse(const char *xmlStr, virNetworkDefParse(const char *xmlStr,
const char *filename) const char *filename,
virNetworkXMLOptionPtr xmlopt)
{ {
xmlDocPtr xml; xmlDocPtr xml;
virNetworkDefPtr def = NULL; virNetworkDefPtr def = NULL;
int keepBlanksDefault = xmlKeepBlanksDefault(0); int keepBlanksDefault = xmlKeepBlanksDefault(0);
if ((xml = virXMLParse(filename, xmlStr, _("(network_definition)")))) { if ((xml = virXMLParse(filename, xmlStr, _("(network_definition)")))) {
def = virNetworkDefParseNode(xml, xmlDocGetRootElement(xml)); def = virNetworkDefParseNode(xml, xmlDocGetRootElement(xml), xmlopt);
xmlFreeDoc(xml); xmlFreeDoc(xml);
} }
...@@ -2076,22 +2080,25 @@ virNetworkDefParse(const char *xmlStr, ...@@ -2076,22 +2080,25 @@ virNetworkDefParse(const char *xmlStr,
virNetworkDefPtr virNetworkDefPtr
virNetworkDefParseString(const char *xmlStr) virNetworkDefParseString(const char *xmlStr,
virNetworkXMLOptionPtr xmlopt)
{ {
return virNetworkDefParse(xmlStr, NULL); return virNetworkDefParse(xmlStr, NULL, xmlopt);
} }
virNetworkDefPtr virNetworkDefPtr
virNetworkDefParseFile(const char *filename) virNetworkDefParseFile(const char *filename,
virNetworkXMLOptionPtr xmlopt)
{ {
return virNetworkDefParse(NULL, filename); return virNetworkDefParse(NULL, filename, xmlopt);
} }
virNetworkDefPtr virNetworkDefPtr
virNetworkDefParseNode(xmlDocPtr xml, virNetworkDefParseNode(xmlDocPtr xml,
xmlNodePtr root) xmlNodePtr root,
virNetworkXMLOptionPtr xmlopt)
{ {
xmlXPathContextPtr ctxt = NULL; xmlXPathContextPtr ctxt = NULL;
virNetworkDefPtr def = NULL; virNetworkDefPtr def = NULL;
...@@ -2111,7 +2118,7 @@ virNetworkDefParseNode(xmlDocPtr xml, ...@@ -2111,7 +2118,7 @@ virNetworkDefParseNode(xmlDocPtr xml,
} }
ctxt->node = root; ctxt->node = root;
def = virNetworkDefParseXML(ctxt); def = virNetworkDefParseXML(ctxt, xmlopt);
cleanup: cleanup:
xmlXPathFreeContext(ctxt); xmlXPathFreeContext(ctxt);
...@@ -2405,6 +2412,7 @@ virNetworkForwardNatDefFormat(virBufferPtr buf, ...@@ -2405,6 +2412,7 @@ virNetworkForwardNatDefFormat(virBufferPtr buf,
int int
virNetworkDefFormatBuf(virBufferPtr buf, virNetworkDefFormatBuf(virBufferPtr buf,
const virNetworkDef *def, const virNetworkDef *def,
virNetworkXMLOptionPtr xmlopt ATTRIBUTE_UNUSED,
unsigned int flags) unsigned int flags)
{ {
const unsigned char *uuid; const unsigned char *uuid;
...@@ -2631,11 +2639,12 @@ virNetworkDefFormatBuf(virBufferPtr buf, ...@@ -2631,11 +2639,12 @@ virNetworkDefFormatBuf(virBufferPtr buf,
char * char *
virNetworkDefFormat(const virNetworkDef *def, virNetworkDefFormat(const virNetworkDef *def,
virNetworkXMLOptionPtr xmlopt,
unsigned int flags) unsigned int flags)
{ {
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
if (virNetworkDefFormatBuf(&buf, def, flags) < 0) if (virNetworkDefFormatBuf(&buf, def, xmlopt, flags) < 0)
goto error; goto error;
if (virBufferCheckError(&buf) < 0) if (virBufferCheckError(&buf) < 0)
...@@ -2709,12 +2718,13 @@ virNetworkSaveXML(const char *configDir, ...@@ -2709,12 +2718,13 @@ virNetworkSaveXML(const char *configDir,
int int
virNetworkSaveConfig(const char *configDir, virNetworkSaveConfig(const char *configDir,
virNetworkDefPtr def) virNetworkDefPtr def,
virNetworkXMLOptionPtr xmlopt)
{ {
int ret = -1; int ret = -1;
char *xml; char *xml;
if (!(xml = virNetworkDefFormat(def, VIR_NETWORK_XML_INACTIVE))) if (!(xml = virNetworkDefFormat(def, xmlopt, VIR_NETWORK_XML_INACTIVE)))
goto cleanup; goto cleanup;
if (virNetworkSaveXML(configDir, def, xml)) if (virNetworkSaveXML(configDir, def, xml))
......
...@@ -301,28 +301,36 @@ virNetworkXMLOptionPtr ...@@ -301,28 +301,36 @@ virNetworkXMLOptionPtr
virNetworkXMLOptionNew(void); virNetworkXMLOptionNew(void);
virNetworkDefPtr virNetworkDefPtr
virNetworkDefCopy(virNetworkDefPtr def, unsigned int flags); virNetworkDefCopy(virNetworkDefPtr def,
virNetworkXMLOptionPtr xmlopt,
unsigned int flags);
virNetworkDefPtr virNetworkDefPtr
virNetworkDefParseXML(xmlXPathContextPtr ctxt); virNetworkDefParseXML(xmlXPathContextPtr ctxt,
virNetworkXMLOptionPtr xmlopt);
virNetworkDefPtr virNetworkDefPtr
virNetworkDefParseString(const char *xmlStr); virNetworkDefParseString(const char *xmlStr,
virNetworkXMLOptionPtr xmlopt);
virNetworkDefPtr virNetworkDefPtr
virNetworkDefParseFile(const char *filename); virNetworkDefParseFile(const char *filename,
virNetworkXMLOptionPtr xmlopt);
virNetworkDefPtr virNetworkDefPtr
virNetworkDefParseNode(xmlDocPtr xml, virNetworkDefParseNode(xmlDocPtr xml,
xmlNodePtr root); xmlNodePtr root,
virNetworkXMLOptionPtr xmlopt);
char * char *
virNetworkDefFormat(const virNetworkDef *def, virNetworkDefFormat(const virNetworkDef *def,
virNetworkXMLOptionPtr xmlopt,
unsigned int flags); unsigned int flags);
int int
virNetworkDefFormatBuf(virBufferPtr buf, virNetworkDefFormatBuf(virBufferPtr buf,
const virNetworkDef *def, const virNetworkDef *def,
virNetworkXMLOptionPtr xmlopt,
unsigned int flags); unsigned int flags);
const char * const char *
...@@ -357,7 +365,8 @@ virNetworkSaveXML(const char *configDir, ...@@ -357,7 +365,8 @@ virNetworkSaveXML(const char *configDir,
int int
virNetworkSaveConfig(const char *configDir, virNetworkSaveConfig(const char *configDir,
virNetworkDefPtr def); virNetworkDefPtr def,
virNetworkXMLOptionPtr xmlopt);
char * char *
virNetworkConfigFile(const char *dir, virNetworkConfigFile(const char *dir,
......
...@@ -673,7 +673,8 @@ virNetworkObjAssignDef(virNetworkObjListPtr nets, ...@@ -673,7 +673,8 @@ virNetworkObjAssignDef(virNetworkObjListPtr nets,
*/ */
int int
virNetworkObjSetDefTransient(virNetworkObjPtr obj, virNetworkObjSetDefTransient(virNetworkObjPtr obj,
bool live) bool live,
virNetworkXMLOptionPtr xmlopt)
{ {
if (!virNetworkObjIsActive(obj) && !live) if (!virNetworkObjIsActive(obj) && !live)
return 0; return 0;
...@@ -681,7 +682,9 @@ virNetworkObjSetDefTransient(virNetworkObjPtr obj, ...@@ -681,7 +682,9 @@ virNetworkObjSetDefTransient(virNetworkObjPtr obj,
if (!obj->persistent || obj->newDef) if (!obj->persistent || obj->newDef)
return 0; return 0;
obj->newDef = virNetworkDefCopy(obj->def, VIR_NETWORK_XML_INACTIVE); obj->newDef = virNetworkDefCopy(obj->def,
xmlopt,
VIR_NETWORK_XML_INACTIVE);
return obj->newDef ? 0 : -1; return obj->newDef ? 0 : -1;
} }
...@@ -759,6 +762,7 @@ virNetworkObjReplacePersistentDef(virNetworkObjPtr obj, ...@@ -759,6 +762,7 @@ virNetworkObjReplacePersistentDef(virNetworkObjPtr obj,
*/ */
static int static int
virNetworkObjConfigChangeSetup(virNetworkObjPtr obj, virNetworkObjConfigChangeSetup(virNetworkObjPtr obj,
virNetworkXMLOptionPtr xmlopt,
unsigned int flags) unsigned int flags)
{ {
bool isActive; bool isActive;
...@@ -782,7 +786,7 @@ virNetworkObjConfigChangeSetup(virNetworkObjPtr obj, ...@@ -782,7 +786,7 @@ virNetworkObjConfigChangeSetup(virNetworkObjPtr obj,
/* this should already have been done by the driver, but do it /* this should already have been done by the driver, but do it
* anyway just in case. * anyway just in case.
*/ */
if (isActive && (virNetworkObjSetDefTransient(obj, false) < 0)) if (isActive && (virNetworkObjSetDefTransient(obj, false, xmlopt) < 0))
goto cleanup; goto cleanup;
} }
...@@ -811,6 +815,7 @@ virNetworkObjRemoveInactive(virNetworkObjListPtr nets, ...@@ -811,6 +815,7 @@ virNetworkObjRemoveInactive(virNetworkObjListPtr nets,
static char * static char *
virNetworkObjFormat(virNetworkObjPtr obj, virNetworkObjFormat(virNetworkObjPtr obj,
virNetworkXMLOptionPtr xmlopt,
unsigned int flags) unsigned int flags)
{ {
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
...@@ -832,7 +837,7 @@ virNetworkObjFormat(virNetworkObjPtr obj, ...@@ -832,7 +837,7 @@ virNetworkObjFormat(virNetworkObjPtr obj,
virNetworkTaintTypeToString(i)); virNetworkTaintTypeToString(i));
} }
if (virNetworkDefFormatBuf(&buf, obj->def, flags) < 0) if (virNetworkDefFormatBuf(&buf, obj->def, xmlopt, flags) < 0)
goto error; goto error;
virBufferAdjustIndent(&buf, -2); virBufferAdjustIndent(&buf, -2);
...@@ -851,13 +856,14 @@ virNetworkObjFormat(virNetworkObjPtr obj, ...@@ -851,13 +856,14 @@ virNetworkObjFormat(virNetworkObjPtr obj,
int int
virNetworkObjSaveStatus(const char *statusDir, virNetworkObjSaveStatus(const char *statusDir,
virNetworkObjPtr obj) virNetworkObjPtr obj,
virNetworkXMLOptionPtr xmlopt)
{ {
int ret = -1; int ret = -1;
int flags = 0; int flags = 0;
char *xml; char *xml;
if (!(xml = virNetworkObjFormat(obj, flags))) if (!(xml = virNetworkObjFormat(obj, xmlopt, flags)))
goto cleanup; goto cleanup;
if (virNetworkSaveXML(statusDir, obj->def, xml)) if (virNetworkSaveXML(statusDir, obj->def, xml))
...@@ -873,7 +879,8 @@ virNetworkObjSaveStatus(const char *statusDir, ...@@ -873,7 +879,8 @@ virNetworkObjSaveStatus(const char *statusDir,
static virNetworkObjPtr static virNetworkObjPtr
virNetworkLoadState(virNetworkObjListPtr nets, virNetworkLoadState(virNetworkObjListPtr nets,
const char *stateDir, const char *stateDir,
const char *name) const char *name,
virNetworkXMLOptionPtr xmlopt)
{ {
char *configFile = NULL; char *configFile = NULL;
virNetworkDefPtr def = NULL; virNetworkDefPtr def = NULL;
...@@ -902,7 +909,7 @@ virNetworkLoadState(virNetworkObjListPtr nets, ...@@ -902,7 +909,7 @@ virNetworkLoadState(virNetworkObjListPtr nets,
/* parse the definition first */ /* parse the definition first */
ctxt->node = node; ctxt->node = node;
if (!(def = virNetworkDefParseXML(ctxt))) if (!(def = virNetworkDefParseXML(ctxt, xmlopt)))
goto error; goto error;
if (STRNEQ(name, def->name)) { if (STRNEQ(name, def->name)) {
...@@ -1000,7 +1007,8 @@ static virNetworkObjPtr ...@@ -1000,7 +1007,8 @@ static virNetworkObjPtr
virNetworkLoadConfig(virNetworkObjListPtr nets, virNetworkLoadConfig(virNetworkObjListPtr nets,
const char *configDir, const char *configDir,
const char *autostartDir, const char *autostartDir,
const char *name) const char *name,
virNetworkXMLOptionPtr xmlopt)
{ {
char *configFile = NULL, *autostartLink = NULL; char *configFile = NULL, *autostartLink = NULL;
virNetworkDefPtr def = NULL; virNetworkDefPtr def = NULL;
...@@ -1015,7 +1023,7 @@ virNetworkLoadConfig(virNetworkObjListPtr nets, ...@@ -1015,7 +1023,7 @@ virNetworkLoadConfig(virNetworkObjListPtr nets,
if ((autostart = virFileLinkPointsTo(autostartLink, configFile)) < 0) if ((autostart = virFileLinkPointsTo(autostartLink, configFile)) < 0)
goto error; goto error;
if (!(def = virNetworkDefParseFile(configFile))) if (!(def = virNetworkDefParseFile(configFile, xmlopt)))
goto error; goto error;
if (STRNEQ(name, def->name)) { if (STRNEQ(name, def->name)) {
...@@ -1033,7 +1041,7 @@ virNetworkLoadConfig(virNetworkObjListPtr nets, ...@@ -1033,7 +1041,7 @@ virNetworkLoadConfig(virNetworkObjListPtr nets,
case VIR_NETWORK_FORWARD_OPEN: case VIR_NETWORK_FORWARD_OPEN:
if (!def->mac_specified) { if (!def->mac_specified) {
virNetworkSetBridgeMacAddr(def); virNetworkSetBridgeMacAddr(def);
virNetworkSaveConfig(configDir, def); virNetworkSaveConfig(configDir, def, xmlopt);
} }
break; break;
...@@ -1073,7 +1081,8 @@ virNetworkLoadConfig(virNetworkObjListPtr nets, ...@@ -1073,7 +1081,8 @@ virNetworkLoadConfig(virNetworkObjListPtr nets,
int int
virNetworkObjLoadAllState(virNetworkObjListPtr nets, virNetworkObjLoadAllState(virNetworkObjListPtr nets,
const char *stateDir) const char *stateDir,
virNetworkXMLOptionPtr xmlopt)
{ {
DIR *dir; DIR *dir;
struct dirent *entry; struct dirent *entry;
...@@ -1089,7 +1098,7 @@ virNetworkObjLoadAllState(virNetworkObjListPtr nets, ...@@ -1089,7 +1098,7 @@ virNetworkObjLoadAllState(virNetworkObjListPtr nets,
if (!virStringStripSuffix(entry->d_name, ".xml")) if (!virStringStripSuffix(entry->d_name, ".xml"))
continue; continue;
obj = virNetworkLoadState(nets, stateDir, entry->d_name); obj = virNetworkLoadState(nets, stateDir, entry->d_name, xmlopt);
if (obj && if (obj &&
virNetworkObjLoadAllPorts(obj, stateDir) < 0) { virNetworkObjLoadAllPorts(obj, stateDir) < 0) {
...@@ -1108,7 +1117,8 @@ virNetworkObjLoadAllState(virNetworkObjListPtr nets, ...@@ -1108,7 +1117,8 @@ virNetworkObjLoadAllState(virNetworkObjListPtr nets,
int int
virNetworkObjLoadAllConfigs(virNetworkObjListPtr nets, virNetworkObjLoadAllConfigs(virNetworkObjListPtr nets,
const char *configDir, const char *configDir,
const char *autostartDir) const char *autostartDir,
virNetworkXMLOptionPtr xmlopt)
{ {
DIR *dir; DIR *dir;
struct dirent *entry; struct dirent *entry;
...@@ -1129,7 +1139,8 @@ virNetworkObjLoadAllConfigs(virNetworkObjListPtr nets, ...@@ -1129,7 +1139,8 @@ virNetworkObjLoadAllConfigs(virNetworkObjListPtr nets,
obj = virNetworkLoadConfig(nets, obj = virNetworkLoadConfig(nets,
configDir, configDir,
autostartDir, autostartDir,
entry->d_name); entry->d_name,
xmlopt);
virNetworkObjEndAPI(&obj); virNetworkObjEndAPI(&obj);
} }
...@@ -1239,20 +1250,21 @@ virNetworkObjUpdate(virNetworkObjPtr obj, ...@@ -1239,20 +1250,21 @@ virNetworkObjUpdate(virNetworkObjPtr obj,
unsigned int section, /* virNetworkUpdateSection */ unsigned int section, /* virNetworkUpdateSection */
int parentIndex, int parentIndex,
const char *xml, const char *xml,
virNetworkXMLOptionPtr xmlopt,
unsigned int flags) /* virNetworkUpdateFlags */ unsigned int flags) /* virNetworkUpdateFlags */
{ {
int ret = -1; int ret = -1;
virNetworkDefPtr livedef = NULL, configdef = NULL; virNetworkDefPtr livedef = NULL, configdef = NULL;
/* normalize config data, and check for common invalid requests. */ /* normalize config data, and check for common invalid requests. */
if (virNetworkObjConfigChangeSetup(obj, flags) < 0) if (virNetworkObjConfigChangeSetup(obj, xmlopt, flags) < 0)
goto cleanup; goto cleanup;
if (flags & VIR_NETWORK_UPDATE_AFFECT_LIVE) { if (flags & VIR_NETWORK_UPDATE_AFFECT_LIVE) {
virNetworkDefPtr checkdef; virNetworkDefPtr checkdef;
/* work on a copy of the def */ /* work on a copy of the def */
if (!(livedef = virNetworkDefCopy(obj->def, 0))) if (!(livedef = virNetworkDefCopy(obj->def, xmlopt, 0)))
goto cleanup; goto cleanup;
if (virNetworkDefUpdateSection(livedef, command, section, if (virNetworkDefUpdateSection(livedef, command, section,
parentIndex, xml, flags) < 0) { parentIndex, xml, flags) < 0) {
...@@ -1261,7 +1273,7 @@ virNetworkObjUpdate(virNetworkObjPtr obj, ...@@ -1261,7 +1273,7 @@ virNetworkObjUpdate(virNetworkObjPtr obj,
/* run a final format/parse cycle to make sure we didn't /* run a final format/parse cycle to make sure we didn't
* add anything illegal to the def * add anything illegal to the def
*/ */
if (!(checkdef = virNetworkDefCopy(livedef, 0))) if (!(checkdef = virNetworkDefCopy(livedef, xmlopt, 0)))
goto cleanup; goto cleanup;
virNetworkDefFree(checkdef); virNetworkDefFree(checkdef);
} }
...@@ -1271,6 +1283,7 @@ virNetworkObjUpdate(virNetworkObjPtr obj, ...@@ -1271,6 +1283,7 @@ virNetworkObjUpdate(virNetworkObjPtr obj,
/* work on a copy of the def */ /* work on a copy of the def */
if (!(configdef = virNetworkDefCopy(virNetworkObjGetPersistentDef(obj), if (!(configdef = virNetworkDefCopy(virNetworkObjGetPersistentDef(obj),
xmlopt,
VIR_NETWORK_XML_INACTIVE))) { VIR_NETWORK_XML_INACTIVE))) {
goto cleanup; goto cleanup;
} }
...@@ -1279,6 +1292,7 @@ virNetworkObjUpdate(virNetworkObjPtr obj, ...@@ -1279,6 +1292,7 @@ virNetworkObjUpdate(virNetworkObjPtr obj,
goto cleanup; goto cleanup;
} }
if (!(checkdef = virNetworkDefCopy(configdef, if (!(checkdef = virNetworkDefCopy(configdef,
xmlopt,
VIR_NETWORK_XML_INACTIVE))) { VIR_NETWORK_XML_INACTIVE))) {
goto cleanup; goto cleanup;
} }
......
...@@ -140,7 +140,8 @@ virNetworkObjUpdateAssignDef(virNetworkObjPtr network, ...@@ -140,7 +140,8 @@ virNetworkObjUpdateAssignDef(virNetworkObjPtr network,
int int
virNetworkObjSetDefTransient(virNetworkObjPtr network, virNetworkObjSetDefTransient(virNetworkObjPtr network,
bool live); bool live,
virNetworkXMLOptionPtr xmlopt);
void void
virNetworkObjUnsetDefTransient(virNetworkObjPtr network); virNetworkObjUnsetDefTransient(virNetworkObjPtr network);
...@@ -191,16 +192,19 @@ virNetworkObjPortListExport(virNetworkPtr net, ...@@ -191,16 +192,19 @@ virNetworkObjPortListExport(virNetworkPtr net,
int int
virNetworkObjSaveStatus(const char *statusDir, virNetworkObjSaveStatus(const char *statusDir,
virNetworkObjPtr net) ATTRIBUTE_RETURN_CHECK; virNetworkObjPtr net,
virNetworkXMLOptionPtr xmlopt) ATTRIBUTE_RETURN_CHECK;
int int
virNetworkObjLoadAllConfigs(virNetworkObjListPtr nets, virNetworkObjLoadAllConfigs(virNetworkObjListPtr nets,
const char *configDir, const char *configDir,
const char *autostartDir); const char *autostartDir,
virNetworkXMLOptionPtr xmlopt);
int int
virNetworkObjLoadAllState(virNetworkObjListPtr nets, virNetworkObjLoadAllState(virNetworkObjListPtr nets,
const char *stateDir); const char *stateDir,
virNetworkXMLOptionPtr xmlopt);
int int
virNetworkObjDeleteConfig(const char *configDir, virNetworkObjDeleteConfig(const char *configDir,
...@@ -218,6 +222,7 @@ virNetworkObjUpdate(virNetworkObjPtr obj, ...@@ -218,6 +222,7 @@ virNetworkObjUpdate(virNetworkObjPtr obj,
unsigned int section, /* virNetworkUpdateSection */ unsigned int section, /* virNetworkUpdateSection */
int parentIndex, int parentIndex,
const char *xml, const char *xml,
virNetworkXMLOptionPtr xmlopt,
unsigned int flags); /* virNetworkUpdateFlags */ unsigned int flags); /* virNetworkUpdateFlags */
int int
......
...@@ -298,7 +298,7 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml) ...@@ -298,7 +298,7 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
return NULL; return NULL;
/* Parse network XML */ /* Parse network XML */
def = virNetworkDefParseString(xml); def = virNetworkDefParseString(xml, NULL);
if (!def) if (!def)
return NULL; return NULL;
...@@ -806,7 +806,7 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags) ...@@ -806,7 +806,7 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags)
} }
} }
xml = virNetworkDefFormat(def, flags); xml = virNetworkDefFormat(def, NULL, flags);
cleanup: cleanup:
esxVI_HostVirtualSwitch_Free(&hostVirtualSwitch); esxVI_HostVirtualSwitch_Free(&hostVirtualSwitch);
......
...@@ -231,7 +231,7 @@ networkRunHook(virNetworkObjPtr obj, ...@@ -231,7 +231,7 @@ networkRunHook(virNetworkObjPtr obj,
virBufferAddLit(&buf, "<hookData>\n"); virBufferAddLit(&buf, "<hookData>\n");
virBufferAdjustIndent(&buf, 2); virBufferAdjustIndent(&buf, 2);
if (virNetworkDefFormatBuf(&buf, def, 0) < 0) if (virNetworkDefFormatBuf(&buf, def, network_driver->xmlopt, 0) < 0)
goto cleanup; goto cleanup;
if (port && virNetworkPortDefFormatBuf(&buf, port) < 0) if (port && virNetworkPortDefFormatBuf(&buf, port) < 0)
goto cleanup; goto cleanup;
...@@ -673,12 +673,14 @@ networkStateInitialize(bool privileged, ...@@ -673,12 +673,14 @@ networkStateInitialize(bool privileged,
goto error; goto error;
if (virNetworkObjLoadAllState(network_driver->networks, if (virNetworkObjLoadAllState(network_driver->networks,
network_driver->stateDir) < 0) network_driver->stateDir,
network_driver->xmlopt) < 0)
goto error; goto error;
if (virNetworkObjLoadAllConfigs(network_driver->networks, if (virNetworkObjLoadAllConfigs(network_driver->networks,
network_driver->networkConfigDir, network_driver->networkConfigDir,
network_driver->networkAutostartDir) < 0) network_driver->networkAutostartDir,
network_driver->xmlopt) < 0)
goto error; goto error;
/* Update the internal status of all allegedly active /* Update the internal status of all allegedly active
...@@ -750,10 +752,12 @@ networkStateReload(void) ...@@ -750,10 +752,12 @@ networkStateReload(void)
return 0; return 0;
virNetworkObjLoadAllState(network_driver->networks, virNetworkObjLoadAllState(network_driver->networks,
network_driver->stateDir); network_driver->stateDir,
network_driver->xmlopt);
virNetworkObjLoadAllConfigs(network_driver->networks, virNetworkObjLoadAllConfigs(network_driver->networks,
network_driver->networkConfigDir, network_driver->networkConfigDir,
network_driver->networkAutostartDir); network_driver->networkAutostartDir,
network_driver->xmlopt);
networkReloadFirewallRules(network_driver, false); networkReloadFirewallRules(network_driver, false);
networkRefreshDaemons(network_driver); networkRefreshDaemons(network_driver);
virNetworkObjListForEach(network_driver->networks, virNetworkObjListForEach(network_driver->networks,
...@@ -2789,7 +2793,7 @@ networkStartNetwork(virNetworkDriverStatePtr driver, ...@@ -2789,7 +2793,7 @@ networkStartNetwork(virNetworkDriverStatePtr driver,
virNetworkObjDeleteAllPorts(obj, driver->stateDir); virNetworkObjDeleteAllPorts(obj, driver->stateDir);
VIR_DEBUG("Setting current network def as transient"); VIR_DEBUG("Setting current network def as transient");
if (virNetworkObjSetDefTransient(obj, true) < 0) if (virNetworkObjSetDefTransient(obj, true, network_driver->xmlopt) < 0)
goto cleanup; goto cleanup;
/* Run an early hook to set-up missing devices. /* Run an early hook to set-up missing devices.
...@@ -2847,7 +2851,8 @@ networkStartNetwork(virNetworkDriverStatePtr driver, ...@@ -2847,7 +2851,8 @@ networkStartNetwork(virNetworkDriverStatePtr driver,
* is setup. * is setup.
*/ */
VIR_DEBUG("Writing network status to disk"); VIR_DEBUG("Writing network status to disk");
if (virNetworkObjSaveStatus(driver->stateDir, obj) < 0) if (virNetworkObjSaveStatus(driver->stateDir,
obj, network_driver->xmlopt) < 0)
goto cleanup; goto cleanup;
virNetworkObjSetActive(obj, true); virNetworkObjSetActive(obj, true);
...@@ -3563,7 +3568,7 @@ networkCreateXML(virConnectPtr conn, ...@@ -3563,7 +3568,7 @@ networkCreateXML(virConnectPtr conn,
virNetworkPtr net = NULL; virNetworkPtr net = NULL;
virObjectEventPtr event = NULL; virObjectEventPtr event = NULL;
if (!(newDef = virNetworkDefParseString(xml))) if (!(newDef = virNetworkDefParseString(xml, network_driver->xmlopt)))
goto cleanup; goto cleanup;
if (virNetworkCreateXMLEnsureACL(conn, newDef) < 0) if (virNetworkCreateXMLEnsureACL(conn, newDef) < 0)
...@@ -3615,7 +3620,7 @@ networkDefineXML(virConnectPtr conn, ...@@ -3615,7 +3620,7 @@ networkDefineXML(virConnectPtr conn,
virNetworkPtr net = NULL; virNetworkPtr net = NULL;
virObjectEventPtr event = NULL; virObjectEventPtr event = NULL;
if (!(def = virNetworkDefParseString(xml))) if (!(def = virNetworkDefParseString(xml, network_driver->xmlopt)))
goto cleanup; goto cleanup;
if (virNetworkDefineXMLEnsureACL(conn, def) < 0) if (virNetworkDefineXMLEnsureACL(conn, def) < 0)
...@@ -3630,7 +3635,8 @@ networkDefineXML(virConnectPtr conn, ...@@ -3630,7 +3635,8 @@ networkDefineXML(virConnectPtr conn,
/* def was assigned to network object */ /* def was assigned to network object */
freeDef = false; freeDef = false;
if (virNetworkSaveConfig(driver->networkConfigDir, def) < 0) { if (virNetworkSaveConfig(driver->networkConfigDir,
def, network_driver->xmlopt) < 0) {
if (!virNetworkObjIsActive(obj)) { if (!virNetworkObjIsActive(obj)) {
virNetworkObjRemoveInactive(driver->networks, obj); virNetworkObjRemoveInactive(driver->networks, obj);
goto cleanup; goto cleanup;
...@@ -3811,7 +3817,9 @@ networkUpdate(virNetworkPtr net, ...@@ -3811,7 +3817,9 @@ networkUpdate(virNetworkPtr net,
} }
/* update the network config in memory/on disk */ /* update the network config in memory/on disk */
if (virNetworkObjUpdate(obj, command, section, parentIndex, xml, flags) < 0) { if (virNetworkObjUpdate(obj, command, section,
parentIndex, xml,
network_driver->xmlopt, flags) < 0) {
if (needFirewallRefresh) if (needFirewallRefresh)
ignore_value(networkAddFirewallRules(def)); ignore_value(networkAddFirewallRules(def));
goto cleanup; goto cleanup;
...@@ -3826,7 +3834,8 @@ networkUpdate(virNetworkPtr net, ...@@ -3826,7 +3834,8 @@ networkUpdate(virNetworkPtr net,
if (flags & VIR_NETWORK_UPDATE_AFFECT_CONFIG) { if (flags & VIR_NETWORK_UPDATE_AFFECT_CONFIG) {
/* save updated persistent config to disk */ /* save updated persistent config to disk */
if (virNetworkSaveConfig(driver->networkConfigDir, if (virNetworkSaveConfig(driver->networkConfigDir,
virNetworkObjGetPersistentDef(obj)) < 0) { virNetworkObjGetPersistentDef(obj),
network_driver->xmlopt) < 0) {
goto cleanup; goto cleanup;
} }
} }
...@@ -3893,7 +3902,8 @@ networkUpdate(virNetworkPtr net, ...@@ -3893,7 +3902,8 @@ networkUpdate(virNetworkPtr net,
} }
/* save current network state to disk */ /* save current network state to disk */
if ((ret = virNetworkObjSaveStatus(driver->stateDir, obj)) < 0) if ((ret = virNetworkObjSaveStatus(driver->stateDir,
obj, network_driver->xmlopt)) < 0)
goto cleanup; goto cleanup;
} }
...@@ -4014,7 +4024,7 @@ networkGetXMLDesc(virNetworkPtr net, ...@@ -4014,7 +4024,7 @@ networkGetXMLDesc(virNetworkPtr net,
else else
curDef = def; curDef = def;
ret = virNetworkDefFormat(curDef, flags); ret = virNetworkDefFormat(curDef, network_driver->xmlopt, flags);
cleanup: cleanup:
virNetworkObjEndAPI(&obj); virNetworkObjEndAPI(&obj);
...@@ -5153,7 +5163,7 @@ networkPlugBandwidthImpl(virNetworkObjPtr obj, ...@@ -5153,7 +5163,7 @@ networkPlugBandwidthImpl(virNetworkObjPtr obj,
tmp_floor_sum += ifaceBand->in->floor; tmp_floor_sum += ifaceBand->in->floor;
virNetworkObjSetFloorSum(obj, tmp_floor_sum); virNetworkObjSetFloorSum(obj, tmp_floor_sum);
/* update status file */ /* update status file */
if (virNetworkObjSaveStatus(driver->stateDir, obj) < 0) { if (virNetworkObjSaveStatus(driver->stateDir, obj, network_driver->xmlopt) < 0) {
ignore_value(virBitmapClearBit(classIdMap, next_id)); ignore_value(virBitmapClearBit(classIdMap, next_id));
tmp_floor_sum -= ifaceBand->in->floor; tmp_floor_sum -= ifaceBand->in->floor;
virNetworkObjSetFloorSum(obj, tmp_floor_sum); virNetworkObjSetFloorSum(obj, tmp_floor_sum);
...@@ -5243,7 +5253,8 @@ networkUnplugBandwidth(virNetworkObjPtr obj, ...@@ -5243,7 +5253,8 @@ networkUnplugBandwidth(virNetworkObjPtr obj,
/* return class ID */ /* return class ID */
ignore_value(virBitmapClearBit(classIdMap, *class_id)); ignore_value(virBitmapClearBit(classIdMap, *class_id));
/* update status file */ /* update status file */
if (virNetworkObjSaveStatus(driver->stateDir, obj) < 0) { if (virNetworkObjSaveStatus(driver->stateDir,
obj, network_driver->xmlopt) < 0) {
tmp_floor_sum += ifaceBand->in->floor; tmp_floor_sum += ifaceBand->in->floor;
virNetworkObjSetFloorSum(obj, tmp_floor_sum); virNetworkObjSetFloorSum(obj, tmp_floor_sum);
ignore_value(virBitmapSetBit(classIdMap, *class_id)); ignore_value(virBitmapSetBit(classIdMap, *class_id));
...@@ -5337,7 +5348,8 @@ networkUpdatePortBandwidth(virNetworkObjPtr obj, ...@@ -5337,7 +5348,8 @@ networkUpdatePortBandwidth(virNetworkObjPtr obj,
if (virNetDevBandwidthUpdateRate(def->bridge, 2, if (virNetDevBandwidthUpdateRate(def->bridge, 2,
def->bandwidth, new_rate) < 0 || def->bandwidth, new_rate) < 0 ||
virNetworkObjSaveStatus(driver->stateDir, obj) < 0) { virNetworkObjSaveStatus(driver->stateDir,
obj, network_driver->xmlopt) < 0) {
/* Ouch, rollback */ /* Ouch, rollback */
tmp_floor_sum -= newBandwidth->in->floor; tmp_floor_sum -= newBandwidth->in->floor;
tmp_floor_sum += oldBandwidth->in->floor; tmp_floor_sum += oldBandwidth->in->floor;
......
...@@ -4713,7 +4713,7 @@ qemuProcessGetNetworkAddress(const char *netname, ...@@ -4713,7 +4713,7 @@ qemuProcessGetNetworkAddress(const char *netname,
if (!xml) if (!xml)
goto cleanup; goto cleanup;
netdef = virNetworkDefParseString(xml); netdef = virNetworkDefParseString(xml, NULL);
if (!netdef) if (!netdef)
goto cleanup; goto cleanup;
......
...@@ -971,7 +971,7 @@ testParseNetworks(testDriverPtr privconn, ...@@ -971,7 +971,7 @@ testParseNetworks(testDriverPtr privconn,
if (!node) if (!node)
return -1; return -1;
def = virNetworkDefParseNode(ctxt->doc, node); def = virNetworkDefParseNode(ctxt->doc, node, NULL);
if (!def) if (!def)
return -1; return -1;
...@@ -4257,7 +4257,7 @@ testNetworkCreateXML(virConnectPtr conn, const char *xml) ...@@ -4257,7 +4257,7 @@ testNetworkCreateXML(virConnectPtr conn, const char *xml)
virNetworkPtr net = NULL; virNetworkPtr net = NULL;
virObjectEventPtr event = NULL; virObjectEventPtr event = NULL;
if ((newDef = virNetworkDefParseString(xml)) == NULL) if ((newDef = virNetworkDefParseString(xml, NULL)) == NULL)
goto cleanup; goto cleanup;
if (!(obj = virNetworkObjAssignDef(privconn->networks, newDef, if (!(obj = virNetworkObjAssignDef(privconn->networks, newDef,
...@@ -4293,7 +4293,7 @@ testNetworkDefineXML(virConnectPtr conn, ...@@ -4293,7 +4293,7 @@ testNetworkDefineXML(virConnectPtr conn,
virNetworkPtr net = NULL; virNetworkPtr net = NULL;
virObjectEventPtr event = NULL; virObjectEventPtr event = NULL;
if ((newDef = virNetworkDefParseString(xml)) == NULL) if ((newDef = virNetworkDefParseString(xml, NULL)) == NULL)
goto cleanup; goto cleanup;
if (!(obj = virNetworkObjAssignDef(privconn->networks, newDef, 0))) if (!(obj = virNetworkObjAssignDef(privconn->networks, newDef, 0)))
...@@ -4379,7 +4379,8 @@ testNetworkUpdate(virNetworkPtr net, ...@@ -4379,7 +4379,8 @@ testNetworkUpdate(virNetworkPtr net,
} }
/* update the network config in memory/on disk */ /* update the network config in memory/on disk */
if (virNetworkObjUpdate(obj, command, section, parentIndex, xml, flags) < 0) if (virNetworkObjUpdate(obj, command, section,
parentIndex, xml, NULL, flags) < 0)
goto cleanup; goto cleanup;
ret = 0; ret = 0;
...@@ -4463,7 +4464,7 @@ testNetworkGetXMLDesc(virNetworkPtr net, ...@@ -4463,7 +4464,7 @@ testNetworkGetXMLDesc(virNetworkPtr net,
if (!(obj = testNetworkObjFindByName(privconn, net->name))) if (!(obj = testNetworkObjFindByName(privconn, net->name)))
goto cleanup; goto cleanup;
ret = virNetworkDefFormat(virNetworkObjGetDef(obj), flags); ret = virNetworkDefFormat(virNetworkObjGetDef(obj), NULL, flags);
cleanup: cleanup:
virNetworkObjEndAPI(&obj); virNetworkObjEndAPI(&obj);
......
...@@ -375,7 +375,7 @@ vboxNetworkDefineCreateXML(virConnectPtr conn, const char *xml, bool start) ...@@ -375,7 +375,7 @@ vboxNetworkDefineCreateXML(virConnectPtr conn, const char *xml, bool start)
PRUnichar *networkNameUtf16 = NULL; PRUnichar *networkNameUtf16 = NULL;
char *networkNameUtf8 = NULL; char *networkNameUtf8 = NULL;
IHostNetworkInterface *networkInterface = NULL; IHostNetworkInterface *networkInterface = NULL;
virNetworkDefPtr def = virNetworkDefParseString(xml); virNetworkDefPtr def = virNetworkDefParseString(xml, NULL);
virNetworkIPDefPtr ipdef = NULL; virNetworkIPDefPtr ipdef = NULL;
unsigned char uuid[VIR_UUID_BUFLEN]; unsigned char uuid[VIR_UUID_BUFLEN];
vboxIID vboxnetiid; vboxIID vboxnetiid;
...@@ -911,7 +911,7 @@ static char *vboxNetworkGetXMLDesc(virNetworkPtr network, unsigned int flags) ...@@ -911,7 +911,7 @@ static char *vboxNetworkGetXMLDesc(virNetworkPtr network, unsigned int flags)
} }
DEBUGIID("Network UUID", &vboxnet0IID); DEBUGIID("Network UUID", &vboxnet0IID);
ret = virNetworkDefFormat(def, 0); ret = virNetworkDefFormat(def, NULL, 0);
cleanup: cleanup:
vboxIIDUnalloc(&vboxnet0IID); vboxIIDUnalloc(&vboxnet0IID);
......
...@@ -26,7 +26,7 @@ testCompareXMLToConfFiles(const char *inxml, const char *outconf, dnsmasqCapsPtr ...@@ -26,7 +26,7 @@ testCompareXMLToConfFiles(const char *inxml, const char *outconf, dnsmasqCapsPtr
char *pidfile = NULL; char *pidfile = NULL;
dnsmasqContext *dctx = NULL; dnsmasqContext *dctx = NULL;
if (!(def = virNetworkDefParseFile(inxml))) if (!(def = virNetworkDefParseFile(inxml, NULL)))
goto fail; goto fail;
if (!(obj = virNetworkObjNew())) if (!(obj = virNetworkObjNew()))
......
...@@ -70,7 +70,7 @@ static int testCompareXMLToArgvFiles(const char *xml, ...@@ -70,7 +70,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
virCommandSetDryRun(&buf, testCommandDryRun, NULL); virCommandSetDryRun(&buf, testCommandDryRun, NULL);
if (!(def = virNetworkDefParseFile(xml))) if (!(def = virNetworkDefParseFile(xml, NULL)))
goto cleanup; goto cleanup;
if (networkAddFirewallRules(def) < 0) if (networkAddFirewallRules(def) < 0)
......
...@@ -30,14 +30,14 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, ...@@ -30,14 +30,14 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml,
testCompareNetXML2XMLResult result = TEST_COMPARE_NET_XML2XML_RESULT_SUCCESS; testCompareNetXML2XMLResult result = TEST_COMPARE_NET_XML2XML_RESULT_SUCCESS;
virNetworkDefPtr dev = NULL; virNetworkDefPtr dev = NULL;
if (!(dev = virNetworkDefParseFile(inxml))) { if (!(dev = virNetworkDefParseFile(inxml, NULL))) {
result = TEST_COMPARE_NET_XML2XML_RESULT_FAIL_PARSE; result = TEST_COMPARE_NET_XML2XML_RESULT_FAIL_PARSE;
goto cleanup; goto cleanup;
} }
if (expectResult == TEST_COMPARE_NET_XML2XML_RESULT_FAIL_PARSE) if (expectResult == TEST_COMPARE_NET_XML2XML_RESULT_FAIL_PARSE)
goto cleanup; goto cleanup;
if (!(actual = virNetworkDefFormat(dev, flags))) { if (!(actual = virNetworkDefFormat(dev, NULL, flags))) {
result = TEST_COMPARE_NET_XML2XML_RESULT_FAIL_FORMAT; result = TEST_COMPARE_NET_XML2XML_RESULT_FAIL_FORMAT;
goto cleanup; goto cleanup;
} }
......
...@@ -27,14 +27,14 @@ testCompareXMLToXMLFiles(const char *netxml, const char *updatexml, ...@@ -27,14 +27,14 @@ testCompareXMLToXMLFiles(const char *netxml, const char *updatexml,
if (virTestLoadFile(updatexml, &updateXmlData) < 0) if (virTestLoadFile(updatexml, &updateXmlData) < 0)
goto error; goto error;
if (!(def = virNetworkDefParseFile(netxml))) if (!(def = virNetworkDefParseFile(netxml, NULL)))
goto fail; goto fail;
if (virNetworkDefUpdateSection(def, command, section, parentIndex, if (virNetworkDefUpdateSection(def, command, section, parentIndex,
updateXmlData, 0) < 0) updateXmlData, 0) < 0)
goto fail; goto fail;
if (!(actual = virNetworkDefFormat(def, flags))) if (!(actual = virNetworkDefFormat(def, NULL, flags)))
goto fail; goto fail;
if (!expectFailure) { if (!expectFailure) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册