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

Daniel Veillard veillard at redhat.com
Tue Sep 7 08:32:52 UTC 2010


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 at 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 at veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/




More information about the libvir-list mailing list