]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: remove currentBackend from virfirewall.c
authorLaine Stump <laine@redhat.com>
Tue, 16 Nov 2021 19:27:00 +0000 (14:27 -0500)
committerLaine Stump <laine@redhat.com>
Mon, 13 Dec 2021 18:37:31 +0000 (13:37 -0500)
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@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/libvirt_private.syms
src/util/virfirewall.c
src/util/virfirewallpriv.h [deleted file]
tests/networkxml2firewalltest.c
tests/nwfilterebiptablestest.c
tests/nwfilterxml2firewalltest.c
tests/virfirewalltest.c

index ae2390132957c85c2454746f5b906151420cecd7..4e9b616621b98e49aab14043d045548adda87f6e 100644 (file)
@@ -2316,7 +2316,6 @@ virFirewallRuleAddArgFormat;
 virFirewallRuleAddArgList;
 virFirewallRuleAddArgSet;
 virFirewallRuleGetArgCount;
-virFirewallSetBackend;
 virFirewallStartRollback;
 virFirewallStartTransaction;
 
index 1e6c667ee1e5073f248aeb48cb1ffe0ee9795b8f..98d78857df5d3d422d937fc59590c4607c807186 100644 (file)
@@ -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 (file)
index b846f87..0000000
+++ /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);
index 68a82e60d6816c1117bab7ef4c4ed21b69a0816d..11be85e06f2e9d051e0c4976e5897a685a34207b 100644 (file)
@@ -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)
index 9307a10229f3f6735fbfea9d3a1eb763675bd41c..35c1c772ae15fb48b96f8a86217144e8e72b4acc 100644 (file)
@@ -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)
index 857214dde54c35e471974cd6a384e1e6264155eb..ec37a4ae1158bab0beb8528cf26a9a24df71709a 100644 (file)
@@ -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");
index 724d3081f1b56bfb60951d047d5a02cb1042b7f4..8a0ca6be070e1ec3815390eff4a7f7bef95e707b 100644 (file)
 # 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) \