]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix port value parsing for serial and parallel ports
authorMichal Novotny <minovotn@redhat.com>
Fri, 25 Feb 2011 14:41:11 +0000 (15:41 +0100)
committerEric Blake <eblake@redhat.com>
Fri, 25 Feb 2011 18:33:27 +0000 (11:33 -0700)
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

index e3037fbf3233b46aa14954afce461045b5300867..c8350c64f0841570a751c1e7a2003fde8f43b164 100644 (file)
@@ -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);