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

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@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; virFirewallFree; +virFirewallIp6tablesNotUseLock; +virFirewallIptablesNotUseLock; virFirewallNew; virFirewallRemoveRule; virFirewallRuleAddArg; diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c index 8496062..5df2a5f 100644 --- a/src/util/virfirewall.c +++ 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; +} + +void +virFirewallEbtablesNotUseLock(void) +{ + ebtablesUseLock = false; +} + static void virFirewallCheckUpdateLock(bool *lockflag, const char *const*args) diff --git a/src/util/virfirewall.h b/src/util/virfirewall.h index 1129219..aa72a76 100644 --- a/src/util/virfirewall.h +++ b/src/util/virfirewall.h @@ -106,4 +106,8 @@ void virFirewallStartRollback(virFirewallPtr firewall, int virFirewallApply(virFirewallPtr firewall); +void virFirewallIptablesNotUseLock(void); +void virFirewallIp6tablesNotUseLock(void); +void virFirewallEbtablesNotUseLock(void); + #endif /* __VIR_FIREWALL_H__ */ diff --git a/tests/nwfilterebiptablestest.c b/tests/nwfilterebiptablestest.c index e04bc21..e18a6c7 100644 --- a/tests/nwfilterebiptablestest.c +++ b/tests/nwfilterebiptablestest.c @@ -24,6 +24,7 @@ #include "testutils.h" #include "nwfilter/nwfilter_ebiptables_driver.h" #include "virbuffer.h" +#include "virfirewall.h" #define __VIR_FIREWALL_PRIV_H_ALLOW__ #include "virfirewallpriv.h" @@ -527,6 +528,10 @@ mymain(void) goto cleanup; } + virFirewallEbtablesNotUseLock(); + virFirewallIptablesNotUseLock(); + virFirewallIp6tablesNotUseLock(); + if (virtTestRun("ebiptablesAllTeardown", testNWFilterEBIPTablesAllTeardown, NULL) < 0) diff --git a/tests/nwfilterxml2firewalltest.c b/tests/nwfilterxml2firewalltest.c index 01527f4..f6ef0e0 100644 --- a/tests/nwfilterxml2firewalltest.c +++ b/tests/nwfilterxml2firewalltest.c @@ -479,6 +479,10 @@ mymain(void) goto cleanup; } + virFirewallEbtablesNotUseLock(); + virFirewallIptablesNotUseLock(); + virFirewallIp6tablesNotUseLock(); + DO_TEST("ah"); DO_TEST("ah-ipv6"); DO_TEST("all"); -- 1.9.3

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@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
participants (2)
-
Eric Blake
-
Stefan Berger