提交 b59bb931 编写于 作者: D Daniel P. Berrange

Make LXC work with new network configuration types

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
上级 5298551e
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
#include "fdstream.h" #include "fdstream.h"
#include "domain_audit.h" #include "domain_audit.h"
#include "domain_nwfilter.h" #include "domain_nwfilter.h"
#include "network/bridge_driver.h"
#define VIR_FROM_THIS VIR_FROM_LXC #define VIR_FROM_THIS VIR_FROM_LXC
...@@ -1042,6 +1043,8 @@ static void lxcVmCleanup(lxc_driver_t *driver, ...@@ -1042,6 +1043,8 @@ static void lxcVmCleanup(lxc_driver_t *driver,
for (i = 0 ; i < vm->def->nnets ; i++) { for (i = 0 ; i < vm->def->nnets ; i++) {
vethInterfaceUpOrDown(vm->def->nets[i]->ifname, 0); vethInterfaceUpOrDown(vm->def->nets[i]->ifname, 0);
vethDelete(vm->def->nets[i]->ifname); vethDelete(vm->def->nets[i]->ifname);
networkReleaseActualDevice(vm->def->nets[i]);
} }
virDomainConfVMNWFilterTeardown(vm); virDomainConfVMNWFilterTeardown(vm);
...@@ -1093,7 +1096,14 @@ static int lxcSetupInterfaces(virConnectPtr conn, ...@@ -1093,7 +1096,14 @@ static int lxcSetupInterfaces(virConnectPtr conn,
char *parentVeth; char *parentVeth;
char *containerVeth = NULL; 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: case VIR_DOMAIN_NET_TYPE_NETWORK:
{ {
virNetworkPtr network; virNetworkPtr network;
...@@ -1110,7 +1120,7 @@ static int lxcSetupInterfaces(virConnectPtr conn, ...@@ -1110,7 +1120,7 @@ static int lxcSetupInterfaces(virConnectPtr conn,
break; break;
} }
case VIR_DOMAIN_NET_TYPE_BRIDGE: case VIR_DOMAIN_NET_TYPE_BRIDGE:
bridge = def->nets[i]->data.bridge.brname; bridge = virDomainNetGetActualBridgeName(def->nets[i]);
break; break;
case VIR_DOMAIN_NET_TYPE_USER: case VIR_DOMAIN_NET_TYPE_USER:
...@@ -1183,6 +1193,10 @@ static int lxcSetupInterfaces(virConnectPtr conn, ...@@ -1183,6 +1193,10 @@ static int lxcSetupInterfaces(virConnectPtr conn,
error_exit: error_exit:
brShutdown(brctl); brShutdown(brctl);
if (rc != 0) {
for (i = 0 ; i < def->nnets ; i++)
networkReleaseActualDevice(def->nets[i]);
}
return rc; return rc;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册