conf: network: Provide only virNetworkDefParse

Replace virNetworkDefParseString/File by direct calls to
virNetworkDefParse.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2022-09-23 13:28:44 +02:00
parent e56e82a654
commit 1eb67d24de
14 changed files with 24 additions and 45 deletions

View File

@ -29728,7 +29728,7 @@ virDomainNetResolveActualType(virDomainNetDef *iface)
if (!(xml = virNetworkGetXMLDesc(net, 0)))
return -1;
if (!(def = virNetworkDefParseString(xml, NULL, false)))
if (!(def = virNetworkDefParse(xml, NULL, NULL, false)))
return -1;
switch ((virNetworkForwardType) def->forward.type) {

View File

@ -315,7 +315,7 @@ virNetworkDefCopy(virNetworkDef *def,
if (!(xml = virNetworkDefFormat(def, xmlopt, flags)))
return NULL;
return virNetworkDefParseString(xml, xmlopt, false);
return virNetworkDefParse(xml, NULL, xmlopt, false);
}
@ -2025,7 +2025,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt,
}
static virNetworkDef *
virNetworkDef *
virNetworkDefParse(const char *xmlStr,
const char *filename,
virNetworkXMLOption *xmlopt,
@ -2046,23 +2046,6 @@ virNetworkDefParse(const char *xmlStr,
}
virNetworkDef *
virNetworkDefParseString(const char *xmlStr,
virNetworkXMLOption *xmlopt,
bool validate)
{
return virNetworkDefParse(xmlStr, NULL, xmlopt, validate);
}
virNetworkDef *
virNetworkDefParseFile(const char *filename,
virNetworkXMLOption *xmlopt)
{
return virNetworkDefParse(NULL, filename, xmlopt, false);
}
static int
virNetworkDNSDefFormat(virBuffer *buf,
const virNetworkDNSDef *def)

View File

@ -325,13 +325,10 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt,
virNetworkXMLOption *xmlopt);
virNetworkDef *
virNetworkDefParseString(const char *xmlStr,
virNetworkXMLOption *xmlopt,
bool validate);
virNetworkDef *
virNetworkDefParseFile(const char *filename,
virNetworkXMLOption *xmlopt);
virNetworkDefParse(const char *xmlStr,
const char *filename,
virNetworkXMLOption *xmlopt,
bool validate);
char *
virNetworkDefFormat(const virNetworkDef *def,

View File

@ -967,7 +967,7 @@ virNetworkLoadConfig(virNetworkObjList *nets,
if ((autostart = virFileLinkPointsTo(autostartLink, configFile)) < 0)
goto error;
if (!(def = virNetworkDefParseFile(configFile, xmlopt)))
if (!(def = virNetworkDefParse(NULL, configFile, xmlopt, false)))
goto error;
if (STRNEQ(name, def->name)) {

View File

@ -296,7 +296,7 @@ esxNetworkDefineXMLFlags(virConnectPtr conn, const char *xml,
return NULL;
/* Parse network XML */
def = virNetworkDefParseString(xml, NULL, !!(flags & VIR_NETWORK_DEFINE_VALIDATE));
def = virNetworkDefParse(xml, NULL, NULL, !!(flags & VIR_NETWORK_DEFINE_VALIDATE));
if (!def)
return NULL;

View File

@ -828,8 +828,7 @@ virNetworkDefForwardIf;
virNetworkDefFree;
virNetworkDefGetIPByIndex;
virNetworkDefGetRouteByIndex;
virNetworkDefParseFile;
virNetworkDefParseString;
virNetworkDefParse;
virNetworkDefParseXML;
virNetworkDefUpdateSection;
virNetworkDHCPLeaseTimeUnitTypeFromString;

View File

@ -3017,8 +3017,8 @@ networkCreateXMLFlags(virConnectPtr conn,
virCheckFlags(VIR_NETWORK_CREATE_VALIDATE, NULL);
if (!(newDef = virNetworkDefParseString(xml, network_driver->xmlopt,
!!(flags & VIR_NETWORK_CREATE_VALIDATE))))
if (!(newDef = virNetworkDefParse(xml, NULL, network_driver->xmlopt,
!!(flags & VIR_NETWORK_CREATE_VALIDATE))))
goto cleanup;
if (virNetworkCreateXMLFlagsEnsureACL(conn, newDef) < 0)
@ -3082,8 +3082,8 @@ networkDefineXMLFlags(virConnectPtr conn,
virCheckFlags(VIR_NETWORK_DEFINE_VALIDATE, NULL);
if (!(def = virNetworkDefParseString(xml, network_driver->xmlopt,
!!(flags & VIR_NETWORK_DEFINE_VALIDATE))))
if (!(def = virNetworkDefParse(xml, NULL, network_driver->xmlopt,
!!(flags & VIR_NETWORK_DEFINE_VALIDATE))))
goto cleanup;
defAlias = def; /* so we can still ref the object after nullifying def */

View File

@ -4852,7 +4852,7 @@ qemuProcessGetNetworkAddress(const char *netname,
if (!xml)
return -1;
netdef = virNetworkDefParseString(xml, NULL, false);
netdef = virNetworkDefParse(xml, NULL, NULL, false);
if (!netdef)
return -1;

View File

@ -5559,8 +5559,8 @@ testNetworkCreateXMLFlags(virConnectPtr conn, const char *xml,
virCheckFlags(VIR_NETWORK_CREATE_VALIDATE, NULL);
if (!(newDef = virNetworkDefParseString(xml, NULL,
!!(flags & VIR_NETWORK_CREATE_VALIDATE))))
if (!(newDef = virNetworkDefParse(xml, NULL, NULL,
!!(flags & VIR_NETWORK_CREATE_VALIDATE))))
goto cleanup;
if (!(obj = virNetworkObjAssignDef(privconn->networks, newDef,
@ -5605,8 +5605,8 @@ testNetworkDefineXMLFlags(virConnectPtr conn,
virCheckFlags(VIR_NETWORK_DEFINE_VALIDATE, NULL);
if (!(newDef = virNetworkDefParseString(xml, NULL,
!!(flags & VIR_NETWORK_DEFINE_VALIDATE))))
if (!(newDef = virNetworkDefParse(xml, NULL, NULL,
!!(flags & VIR_NETWORK_DEFINE_VALIDATE))))
goto cleanup;
if (!(obj = virNetworkObjAssignDef(privconn->networks, newDef, 0)))

View File

@ -402,7 +402,7 @@ vboxNetworkDefineCreateXML(virConnectPtr conn, const char *xml, bool start,
VBOX_IID_INITIALIZE(&vboxnetiid);
if (!(def = virNetworkDefParseString(xml, NULL, validate)) ||
if (!(def = virNetworkDefParse(xml, NULL, NULL, validate)) ||
(def->forward.type != VIR_NETWORK_FORWARD_NONE) ||
(def->nips == 0 || !def->ips))
goto cleanup;

View File

@ -31,7 +31,7 @@ testCompareXMLToConfFiles(const char *inxml, const char *outconf,
if (!(xmlopt = networkDnsmasqCreateXMLConf()))
goto fail;
if (!(def = virNetworkDefParseFile(inxml, xmlopt)))
if (!(def = virNetworkDefParse(NULL, inxml, xmlopt, false)))
goto fail;
if (!(obj = virNetworkObjNew()))

View File

@ -95,7 +95,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
virCommandSetDryRun(dryRunToken, &buf, true, true, testCommandDryRun, NULL);
if (!(def = virNetworkDefParseFile(xml, NULL)))
if (!(def = virNetworkDefParse(NULL, xml, NULL, false)))
return -1;
if (networkAddFirewallRules(def) < 0)

View File

@ -33,7 +33,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml,
if (!(xmlopt = networkDnsmasqCreateXMLConf()))
goto cleanup;
if (!(dev = virNetworkDefParseFile(inxml, xmlopt))) {
if (!(dev = virNetworkDefParse(NULL, inxml, xmlopt, false))) {
result = TEST_COMPARE_NET_XML2XML_RESULT_FAIL_PARSE;
goto cleanup;
}

View File

@ -25,7 +25,7 @@ testCompareXMLToXMLFiles(const char *netxml, const char *updatexml,
if (virTestLoadFile(updatexml, &updateXmlData) < 0)
return -1;
if (!(def = virNetworkDefParseFile(netxml, NULL)))
if (!(def = virNetworkDefParse(NULL, netxml, NULL, false)))
goto fail;
if (virNetworkDefUpdateSection(def, command, section, parentIndex,