[PATCH 9/9] LXC: honour network devices link state

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

 



Don't activate LXC network device if <link state='down'/> has been set
in its configuration.
---
 src/lxc/lxc_container.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 4a373cb..480b045 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -561,19 +561,21 @@ static int lxcContainerRenameAndEnableInterfaces(virDomainDefPtr vmDef,
             }
         }
 
-        VIR_DEBUG("Enabling %s", newname);
-        rc = virNetDevSetOnline(newname, true);
-        if (rc < 0)
-            goto error_out;
+        if (netDef->linkstate != VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN) {
+            VIR_DEBUG("Enabling %s", newname);
+            rc = virNetDevSetOnline(newname, true);
+            if (rc < 0)
+                goto error_out;
 
-        /* Set the gateways */
-        if (netDef->gateway_ipv4 &&
-            lxcContainerAddDefaultRoute(newname, netDef->gateway_ipv4) < 0)
-            goto error_out;
+            /* Set the gateways */
+            if (netDef->gateway_ipv4 &&
+                lxcContainerAddDefaultRoute(newname, netDef->gateway_ipv4) < 0)
+                goto error_out;
 
-        if (netDef->gateway_ipv6 &&
-            lxcContainerAddDefaultRoute(newname, netDef->gateway_ipv6) < 0)
-            goto error_out;
+            if (netDef->gateway_ipv6 &&
+                lxcContainerAddDefaultRoute(newname, netDef->gateway_ipv6) < 0)
+                goto error_out;
+        }
 
         VIR_FREE(newname);
     }
-- 
1.8.4.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]