virFirewallRuleAddArgList;
virFirewallRuleAddArgSet;
virFirewallRuleGetArgCount;
-virFirewallSetBackend;
virFirewallStartRollback;
virFirewallStartTransaction;
#include <stdarg.h>
-#define LIBVIRT_VIRFIREWALLPRIV_H_ALLOW
-#include "virfirewallpriv.h"
+#include "virfirewall.h"
#include "virfirewalld.h"
#include "viralloc.h"
#include "virerror.h"
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)
+++ /dev/null
-/*
- * 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);
# 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"
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)
#include "virbuffer.h"
#include "virfirewall.h"
-#define LIBVIRT_VIRFIREWALLPRIV_H_ALLOW
-#include "virfirewallpriv.h"
-
#define LIBVIRT_VIRCOMMANDPRIV_H_ALLOW
#include "vircommandpriv.h"
{
int ret = 0;
- if (virFirewallSetBackend(VIR_FIREWALL_BACKEND_DIRECT) < 0) {
- return EXIT_FAILURE;
- }
-
if (virTestRun("ebiptablesAllTeardown",
testNWFilterEBIPTablesAllTeardown,
NULL) < 0)
# 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"
ret = -1; \
} while (0)
- if (virFirewallSetBackend(VIR_FIREWALL_BACKEND_DIRECT) < 0) {
- return EXIT_FAILURE;
- }
-
DO_TEST("ah");
DO_TEST("ah-ipv6");
DO_TEST("all");
# 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"
{
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) \