Since the currentBackend (direct vs. firewalld) setting is no longer
used for anything, we don't need to set it (either explicitly from
tests, or implicitly during init), and can completely remove it.
Signed-off-by: Laine Stump <laine(a)redhat.com>
---
src/libvirt_private.syms | 1 -
src/util/virfirewall.c | 50 ++------------------------------
src/util/virfirewallpriv.h | 37 -----------------------
tests/networkxml2firewalltest.c | 8 +----
tests/nwfilterebiptablestest.c | 7 -----
tests/nwfilterxml2firewalltest.c | 8 +----
tests/virfirewalltest.c | 7 ++---
7 files changed, 6 insertions(+), 112 deletions(-)
delete mode 100644 src/util/virfirewallpriv.h
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 23385ec7a1..bb90659365 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2316,7 +2316,6 @@ virFirewallRuleAddArgFormat;
virFirewallRuleAddArgList;
virFirewallRuleAddArgSet;
virFirewallRuleGetArgCount;
-virFirewallSetBackend;
virFirewallStartRollback;
virFirewallStartTransaction;
diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c
index 1e6c667ee1..98d78857df 100644
--- a/src/util/virfirewall.c
+++ b/src/util/virfirewall.c
@@ -22,8 +22,7 @@
#include <stdarg.h>
-#define LIBVIRT_VIRFIREWALLPRIV_H_ALLOW
-#include "virfirewallpriv.h"
+#include "virfirewall.h"
#include "virfirewalld.h"
#include "viralloc.h"
#include "virerror.h"
@@ -81,61 +80,16 @@ struct _virFirewall {
size_t currentGroup;
};
-static virFirewallBackend currentBackend = VIR_FIREWALL_BACKEND_AUTOMATIC;
static virMutex ruleLock = VIR_MUTEX_INITIALIZER;
-static int
-virFirewallValidateBackend(virFirewallBackend backend);
-
static int
virFirewallOnceInit(void)
{
- return virFirewallValidateBackend(currentBackend);
-}
-
-VIR_ONCE_GLOBAL_INIT(virFirewall);
-
-static int
-virFirewallValidateBackend(virFirewallBackend backend)
-{
- if (backend == VIR_FIREWALL_BACKEND_AUTOMATIC ||
- backend == VIR_FIREWALL_BACKEND_FIREWALLD) {
- int rv = virFirewallDIsRegistered();
-
- VIR_DEBUG("Firewalld is registered ? %d", rv);
-
- if (rv == -1)
- return -1;
-
- if (rv == -2) {
- if (backend == VIR_FIREWALL_BACKEND_FIREWALLD) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("firewalld backend requested, but service is not
running"));
- return -1;
- } else {
- VIR_DEBUG("firewalld service not running, using direct
backend");
- backend = VIR_FIREWALL_BACKEND_DIRECT;
- }
- } else {
- VIR_DEBUG("firewalld service running, using firewalld backend");
- backend = VIR_FIREWALL_BACKEND_FIREWALLD;
- }
- }
-
- currentBackend = backend;
return 0;
}
-int
-virFirewallSetBackend(virFirewallBackend backend)
-{
- currentBackend = backend;
-
- if (virFirewallInitialize() < 0)
- return -1;
+VIR_ONCE_GLOBAL_INIT(virFirewall);
- return virFirewallValidateBackend(backend);
-}
static virFirewallGroup *
virFirewallGroupNew(void)
diff --git a/src/util/virfirewallpriv.h b/src/util/virfirewallpriv.h
deleted file mode 100644
index b846f8799c..0000000000
--- a/src/util/virfirewallpriv.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * virfirewallpriv.h: integration with firewalls private APIs
- *
- * Copyright (C) 2013 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see
- * <
http://www.gnu.org/licenses/>.
- */
-
-#ifndef LIBVIRT_VIRFIREWALLPRIV_H_ALLOW
-# error "virfirewallpriv.h may only be included by virfirewall.c or test
suites"
-#endif /* LIBVIRT_VIRFIREWALLPRIV_H_ALLOW */
-
-#pragma once
-
-#include "virfirewall.h"
-
-typedef enum {
- VIR_FIREWALL_BACKEND_AUTOMATIC,
- VIR_FIREWALL_BACKEND_DIRECT,
- VIR_FIREWALL_BACKEND_FIREWALLD,
-
- VIR_FIREWALL_BACKEND_LAST,
-} virFirewallBackend;
-
-int virFirewallSetBackend(virFirewallBackend backend);
diff --git a/tests/networkxml2firewalltest.c b/tests/networkxml2firewalltest.c
index 68a82e60d6..11be85e06f 100644
--- a/tests/networkxml2firewalltest.c
+++ b/tests/networkxml2firewalltest.c
@@ -31,9 +31,7 @@
# include "network/bridge_driver_platform.h"
# include "virbuffer.h"
# include "virmock.h"
-
-# define LIBVIRT_VIRFIREWALLPRIV_H_ALLOW
-# include "virfirewallpriv.h"
+# include "virfirewall.h"
# define LIBVIRT_VIRCOMMANDPRIV_H_ALLOW
# include "vircommandpriv.h"
@@ -167,10 +165,6 @@ mymain(void)
ret = -1; \
} while (0)
- if (virFirewallSetBackend(VIR_FIREWALL_BACKEND_DIRECT) < 0) {
- return EXIT_FAILURE;
- }
-
basefile = g_strdup_printf("%s/networkxml2firewalldata/base.args",
abs_srcdir);
if (virFileReadAll(basefile, INT_MAX, &baseargs) < 0)
diff --git a/tests/nwfilterebiptablestest.c b/tests/nwfilterebiptablestest.c
index 9307a10229..35c1c772ae 100644
--- a/tests/nwfilterebiptablestest.c
+++ b/tests/nwfilterebiptablestest.c
@@ -26,9 +26,6 @@
#include "virbuffer.h"
#include "virfirewall.h"
-#define LIBVIRT_VIRFIREWALLPRIV_H_ALLOW
-#include "virfirewallpriv.h"
-
#define LIBVIRT_VIRCOMMANDPRIV_H_ALLOW
#include "vircommandpriv.h"
@@ -460,10 +457,6 @@ mymain(void)
{
int ret = 0;
- if (virFirewallSetBackend(VIR_FIREWALL_BACKEND_DIRECT) < 0) {
- return EXIT_FAILURE;
- }
-
if (virTestRun("ebiptablesAllTeardown",
testNWFilterEBIPTablesAllTeardown,
NULL) < 0)
diff --git a/tests/nwfilterxml2firewalltest.c b/tests/nwfilterxml2firewalltest.c
index 857214dde5..ec37a4ae11 100644
--- a/tests/nwfilterxml2firewalltest.c
+++ b/tests/nwfilterxml2firewalltest.c
@@ -26,9 +26,7 @@
# include "testutils.h"
# include "nwfilter/nwfilter_ebiptables_driver.h"
# include "virbuffer.h"
-
-# define LIBVIRT_VIRFIREWALLPRIV_H_ALLOW
-# include "virfirewallpriv.h"
+# include "virfirewall.h"
# define LIBVIRT_VIRCOMMANDPRIV_H_ALLOW
# include "vircommandpriv.h"
@@ -423,10 +421,6 @@ mymain(void)
ret = -1; \
} while (0)
- if (virFirewallSetBackend(VIR_FIREWALL_BACKEND_DIRECT) < 0) {
- return EXIT_FAILURE;
- }
-
DO_TEST("ah");
DO_TEST("ah-ipv6");
DO_TEST("all");
diff --git a/tests/virfirewalltest.c b/tests/virfirewalltest.c
index 724d3081f1..8a0ca6be07 100644
--- a/tests/virfirewalltest.c
+++ b/tests/virfirewalltest.c
@@ -25,10 +25,10 @@
# include <gio/gio.h>
# include "virbuffer.h"
+# include "virfirewall.h"
+
# define LIBVIRT_VIRCOMMANDPRIV_H_ALLOW
# include "vircommandpriv.h"
-# define LIBVIRT_VIRFIREWALLPRIV_H_ALLOW
-# include "virfirewallpriv.h"
# define LIBVIRT_VIRFIREWALLDPRIV_H_ALLOW
# include "virfirewalldpriv.h"
# include "virmock.h"
@@ -779,9 +779,6 @@ mymain(void)
{
int ret = 0;
- if (virFirewallSetBackend(VIR_FIREWALL_BACKEND_DIRECT) < 0)
- return EXIT_FAILURE;
-
# define RUN_TEST(name, method) \
do { \
if (virTestRun(name, method, NULL) < 0) \
--
2.33.1