From nobody Mon Feb 9 23:57:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1639338623; cv=none; d=zohomail.com; s=zohoarc; b=RUy3X7m1e3E8/FNrTEvM+gJyABm6eixJGxnqtJfZi2YuoQY/DKGdbGqQYLiboV+UJPnts5NFkTfAasBM4ZvWTh9UQFBukPE17+hRzU0sFKKl7BqTlUcn8dgXD7QEliI905L0OLO3slnwZnR0R0wYHr8zZaKZY91mq5tdfUgu0RI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639338623; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=c29730AugVVetIJL1KChhF/mR2vSFJGupO4eeElN3Gw=; b=QdvXJtmjoDKqCUOFgg11y6jXyxeI5vr2MZk2atZJJu5DwKpeBD2VzuiiPndWrPj5BVIQQUXaOLnPv+G3yqmBdNtyFQMXZYATru73GTtpTkU6mMyu68feQyTRjvz203k6e1QeWHIzXLkuY3epFOXwbxEt3aEU6d3A9QeOTnk2yCc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1639338623383700.5689759971041; Sun, 12 Dec 2021 11:50:23 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-546-XgqGkAbONameybyvknn3jA-1; Sun, 12 Dec 2021 14:49:11 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A63DD1853036; Sun, 12 Dec 2021 19:49:01 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8872B22DFE; Sun, 12 Dec 2021 19:49:01 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5D22F4A70B; Sun, 12 Dec 2021 19:49:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BCJmbZY018904 for ; Sun, 12 Dec 2021 14:48:37 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9ADB65BE03; Sun, 12 Dec 2021 19:48:37 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.2.16.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 67ED05D6D7 for ; Sun, 12 Dec 2021 19:48:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639338622; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=c29730AugVVetIJL1KChhF/mR2vSFJGupO4eeElN3Gw=; b=PxbY4T0WYtABVSHa/nqQPwHDnT5d3e/+TkgwLoL7Ds9Kz3VGQSX8j1Re3ey8ug4AQ+B58R YfklHz5g/oE0/ye4uYFcruthDytgHFE5Ghm1TWuthyD/FjZlbC02QzR3l5RBBn00PA115W Yvh7gpe7R309/N4hCo+iAqTUcVVc8Hw= X-MC-Unique: XgqGkAbONameybyvknn3jA-1 From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 11/12] util: remove currentBackend from virfirewall.c Date: Sun, 12 Dec 2021 14:48:29 -0500 Message-Id: <20211212194830.292379-12-laine@redhat.com> In-Reply-To: <20211212194830.292379-1-laine@redhat.com> References: <20211212194830.292379-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639338624965100001 Content-Type: text/plain; charset="utf-8" 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 --- 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; =20 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 @@ =20 #include =20 -#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; }; =20 -static virFirewallBackend currentBackend =3D VIR_FIREWALL_BACKEND_AUTOMATI= C; static virMutex ruleLock =3D VIR_MUTEX_INITIALIZER; =20 -static int -virFirewallValidateBackend(virFirewallBackend backend); - static int virFirewallOnceInit(void) { - return virFirewallValidateBackend(currentBackend); -} - -VIR_ONCE_GLOBAL_INIT(virFirewall); - -static int -virFirewallValidateBackend(virFirewallBackend backend) -{ - if (backend =3D=3D VIR_FIREWALL_BACKEND_AUTOMATIC || - backend =3D=3D VIR_FIREWALL_BACKEND_FIREWALLD) { - int rv =3D virFirewallDIsRegistered(); - - VIR_DEBUG("Firewalld is registered ? %d", rv); - - if (rv =3D=3D -1) - return -1; - - if (rv =3D=3D -2) { - if (backend =3D=3D 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 bac= kend"); - backend =3D VIR_FIREWALL_BACKEND_DIRECT; - } - } else { - VIR_DEBUG("firewalld service running, using firewalld backend"= ); - backend =3D VIR_FIREWALL_BACKEND_FIREWALLD; - } - } - - currentBackend =3D backend; return 0; } =20 -int -virFirewallSetBackend(virFirewallBackend backend) -{ - currentBackend =3D backend; - - if (virFirewallInitialize() < 0) - return -1; +VIR_ONCE_GLOBAL_INIT(virFirewall); =20 - return virFirewallValidateBackend(backend); -} =20 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 - * . - */ - -#ifndef LIBVIRT_VIRFIREWALLPRIV_H_ALLOW -# error "virfirewallpriv.h may only be included by virfirewall.c or test s= uites" -#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/networkxml2firewalltes= t.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" =20 # define LIBVIRT_VIRCOMMANDPRIV_H_ALLOW # include "vircommandpriv.h" @@ -167,10 +165,6 @@ mymain(void) ret =3D -1; \ } while (0) =20 - if (virFirewallSetBackend(VIR_FIREWALL_BACKEND_DIRECT) < 0) { - return EXIT_FAILURE; - } - basefile =3D g_strdup_printf("%s/networkxml2firewalldata/base.args", a= bs_srcdir); =20 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" =20 -#define LIBVIRT_VIRFIREWALLPRIV_H_ALLOW -#include "virfirewallpriv.h" - #define LIBVIRT_VIRCOMMANDPRIV_H_ALLOW #include "vircommandpriv.h" =20 @@ -460,10 +457,6 @@ mymain(void) { int ret =3D 0; =20 - if (virFirewallSetBackend(VIR_FIREWALL_BACKEND_DIRECT) < 0) { - return EXIT_FAILURE; - } - if (virTestRun("ebiptablesAllTeardown", testNWFilterEBIPTablesAllTeardown, NULL) < 0) diff --git a/tests/nwfilterxml2firewalltest.c b/tests/nwfilterxml2firewallt= est.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" =20 # define LIBVIRT_VIRCOMMANDPRIV_H_ALLOW # include "vircommandpriv.h" @@ -423,10 +421,6 @@ mymain(void) ret =3D -1; \ } while (0) =20 - 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 =20 # 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 =3D 0; =20 - if (virFirewallSetBackend(VIR_FIREWALL_BACKEND_DIRECT) < 0) - return EXIT_FAILURE; - # define RUN_TEST(name, method) \ do { \ if (virTestRun(name, method, NULL) < 0) \ --=20 2.33.1