conf: networkportdef: Provide only virNetworkPortDefParse

Replace the two helpers virNetworkPortDefParseString/File with the
common helper.

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-22 16:09:27 +02:00
parent 0589afb96b
commit ed080445a6
7 changed files with 9 additions and 27 deletions

View File

@ -29537,7 +29537,7 @@ virDomainNetCreatePort(virConnectPtr conn,
VIR_FREE(portxml);
if (!(portxml = virNetworkPortGetXMLDesc(port, 0)) ||
!(portdef = virNetworkPortDefParseString(portxml, 0)) ||
!(portdef = virNetworkPortDefParse(portxml, NULL, 0)) ||
virDomainNetDefActualFromNetworkPort(iface, portdef) < 0) {
virErrorPreserveLast(&save_err);
virNetworkPortDelete(port, 0);

View File

@ -1833,7 +1833,7 @@ virNetworkObjLoadAllPorts(virNetworkObj *net,
file = g_strdup_printf("%s/%s.xml", dir, de->d_name);
portdef = virNetworkPortDefParseFile(file);
portdef = virNetworkPortDefParse(NULL, file, 0);
if (!portdef) {
VIR_WARN("Cannot parse port %s", file);
continue;

View File

@ -251,7 +251,7 @@ virNetworkPortDefParseXML(xmlXPathContextPtr ctxt)
}
static virNetworkPortDef *
virNetworkPortDef *
virNetworkPortDefParse(const char *xmlStr,
const char *filename,
unsigned int flags)
@ -268,21 +268,6 @@ virNetworkPortDefParse(const char *xmlStr,
}
virNetworkPortDef *
virNetworkPortDefParseString(const char *xmlStr,
unsigned int flags)
{
return virNetworkPortDefParse(xmlStr, NULL, flags);
}
virNetworkPortDef *
virNetworkPortDefParseFile(const char *filename)
{
return virNetworkPortDefParse(NULL, filename, 0);
}
char *
virNetworkPortDefFormat(const virNetworkPortDef *def)
{

View File

@ -81,12 +81,10 @@ virNetworkPortDefFree(virNetworkPortDef *port);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virNetworkPortDef, virNetworkPortDefFree);
virNetworkPortDef *
virNetworkPortDefParseString(const char *xml,
virNetworkPortDefParse(const char *xmlStr,
const char *filename,
unsigned int flags);
virNetworkPortDef *
virNetworkPortDefParseFile(const char *filename);
char *
virNetworkPortDefFormat(const virNetworkPortDef *def);

View File

@ -1326,8 +1326,7 @@ virNetworkObjUpdateAssignDef;
virNetworkPortDefFormat;
virNetworkPortDefFormatBuf;
virNetworkPortDefFree;
virNetworkPortDefParseFile;
virNetworkPortDefParseString;
virNetworkPortDefParse;
virNetworkPortDefSaveStatus;

View File

@ -4844,7 +4844,7 @@ networkPortCreateXML(virNetworkPtr net,
def = virNetworkObjGetDef(obj);
if (!(portdef = virNetworkPortDefParseString(xmldesc, flags)))
if (!(portdef = virNetworkPortDefParse(xmldesc, NULL, flags)))
goto cleanup;
if (virNetworkPortCreateXMLEnsureACL(net->conn, def, portdef) < 0)

View File

@ -38,7 +38,7 @@ testCompareXMLToXMLFiles(const char *expected)
g_autofree char *actual = NULL;
g_autoptr(virNetworkPortDef) dev = NULL;
if (!(dev = virNetworkPortDefParseFile(expected)))
if (!(dev = virNetworkPortDefParse(NULL, expected, 0)))
return -1;
if (!(actual = virNetworkPortDefFormat(dev)))