separate virDomainDefParseParallelInfo from virDomainDefParseXML, move virDomainDefParseParallelInfo into virDomainDefParseDeviceInfo --- src/conf/domain_conf.c | 77 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 28 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f818228..137b392 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -20067,6 +20067,54 @@ virDomainDefParseSmartCardsInfo(virDomainParseTotalParamPtr param) return ret; } + +static int +virDomainDefParseParallelInfo(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, j; + xmlNodePtr *nodes = NULL; + + /* analysis of the character devices */ + if ((n = virXPathNodeSet("./devices/parallel", ctxt, &nodes)) < 0) + goto cleanup; + if (n && VIR_ALLOC_N(def->parallels, n) < 0) + goto cleanup; + + for (i = 0; i < n; i++) { + virDomainChrDefPtr chr = virDomainChrDefParseXML(xmlopt, + ctxt, + nodes[i], + def->seclabels, + def->nseclabels, + flags); + if (!chr) + goto cleanup; + + if (chr->target.port == -1) { + int maxport = -1; + for (j = 0; j < i; j++) { + if (def->parallels[j]->target.port > maxport) + maxport = def->parallels[j]->target.port; + } + chr->target.port = maxport + 1; + } + def->parallels[def->nparallels++] = chr; + } + ret = 0; + + cleanup: + VIR_FREE(nodes); + return ret; +} + + static int virDomainDefParseDeviceInfo(virDomainParseTotalParamPtr param) { @@ -20081,6 +20129,7 @@ virDomainDefParseDeviceInfo(virDomainParseTotalParamPtr param) virDomainDefParseFilesystemInfo, virDomainDefParseInterfaceInfo, virDomainDefParseSmartCardsInfo, + virDomainDefParseParallelInfo, NULL }; @@ -20184,34 +20233,6 @@ virDomainDefParseXML(xmlDocPtr xml, fun_index++; } - /* analysis of the character devices */ - if ((n = virXPathNodeSet("./devices/parallel", ctxt, &nodes)) < 0) - goto error; - if (n && VIR_ALLOC_N(def->parallels, n) < 0) - goto error; - - for (i = 0; i < n; i++) { - virDomainChrDefPtr chr = virDomainChrDefParseXML(xmlopt, - ctxt, - nodes[i], - def->seclabels, - def->nseclabels, - flags); - if (!chr) - goto error; - - if (chr->target.port == -1) { - int maxport = -1; - for (j = 0; j < i; j++) { - if (def->parallels[j]->target.port > maxport) - maxport = def->parallels[j]->target.port; - } - chr->target.port = maxport + 1; - } - def->parallels[def->nparallels++] = chr; - } - VIR_FREE(nodes); - if ((n = virXPathNodeSet("./devices/serial", ctxt, &nodes)) < 0) goto error; -- 2.8.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list