From nobody Tue Feb 10 03:37:29 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=1661175190; cv=none; d=zohomail.com; s=zohoarc; b=Kf0/8bEdLHyRLl5eTcbelk7uOqdLgNORpe1SZruivqSFuVyU9ywyTwPQlZdIZNjyMBWcTkgVFzEt/HqCt9KJLGB12HLinQPlYjJV7giSkJhRgLD6y+ohmc5sgewC9RAhg0rGRUOARlh0rZWY7XRq3snE/yJ+7jXx2QPgtruhFOY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661175190; 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=y5P4xWoFfdUW/Z5AWkrChLXIreZz8usZZPxZpvV7xnE=; b=NL+ExhgE/9QcQ8VTv1pmyWK9JYRt98Wl7+d3T9qazRa3Ekp+O3wzju/0jTgwAFCIDJi3fZdtOaQYmLLIkmowP6e2hjyPPNy48OQBb94SFfUpM8B16TH07zsInSgUeiYrTFKIEmBN72XT/Xh+WiU66y7RvMqlVAcdXiWxeGZnE6o= 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 1661175190864780.9432985198698; Mon, 22 Aug 2022 06:33:10 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-52-V-M0cYvdM8yZI87PzDH_gg-1; Mon, 22 Aug 2022 09:32:16 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BD8A98039C1; Mon, 22 Aug 2022 13:32:11 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id ABCB42026D4C; Mon, 22 Aug 2022 13:32:11 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7F02B1946A62; Mon, 22 Aug 2022 13:32:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 041901946A62 for ; Mon, 22 Aug 2022 13:31:52 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id ED96240CFD0D; Mon, 22 Aug 2022 13:31:52 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.2.16.254]) by smtp.corp.redhat.com (Postfix) with ESMTP id D961E40CFD0A for ; Mon, 22 Aug 2022 13:31:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661175188; 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=y5P4xWoFfdUW/Z5AWkrChLXIreZz8usZZPxZpvV7xnE=; b=dwKkdu9r/3X1fyPAEOIKt6PsiLF2CP7w0i+Gc6cCAT/fUtAc5gPf+q9HckOvTSIlWprFo+ buahpvHKzBZRWQ5Sf+pt2sOr7Bw/W+tL12GNDBbb8S9JCj5JaObmVxsQ066fXhuelWrFwK z32HbbQi4uvdmZC6eWYHp8C+uG9VYfc= X-MC-Unique: V-M0cYvdM8yZI87PzDH_gg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 15/16] util: make virFirewallRuleToString() global Date: Mon, 22 Aug 2022 09:31:49 -0400 Message-Id: <20220822133150.1098794-16-laine@redhat.com> In-Reply-To: <20220822133150.1098794-1-laine@redhat.com> References: <20220822133150.1098794-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 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: 1661175191490100006 Content-Type: text/plain; charset="utf-8"; x-default="true" Although the next commit will eliminate the one current use of virFirewallRuleToString(), a future commit will once again have a use for it, but in a different source file so it will need to be a global function rather than static. Make that change now so that we don't get a compile error from having an unused static function in the next commit. (The arg list is also changed to include the name of the command as a separate argument rather than just assuming that it can be derived from the rule's layer (which is correct for iptables, but won't be correct for nftables)). Signed-off-by: Laine Stump --- src/libvirt_private.syms | 1 + src/util/virfirewall.c | 13 ++++++++----- src/util/virfirewall.h | 3 +++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index ac2802095e..f739259375 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2352,6 +2352,7 @@ virFirewallRuleAddArgFormat; virFirewallRuleAddArgList; virFirewallRuleAddArgSet; virFirewallRuleGetArgCount; +virFirewallRuleToString; virFirewallStartRollback; virFirewallStartTransaction; =20 diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c index 0a9ba9ad5c..247430be2e 100644 --- a/src/util/virfirewall.c +++ b/src/util/virfirewall.c @@ -461,14 +461,14 @@ void virFirewallStartRollback(virFirewall *firewall, } =20 =20 -static char * -virFirewallRuleToString(virFirewallRule *rule) +char * +virFirewallRuleToString(const char *cmd, + virFirewallRule *rule) { - const char *bin =3D virFirewallLayerCommandTypeToString(rule->layer); g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; size_t i; =20 - virBufferAdd(&buf, bin, -1); + virBufferAdd(&buf, cmd, -1); for (i =3D 0; i < rule->argsLen; i++) { virBufferAddLit(&buf, " "); virBufferAdd(&buf, rule->args[i], -1); @@ -477,6 +477,7 @@ virFirewallRuleToString(virFirewallRule *rule) return virBufferContentAndReset(&buf); } =20 + static int virFirewallApplyRuleDirect(virFirewallRule *rule, bool ignoreErrors, @@ -529,8 +530,10 @@ virFirewallApplyRule(virFirewall *firewall, bool ignoreErrors) { g_autofree char *output =3D NULL; - g_autofree char *str =3D virFirewallRuleToString(rule); g_auto(GStrv) lines =3D NULL; + g_autofree char *str + =3D virFirewallRuleToString(virFirewallLayerCommandTypeToString(ru= le->layer), rule); + VIR_INFO("Applying rule '%s'", NULLSTR(str)); =20 if (rule->ignoreErrors) diff --git a/src/util/virfirewall.h b/src/util/virfirewall.h index 7448825dbc..187748b2bf 100644 --- a/src/util/virfirewall.h +++ b/src/util/virfirewall.h @@ -89,6 +89,9 @@ void virFirewallRuleAddArgList(virFirewall *firewall, =20 size_t virFirewallRuleGetArgCount(virFirewallRule *rule); =20 +char *virFirewallRuleToString(const char *cmd, + virFirewallRule *rule); + typedef enum { /* Ignore all errors when applying rules, so no * rollback block will be required */ --=20 2.37.1