[libvirt] [PATCH v2] nwfilter: fix loadable module support

Stefan Berger stefanb at linux.vnet.ibm.com
Wed Jun 16 15:09:15 UTC 2010


On 06/16/2010 08:02 AM, Daniel P. Berrange wrote:
>
>> +/* helper functions */
>> +
>> +static inline
>> +int virNWFilterInstantiateNWFilter(virConnectPtr conn,
>> +                                   const virDomainNetDefPtr net)
>> +{
>> +    return virDomainConfNWFilterInstantiate(conn, net);
>> +}
>> +
>> +/* tear down an interface's filter before tearing down the interface */
>> +static inline void
>> +virNWFilterTearNWFilter(virDomainNetDefPtr net) {
>> +    if ((net->filter)&&  (net->ifname))
>> +        virDomainConfNWFilterTeardown(net);
>> +}
>> +
>> +
>> +static inline void
>> +virNWFilterTearVMNWFilters(virDomainObjPtr vm) {
>> +    int i;
>> +
>> +    for (i = 0; i<  vm->def->nnets; i++)
>> +        virNWFilterTearNWFilter(vm->def->nets[i]);
>> +}
>>      
> I'd prefer it if we didn't add these inline functions. It is simple
> enough to just update the QEMU driver to call the new function
> names directly, instead of having the compat shim layer. Using the
> functions with new naming convention in QEMU driver code will make
> it more obvious to the person reading QEMU code that functions
> are calling into this code, rather than directly to nwfilter code.
>
>    
The reason why I previously had introduced them (I only moved the latter 
2) is that these functions get called several times (2, 5 and 2 times 
respectively) and I wanted to avoid replication of for example the tests 
(if-statement) in front of them. The virNWFilterTearVMNWFilters() calls 
the inline function virNWFilterTearNWFilter() while iterating over all 
the nets, so that also makes the code easier to read if one only has to 
call one function.

    Stefan
> Regards,
> Daniel
>    




More information about the libvir-list mailing list