提交 f68fd147 编写于 作者: S Soren Hansen 提交者: Eric Blake

Add nwfilter support to UML driver

Extend user-mode-linux driver to support nwfilter.
Signed-off-by: NSoren Hansen <soren@linux2go.dk>
上级 8eac2621
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include "verify.h" #include "verify.h"
#include "bridge.h" #include "bridge.h"
#include "logging.h" #include "logging.h"
#include "domain_nwfilter.h"
#define VIR_FROM_THIS VIR_FROM_UML #define VIR_FROM_THIS VIR_FROM_UML
...@@ -108,7 +109,8 @@ virCapsPtr umlCapsInit(void) { ...@@ -108,7 +109,8 @@ virCapsPtr umlCapsInit(void) {
static int static int
umlConnectTapDevice(virDomainNetDefPtr net, umlConnectTapDevice(virConnectPtr conn,
virDomainNetDefPtr net,
const char *bridge) const char *bridge)
{ {
brControl *brctl = NULL; brControl *brctl = NULL;
...@@ -164,6 +166,14 @@ umlConnectTapDevice(virDomainNetDefPtr net, ...@@ -164,6 +166,14 @@ umlConnectTapDevice(virDomainNetDefPtr net,
goto error; goto error;
} }
if (net->filter) {
if (virDomainConfNWFilterInstantiate(conn, net)) {
if (template_ifname)
VIR_FREE(net->ifname);
goto error;
}
}
brShutdown(brctl); brShutdown(brctl);
return 0; return 0;
...@@ -239,7 +249,7 @@ umlBuildCommandLineNet(virConnectPtr conn, ...@@ -239,7 +249,7 @@ umlBuildCommandLineNet(virConnectPtr conn,
goto error; goto error;
} }
if (umlConnectTapDevice(def, bridge) < 0) { if (umlConnectTapDevice(conn, def, bridge) < 0) {
VIR_FREE(bridge); VIR_FREE(bridge);
goto error; goto error;
} }
...@@ -250,7 +260,7 @@ umlBuildCommandLineNet(virConnectPtr conn, ...@@ -250,7 +260,7 @@ umlBuildCommandLineNet(virConnectPtr conn,
} }
case VIR_DOMAIN_NET_TYPE_BRIDGE: case VIR_DOMAIN_NET_TYPE_BRIDGE:
if (umlConnectTapDevice(def, def->data.bridge.brname) < 0) if (umlConnectTapDevice(conn, def, def->data.bridge.brname) < 0)
goto error; goto error;
/* ethNNN=tuntap,tapname,macaddr,gateway */ /* ethNNN=tuntap,tapname,macaddr,gateway */
......
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
#include "domain_conf.h" #include "domain_conf.h"
#include "datatypes.h" #include "datatypes.h"
#include "logging.h" #include "logging.h"
#include "domain_nwfilter.h"
#define VIR_FROM_THIS VIR_FROM_UML #define VIR_FROM_THIS VIR_FROM_UML
...@@ -876,6 +877,7 @@ static int umlStartVMDaemon(virConnectPtr conn, ...@@ -876,6 +877,7 @@ static int umlStartVMDaemon(virConnectPtr conn,
if (umlBuildCommandLine(conn, driver, vm, &keepfd, if (umlBuildCommandLine(conn, driver, vm, &keepfd,
&argv, &progenv) < 0) { &argv, &progenv) < 0) {
close(logfd); close(logfd);
virDomainConfVMNWFilterTeardown(vm);
umlCleanupTapDevices(conn, vm); umlCleanupTapDevices(conn, vm);
return -1; return -1;
} }
...@@ -928,8 +930,11 @@ static int umlStartVMDaemon(virConnectPtr conn, ...@@ -928,8 +930,11 @@ static int umlStartVMDaemon(virConnectPtr conn,
VIR_FREE(progenv[i]); VIR_FREE(progenv[i]);
VIR_FREE(progenv); VIR_FREE(progenv);
if (ret < 0) if (ret < 0) {
virDomainConfVMNWFilterTeardown(vm);
umlCleanupTapDevices(conn, vm); umlCleanupTapDevices(conn, vm);
}
/* NB we don't mark it running here - we do that async /* NB we don't mark it running here - we do that async
with inotify */ with inotify */
...@@ -965,6 +970,7 @@ static void umlShutdownVMDaemon(virConnectPtr conn ATTRIBUTE_UNUSED, ...@@ -965,6 +970,7 @@ static void umlShutdownVMDaemon(virConnectPtr conn ATTRIBUTE_UNUSED,
vm->def->id = -1; vm->def->id = -1;
vm->state = VIR_DOMAIN_SHUTOFF; vm->state = VIR_DOMAIN_SHUTOFF;
virDomainConfVMNWFilterTeardown(vm);
umlCleanupTapDevices(conn, vm); umlCleanupTapDevices(conn, vm);
if (vm->newDef) { if (vm->newDef) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册