separate virDomainDefParseSerialInfo from virDomainDefParseXML,
move virDomainDefParseSerialInfo into virDomainDefParseDeviceInfo
---
src/conf/domain_conf.c | 76 +++++++++++++++++++++++++++++++-------------------
1 file changed, 48 insertions(+), 28 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 137b392..c4743cf 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -20116,6 +20116,53 @@ virDomainDefParseParallelInfo(virDomainParseTotalParamPtr param)
static int
+virDomainDefParseSerialInfo(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;
+
+ if ((n = virXPathNodeSet("./devices/serial", ctxt, &nodes)) < 0)
+ goto cleanup;
+
+ if (n && VIR_ALLOC_N(def->serials, 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->serials[j]->target.port > maxport)
+ maxport = def->serials[j]->target.port;
+ }
+ chr->target.port = maxport + 1;
+ }
+ def->serials[def->nserials++] = chr;
+ }
+ ret = 0;
+
+ cleanup:
+ VIR_FREE(nodes);
+ return ret;
+}
+
+
+static int
virDomainDefParseDeviceInfo(virDomainParseTotalParamPtr param)
{
typedef int (*virDomainPreaseDeviceFuc)(virDomainParseTotalParamPtr param);
@@ -20130,6 +20177,7 @@ virDomainDefParseDeviceInfo(virDomainParseTotalParamPtr param)
virDomainDefParseInterfaceInfo,
virDomainDefParseSmartCardsInfo,
virDomainDefParseParallelInfo,
+ virDomainDefParseSerialInfo,
NULL
};
@@ -20233,34 +20281,6 @@ virDomainDefParseXML(xmlDocPtr xml,
fun_index++;
}
- if ((n = virXPathNodeSet("./devices/serial", ctxt, &nodes)) < 0)
- goto error;
-
- if (n && VIR_ALLOC_N(def->serials, 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->serials[j]->target.port > maxport)
- maxport = def->serials[j]->target.port;
- }
- chr->target.port = maxport + 1;
- }
- def->serials[def->nserials++] = chr;
- }
- VIR_FREE(nodes);
-
if ((n = virXPathNodeSet("./devices/console", ctxt, &nodes)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("cannot extract console devices"));
--
2.8.3