[libvirt] [PATCH] Add nwfilter support to UML driver

Extend user-mode-linux driver to support nwfilter. Signed-off-by: Soren Hansen <soren@linux2go.dk> --- src/uml/uml_conf.c | 16 +++++++++++++--- src/uml/uml_driver.c | 8 +++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c index 4906192..f2eaef5 100644 --- a/src/uml/uml_conf.c +++ b/src/uml/uml_conf.c @@ -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 */ diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 0a5c829..40345d5 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -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) { -- 1.7.1

On Tue, Sep 07, 2010 at 10:19:56AM +0200, Soren Hansen wrote:
Extend user-mode-linux driver to support nwfilter.
Signed-off-by: Soren Hansen <soren@linux2go.dk> --- src/uml/uml_conf.c | 16 +++++++++++++--- src/uml/uml_driver.c | 8 +++++++- 2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c index 4906192..f2eaef5 100644 --- a/src/uml/uml_conf.c +++ b/src/uml/uml_conf.c @@ -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 */ diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 0a5c829..40345d5 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -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) {
We are supposed to be in feature freeze mode this week, but this looks simple enough and I don't think this can introduce regression, so ACK and I suggest to push this to git before Friday, unless someone disagrees, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On 07-09-2010 10:32, Daniel Veillard wrote:
We are supposed to be in feature freeze mode this week,
Apologies. I didn't realise. Where could I have learned this? -- Soren Hansen Ubuntu Developer http://www.ubuntu.com/

On 09/07/2010 02:50 AM, Soren Hansen wrote:
On 07-09-2010 10:32, Daniel Veillard wrote:
We are supposed to be in feature freeze mode this week,
Apologies. I didn't realise. Where could I have learned this?
About once a month, the list gets a message announcing an upcoming release; here's the most recent one: https://www.redhat.com/archives/libvir-list/2010-September/msg00003.html -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On 09/07/2010 02:32 AM, Daniel Veillard wrote:
On Tue, Sep 07, 2010 at 10:19:56AM +0200, Soren Hansen wrote:
Extend user-mode-linux driver to support nwfilter.
We are supposed to be in feature freeze mode this week, but this looks simple enough and I don't think this can introduce regression, so ACK and I suggest to push this to git before Friday, unless someone disagrees,
I went ahead and pushed this one. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
participants (4)
-
Daniel Veillard
-
Eric Blake
-
Soren Hansen
-
Soren Hansen