Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > ebe084c140192657f9094e135a84202c > files > 40

libvirt-0.8.2-29.el5.src.rpm

From 98bea9073277a6d7edc7a566c96ca178008ec256 Mon Sep 17 00:00:00 2001
Message-Id: <98bea9073277a6d7edc7a566c96ca178008ec256.1300377193.git.jdenemar@redhat.com>
From: Michal Novotny <minovotn@redhat.com>
Date: Mon, 7 Mar 2011 16:01:18 +0100
Subject: [PATCH] Fix port value parsing for serial and parallel ports

https://bugzilla.redhat.com/show_bug.cgi?id=670789

Upstream status: This patch has been applied upstream in commit 79c3fe4d

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 <minovotn@redhat.com>
---
 src/conf/domain_conf.c |   25 +++++++++++++++++++++----
 1 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 30e2ada..659b1f7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2495,8 +2495,8 @@ virDomainChrDefParseXML(xmlNodePtr node,
                 case VIR_DOMAIN_CHR_TARGET_TYPE_CONSOLE:
                     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;
                     }
 
@@ -2506,6 +2506,7 @@ virDomainChrDefParseXML(xmlNodePtr node,
                                              portStr);
                         goto error;
                     }
+                    def->target.port = port;
                     break;
 
                 case VIR_DOMAIN_CHR_TARGET_TYPE_GUESTFWD:
@@ -4419,7 +4420,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);
@@ -4438,7 +4447,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);
-- 
1.7.4.1