separate virDomainDefParseResourceInfo from virDomainDefParseXML --- src/conf/domain_conf.c | 51 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 892e871..24bd240 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -19274,6 +19274,39 @@ virDomainDefParseCpuNumaInfo(virDomainParseTotalParamPtr param) } +static int +virDomainDefParseResourceInfo(virDomainParseTotalParamPtr param) +{ + virDomainDefPtr def = param->def; + xmlXPathContextPtr ctxt = param->ctxt; + + int ret = -1; + int n; + xmlNodePtr *nodes = NULL; + + if ((n = virXPathNodeSet("./resource", ctxt, &nodes)) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("cannot extract resource nodes")); + goto cleanup; + } + + if (n > 1) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("only one resource element is supported")); + goto cleanup; + } + + if (n && + !(def->resource = virDomainResourceDefParse(nodes[0], ctxt))) + goto cleanup; + ret = 0; + + cleanup: + VIR_FREE(nodes); + return ret; +} + + static virDomainDefPtr virDomainDefParseXML(xmlDocPtr xml, xmlNodePtr root, @@ -19325,6 +19358,7 @@ virDomainDefParseXML(xmlDocPtr xml, virDomainDefParseIoThreadInfo, virDomainDefParseCputuneInfo, virDomainDefParseCpuNumaInfo, + virDomainDefParseResourceInfo, NULL }; @@ -19352,23 +19386,6 @@ virDomainDefParseXML(xmlDocPtr xml, fun_index++; } - if ((n = virXPathNodeSet("./resource", ctxt, &nodes)) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("cannot extract resource nodes")); - goto error; - } - - if (n > 1) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("only one resource element is supported")); - goto error; - } - - if (n && - !(def->resource = virDomainResourceDefParse(nodes[0], ctxt))) - goto error; - VIR_FREE(nodes); - if ((n = virXPathNodeSet("./features/*", ctxt, &nodes)) < 0) goto error; -- 2.8.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list