Re: [PATCH] [RFC] nwfilter: fix loadable module support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jun 14, 2010 at 07:49:50AM -0400, Stefan Berger wrote:
> Hello!
> 
> I am trying to fix the loadable modules support by removing all direct 
> calls from qemu_driver.c and qemu_conf.c into nwfilter functions. The 
> below patch extends the nwfilter driver interface with 2 more private 
> functions to instantiate and tear down the filters. I call them 
> 'private' because no client should ever be calling them via RPC and be 
> able to tear down the filters for example -- they should only ever be 
> callable from within libvirtd.
> 
> I extended the qemudShutdownVMDaemon function with the virConnectPtr 
> type of parameter so that I have the pointer to conn->nwfilterDriver to 
> access the private nwfilter driver functions. The problem with that is 
> that the conn pointer is not always available to be passed 
> (qemuReconnectDomain, qemuHandleMonitorEOF), particularly in tear-down 
> functions, and so I have to pass a NULL pointer, which then prevents the 
> calling of the private interface function to tear down the filters.Does 
> anyone have a suggestion on how I would best change the interface with 
> the nwfilter driver to fix this particular problem?

This problem is an artifact of trying to hook this into the main API
driver tables.

In our architecture we want the nwfilter & qemu drivers to be separately
loadable modules, without any hard dependancy between them in either
direction.

Thus the first step is to kill the following two includes from the QEMU
driver source, since using any functions from this header implies that
there's a hard compile time dependancy from QEMU to nwfilter

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index a4f06fb..6d99044 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -54,7 +54,6 @@
 #include "network.h"
 #include "macvtap.h"
 #include "cpu/cpu.h"
-#include "nwfilter/nwfilter_gentech_driver.h"
 
 #define VIR_FROM_THIS VIR_FROM_QEMU
 
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 670ef5d..f9deff6 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -81,7 +81,6 @@
 #include "xml.h"
 #include "cpu/cpu.h"
 #include "macvtap.h"
-#include "nwfilter/nwfilter_gentech_driver.h"
 #include "hooks.h"
 #include "storage_file.h"
 

The resulting compile errors show:

qemu/qemu_conf.c: In function ‘qemudNetworkIfaceConnect’:
qemu/qemu_conf.c:1694: error: implicit declaration of function ‘virNWFilterInstantiateFilter’ [-Wimplicit-function-declaration]
qemu/qemu_conf.c:1694: error: nested extern declaration of ‘virNWFilterInstantiateFilter’ [-Wnested-externs]
qemu/qemu_conf.c: In function ‘qemudBuildCommandLine’:
qemu/qemu_conf.c:4213: error: implicit declaration of function ‘virNWFilterTearNWFilter’ [-Wimplicit-function-declaration]
qemu/qemu_conf.c:4213: error: nested extern declaration of ‘virNWFilterTearNWFilter’ [-Wnested-externs]
qemu/qemu_driver.c: In function ‘qemudStartVMDaemon’:
qemu/qemu_driver.c:3566: error: implicit declaration of function ‘virNWFilterTearVMNWFilters’ [-Wimplicit-function-declaration]
qemu/qemu_driver.c:3566: error: nested extern declaration of ‘virNWFilterTearVMNWFilters’ [-Wnested-externs]
qemu/qemu_driver.c: In function ‘qemudDomainAttachNetDevice’:
qemu/qemu_driver.c:7634: error: implicit declaration of function ‘virNWFilterTearNWFilter’ [-Wimplicit-function-declaration]
qemu/qemu_driver.c:7634: error: nested extern declaration of ‘virNWFilterTearNWFilter’ [-Wnested-externs]


For loadable modules to work, we need to be able to call those
functions regardless of whether any module is loaded. I would
thus suggest we introduce two new files:

    src/conf/domain_nwfilter.h
    src/conf/domain_nwfilter.c

And add them to DOMAIN_CONF_SOURCES  in Makefile.am so that they
are compiled into the main binary at all times, thus accessible
to all driver loadable modules.

They should not contain any functional code, just be a glue layer
similar to driver.h, but without any virConnectPtr involved:

   typedef int (*virDomainConfNetFilterSetupDrv)(virDomainNetDefPtr net);
   typedef int (*virDomainConfNetFilterCleanupDrv)(virDomainNetDefPtr net);

   typedef struct {
      virDomainConfNetFilterSetupDrv net;
      virDomainConfNetFilterCleanupDrv net;
   } virDomainConfNetFilterDrv;

   void virDomainConfNetFilterRegister(virDomainConfNetFilterDrv driver);

   int virDomainConfNetFilterSetup(virDomainNetDefPtr net);
   int virDomainConfNetFilterCleanup(virDomainNetDefPtr net);


So, when the nwfilter driver is loaded it calls virDomainConfNetFilterRegister()
to register the setup/teardown functions.

When QEMU needs to add/remove a NIC it calls virDomainConfNetFilterSetup
and virDomainConfNetFilterCleanup appropriately. None of the code now 
requires any virConnectPtr object, and we have totally decoupled the
QEMU and NWfilter drivers


Regards,
Daniel
-- 
|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]