1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-25 01:34:11 +03:00

Refactoring virDomainChrDefParseTargetXML() to use XPath

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Kristina Hanicova 2021-05-04 13:40:06 +02:00 committed by Michal Privoznik
parent d1c8ee235a
commit 3ee51e1b56

View File

@ -11021,16 +11021,18 @@ virDomainChrTargetModelFromString(int devtype,
static int static int
virDomainChrDefParseTargetXML(virDomainChrDef *def, virDomainChrDefParseTargetXML(virDomainChrDef *def,
xmlNodePtr cur, xmlNodePtr cur,
xmlXPathContextPtr ctxt G_GNUC_UNUSED, xmlXPathContextPtr ctxt,
unsigned int flags) unsigned int flags)
{ {
xmlNodePtr child;
unsigned int port; unsigned int port;
g_autofree char *targetType = virXMLPropString(cur, "type"); g_autofree char *targetType = virXMLPropString(cur, "type");
g_autofree char *targetModel = NULL; g_autofree char *targetModel = NULL;
g_autofree char *addrStr = NULL; g_autofree char *addrStr = NULL;
g_autofree char *portStr = NULL; g_autofree char *portStr = NULL;
g_autofree char *stateStr = NULL; g_autofree char *stateStr = NULL;
VIR_XPATH_NODE_AUTORESTORE(ctxt)
ctxt->node = cur;
if ((def->targetType = if ((def->targetType =
virDomainChrTargetTypeFromString(def->deviceType, virDomainChrTargetTypeFromString(def->deviceType,
@ -11041,14 +11043,7 @@ virDomainChrDefParseTargetXML(virDomainChrDef *def,
return -1; return -1;
} }
child = cur->children; targetModel = virXPathString("string(./model/@name)", ctxt);
while (child != NULL) {
if (child->type == XML_ELEMENT_NODE &&
virXMLNodeNameEqual(child, "model")) {
targetModel = virXMLPropString(child, "name");
}
child = child->next;
}
if ((def->targetModel = if ((def->targetModel =
virDomainChrTargetModelFromString(def->deviceType, virDomainChrTargetModelFromString(def->deviceType,