From 79c3fe4d1681cd94598d2bd42e38a98f51cb645d Mon Sep 17 00:00:00 2001 From: Michal Novotny Date: Fri, 25 Feb 2011 15:41:11 +0100 Subject: [PATCH] Fix port value parsing for serial and parallel ports this is the patch to fix the virDomainChrDefParseTargetXML() functionality to parse the target port from XML if available. This is necessary for multiple serial port support which is the second part of this patch. Signed-off-by: Michal Novotny --- src/conf/domain_conf.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e3037fbf32..c8350c64f0 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2974,7 +2974,8 @@ virDomainChrDefParseTargetXML(virCapsPtr caps, default: portStr = virXMLPropString(cur, "port"); if (portStr == NULL) { - /* Not required. It will be assigned automatically later */ + /* Set to negative value to indicate we should set it later */ + def->target.port = -1; break; } @@ -2984,6 +2985,7 @@ virDomainChrDefParseTargetXML(virCapsPtr caps, portStr); goto error; } + def->target.port = port; break; } @@ -5547,7 +5549,15 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, if (!chr) goto error; - chr->target.port = i; + if (chr->target.port == -1) { + int maxport = -1; + int j; + 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); @@ -5567,7 +5577,15 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, if (!chr) goto error; - chr->target.port = i; + if (chr->target.port == -1) { + int maxport = -1; + int j; + 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); -- GitLab