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))) if (!(xml = virNetworkGetXMLDesc(net, 0)))
return -1; return -1;
if (!(def = virNetworkDefParseString(xml, NULL, false))) if (!(def = virNetworkDefParse(xml, NULL, NULL, false)))
return -1; return -1;
switch ((virNetworkForwardType) def->forward.type) { switch ((virNetworkForwardType) def->forward.type) {

View File

@ -315,7 +315,7 @@ virNetworkDefCopy(virNetworkDef *def,
if (!(xml = virNetworkDefFormat(def, xmlopt, flags))) if (!(xml = virNetworkDefFormat(def, xmlopt, flags)))
return NULL; 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, virNetworkDefParse(const char *xmlStr,
const char *filename, const char *filename,
virNetworkXMLOption *xmlopt, 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 static int
virNetworkDNSDefFormat(virBuffer *buf, virNetworkDNSDefFormat(virBuffer *buf,
const virNetworkDNSDef *def) const virNetworkDNSDef *def)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -5559,8 +5559,8 @@ testNetworkCreateXMLFlags(virConnectPtr conn, const char *xml,
virCheckFlags(VIR_NETWORK_CREATE_VALIDATE, NULL); virCheckFlags(VIR_NETWORK_CREATE_VALIDATE, NULL);
if (!(newDef = virNetworkDefParseString(xml, NULL, if (!(newDef = virNetworkDefParse(xml, NULL, NULL,
!!(flags & VIR_NETWORK_CREATE_VALIDATE)))) !!(flags & VIR_NETWORK_CREATE_VALIDATE))))
goto cleanup; goto cleanup;
if (!(obj = virNetworkObjAssignDef(privconn->networks, newDef, if (!(obj = virNetworkObjAssignDef(privconn->networks, newDef,
@ -5605,8 +5605,8 @@ testNetworkDefineXMLFlags(virConnectPtr conn,
virCheckFlags(VIR_NETWORK_DEFINE_VALIDATE, NULL); virCheckFlags(VIR_NETWORK_DEFINE_VALIDATE, NULL);
if (!(newDef = virNetworkDefParseString(xml, NULL, if (!(newDef = virNetworkDefParse(xml, NULL, NULL,
!!(flags & VIR_NETWORK_DEFINE_VALIDATE)))) !!(flags & VIR_NETWORK_DEFINE_VALIDATE))))
goto cleanup; goto cleanup;
if (!(obj = virNetworkObjAssignDef(privconn->networks, newDef, 0))) 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); 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->forward.type != VIR_NETWORK_FORWARD_NONE) ||
(def->nips == 0 || !def->ips)) (def->nips == 0 || !def->ips))
goto cleanup; goto cleanup;

View File

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

View File

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

View File

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

View File

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