mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
virInterfaceDefParseXML: Simplify and cleanup
Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
7443101eb0
commit
56b4186efc
@ -573,26 +573,14 @@ static virInterfaceDef *
|
|||||||
virInterfaceDefParseXML(xmlXPathContextPtr ctxt,
|
virInterfaceDefParseXML(xmlXPathContextPtr ctxt,
|
||||||
int parentIfType)
|
int parentIfType)
|
||||||
{
|
{
|
||||||
g_autoptr(virInterfaceDef) def = NULL;
|
|
||||||
int type;
|
|
||||||
g_autofree char *tmp = NULL;
|
|
||||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||||
|
g_autoptr(virInterfaceDef) def = NULL;
|
||||||
|
virInterfaceType type;
|
||||||
xmlNodePtr lnk;
|
xmlNodePtr lnk;
|
||||||
|
|
||||||
|
if (virXMLPropEnum(ctxt->node, "type", virInterfaceTypeFromString,
|
||||||
/* check @type */
|
VIR_XML_PROP_REQUIRED, &type) < 0)
|
||||||
tmp = virXPathString("string(./@type)", ctxt);
|
|
||||||
if (tmp == NULL) {
|
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
|
||||||
"%s", _("interface misses the type attribute"));
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
type = virInterfaceTypeFromString(tmp);
|
|
||||||
if (type == -1) {
|
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
||||||
_("unknown interface type %s"), tmp);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
def = g_new0(virInterfaceDef, 1);
|
def = g_new0(virInterfaceDef, 1);
|
||||||
|
|
||||||
@ -680,7 +668,8 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt,
|
|||||||
return NULL;
|
return NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case VIR_INTERFACE_TYPE_LAST:
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return g_steal_pointer(&def);
|
return g_steal_pointer(&def);
|
||||||
|
Loading…
Reference in New Issue
Block a user