[PATCH] Make LXC work with new network configuration types

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

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

If using one of the new non-NAT/routed virtual network
configurations, the LXC driver would not know how to
setup the VETH devices. Adding in calls to setup the
"actual" network configuration at VM startup and cleanup
when shutting down fixes this.

* src/lxc/lxc_driver.c: Setup/cleanup actual net devs
---
 src/lxc/lxc_driver.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index c8e6119..c475887 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -54,6 +54,7 @@
 #include "fdstream.h"
 #include "domain_audit.h"
 #include "domain_nwfilter.h"
+#include "network/bridge_driver.h"
 
 #define VIR_FROM_THIS VIR_FROM_LXC
 
@@ -1042,6 +1043,8 @@ static void lxcVmCleanup(lxc_driver_t *driver,
     for (i = 0 ; i < vm->def->nnets ; i++) {
         vethInterfaceUpOrDown(vm->def->nets[i]->ifname, 0);
         vethDelete(vm->def->nets[i]->ifname);
+
+        networkReleaseActualDevice(vm->def->nets[i]);
     }
 
     virDomainConfVMNWFilterTeardown(vm);
@@ -1093,7 +1096,14 @@ static int lxcSetupInterfaces(virConnectPtr conn,
         char *parentVeth;
         char *containerVeth = NULL;
 
-        switch (def->nets[i]->type) {
+        /* If appropriate, grab a physical device from the configured
+         * network's pool of devices, or resolve bridge device name
+         * to the one defined in the network definition.
+         */
+        if (networkAllocateActualDevice(def->nets[i]) < 0)
+            goto error_exit;
+
+        switch (virDomainNetGetActualType(def->nets[i])) {
         case VIR_DOMAIN_NET_TYPE_NETWORK:
         {
             virNetworkPtr network;
@@ -1110,7 +1120,7 @@ static int lxcSetupInterfaces(virConnectPtr conn,
             break;
         }
         case VIR_DOMAIN_NET_TYPE_BRIDGE:
-            bridge = def->nets[i]->data.bridge.brname;
+            bridge = virDomainNetGetActualBridgeName(def->nets[i]);
             break;
 
         case VIR_DOMAIN_NET_TYPE_USER:
@@ -1183,6 +1193,10 @@ static int lxcSetupInterfaces(virConnectPtr conn,
 
 error_exit:
     brShutdown(brctl);
+    if (rc != 0) {
+        for (i = 0 ; i < def->nnets ; i++)
+            networkReleaseActualDevice(def->nets[i]);
+    }
     return rc;
 }
 
-- 
1.7.6.2

--
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]