[libvirt] [PATCH] test: fix nwfilter tests following changes in virfirewall.c

Eric Blake eblake at redhat.com
Wed Nov 26 16:11:10 UTC 2014


On 11/26/2014 08:58 AM, Stefan Berger wrote:
> Some of the nwfilter tests are now failing since --concurrent shows
> up in the ebtables command. To avoid this, implement a few functions
> that allow to set the booleans indicating how the locking is to be
> done to false, overriding the probing.
> 
> Signed-off-by: Stefan Berger <stefanb at linux.vnet.ibm.com>
> ---
>  src/libvirt_private.syms         |  3 +++
>  src/util/virfirewall.c           | 18 ++++++++++++++++++
>  src/util/virfirewall.h           |  4 ++++
>  tests/nwfilterebiptablestest.c   |  5 +++++
>  tests/nwfilterxml2firewalltest.c |  4 ++++
>  5 files changed, 34 insertions(+)
> 
> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index 2647d36..376826a 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -1353,7 +1353,10 @@ virFindFileInPath;
>  virFirewallAddRule;
>  virFirewallAddRuleFull;
>  virFirewallApply;
> +virFirewallEbtablesNotUseLock;

Awkward naming scheme.  If we keep it, I'd suggest
virFirewallEbtablesAvoidLock (and similar for the other functions).  But
see below for an alternative suggestion with fewer lines of code required:

> +++ b/src/util/virfirewall.c
> @@ -108,6 +108,24 @@ static bool iptablesUseLock;
>  static bool ip6tablesUseLock;
>  static bool ebtablesUseLock;
>  
> +void
> +virFirewallIptablesNotUseLock(void)
> +{
> +    iptablesUseLock = false;
> +}
> +
> +void
> +virFirewallIp6tablesNotUseLock(void)
> +{
> +    ip6tablesUseLock = false;
> +}

Rather than implementing 3 functions, why not just have one?  Something
like:

static bool lockOverride; /* true to avoid lock probes */
void
virFirewallSetLockOverride(bool avoid)
{
    lockOverride = avoid;
}

static void
virFirewallCheckUpdateLock(...)
{
    if (lockOverride)
        return;
    ... existing body
}

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 539 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20141126/0564a75b/attachment-0001.sig>


More information about the libvir-list mailing list