separate virDomainDefParseDeviceMemInfo from virDomainDefParseXML, move virDomainDefParseDeviceMemInfo into virDomainDefParseDeviceInfo --- src/conf/domain_conf.c | 57 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 281042f..7d8b875 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -20831,6 +20831,43 @@ virDomainDefParseShmemInfo(virDomainParseTotalParamPtr param) static int +virDomainDefParseDeviceMemInfo(virDomainParseTotalParamPtr param) +{ + virDomainDefPtr def = param->def; + xmlXPathContextPtr ctxt = param->ctxt; + virDomainXMLOptionPtr xmlopt = param->xmlopt; + unsigned int flags = param->flags; + + int ret = -1; + int n = 0; + size_t i; + xmlNodePtr *nodes = NULL; + + /* analysis of memory devices */ + if ((n = virXPathNodeSet("./devices/memory", ctxt, &nodes)) < 0) + goto cleanup; + if (n && VIR_ALLOC_N(def->mems, n) < 0) + goto cleanup; + + for (i = 0; i < n; i++) { + virDomainMemoryDefPtr mem = virDomainMemoryDefParseXML(xmlopt, + nodes[i], + ctxt, + flags); + if (!mem) + goto cleanup; + + def->mems[def->nmems++] = mem; + } + ret = 0; + + cleanup: + VIR_FREE(nodes); + return ret; +} + + +static int virDomainDefParseDeviceInfo(virDomainParseTotalParamPtr param) { typedef int (*virDomainPreaseDeviceFuc)(virDomainParseTotalParamPtr param); @@ -20863,6 +20900,7 @@ virDomainDefParseDeviceInfo(virDomainParseTotalParamPtr param) virDomainDefParseRedirFilterInfo, virDomainDefParsePanicInfo, virDomainDefParseShmemInfo, + virDomainDefParseDeviceMemInfo, NULL }; @@ -20891,7 +20929,6 @@ virDomainDefParseXML(xmlDocPtr xml, xmlNodePtr *nodes = NULL, node = NULL; char *tmp = NULL; - size_t i; int n; size_t fun_index = 0; virDomainDefPtr def; @@ -20965,24 +21002,6 @@ virDomainDefParseXML(xmlDocPtr xml, fun_index++; } - /* analysis of memory devices */ - if ((n = virXPathNodeSet("./devices/memory", ctxt, &nodes)) < 0) - goto error; - if (n && VIR_ALLOC_N(def->mems, n) < 0) - goto error; - - for (i = 0; i < n; i++) { - virDomainMemoryDefPtr mem = virDomainMemoryDefParseXML(xmlopt, - nodes[i], - ctxt, - flags); - if (!mem) - goto error; - - def->mems[def->nmems++] = mem; - } - VIR_FREE(nodes); - if ((n = virXPathNodeSet("./devices/iommu", ctxt, &nodes)) < 0) goto error; -- 2.8.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list