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