mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
util: remove currentBackend from virfirewall.c
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>
This commit is contained in:
parent
ab238e23b4
commit
d566cc55bf
@ -2316,7 +2316,6 @@ virFirewallRuleAddArgFormat;
|
||||
virFirewallRuleAddArgList;
|
||||
virFirewallRuleAddArgSet;
|
||||
virFirewallRuleGetArgCount;
|
||||
virFirewallSetBackend;
|
||||
virFirewallStartRollback;
|
||||
virFirewallStartTransaction;
|
||||
|
||||
|
@ -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);
|
||||
return 0;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
return virFirewallValidateBackend(backend);
|
||||
}
|
||||
|
||||
static virFirewallGroup *
|
||||
virFirewallGroupNew(void)
|
||||
|
@ -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);
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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");
|
||||
|
@ -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) \
|
||||
|
Loading…
Reference in New Issue
Block a user