[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] The logic in veth.c that searches for free interface names takes into account



only current devices, but not device names already planned for the other
half of a container's device pair.  Thus, the search can result in attempting
to create a pair of devices such as veth1 and veth1, which obviously does
not work.

This patch augments the logic to be a little smarter in this regard, and should
fix one case where attempting to start a container results in an error message
of "unable to create device pair".

diff -r 8c5e6387e449 -r 8545f7ac1f0f src/veth.c
--- a/src/veth.c	Tue Aug 05 16:45:07 2008 +0000
+++ b/src/veth.c	Wed Aug 06 08:14:16 2008 -0700
@@ -92,17 +92,18 @@
 
     DEBUG("veth1: %s veth2: %s", veth1, veth2);
 
-    if (1 > strlen(veth1)) {
+    while ((1 > strlen(veth1)) || STREQ(veth1, veth2)) {
         vethDev = getFreeVethName(veth1, veth1MaxLen, 0);
         ++vethDev;
         DEBUG("assigned veth1: %s", veth1);
     }
 
-    if (1 > strlen(veth2)) {
+    while ((1 > strlen(veth2)) || STREQ(veth1, veth2)) {
         vethDev = getFreeVethName(veth2, veth2MaxLen, vethDev);
         DEBUG("assigned veth2: %s", veth2);
     }
 
+    DEBUG("veth1: %s veth2: %s", veth1, veth2);
     rc = virRun(NULL, (char**)argv, &cmdResult);
 
     if (0 == rc) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]