From nobody Mon Feb 9 18:19:32 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=1661175156; cv=none; d=zohomail.com; s=zohoarc; b=l7QtnEY8Msqgb+mDfy0EFoP3v/w8F3hNiy8EZ2oBNSKDPm87/rFx4cWytUKIDWRL/kVkpoRdaSY/btykh+U2wmqj35iby8BCvzuZTd2QKhcNk8cqiXluMEJs9LT6v/PBr1EC5SA358lEwT5Tt1YzkRuQ2meCHAXIt9Lre7MX6F4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661175156; 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=hsFld66vmjGl8fZQdSfyXAPDo4m1GZWhe8Rrdzsoc7M=; b=QO/nWNFVTQqGVSWKJqgyu5ADvzm2RNsDvwGnhIG/eBuGqzp33u/aF20tbjgTQxzG0swmnV//r7fnaXRvABMJ/v3xw68SOvssLIIto/WOySAhQXJqspA4egp8le4w+sOQ05GASOw+9a5ul3hFSnjOL8nCDvnI1BsbwAamP5X3GfI= 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 1661175156950382.6618790406485; Mon, 22 Aug 2022 06:32:36 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-528-ahbSCrESM4K2QV5vKzo73w-1; Mon, 22 Aug 2022 09:32:30 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7D94B299E74D; Mon, 22 Aug 2022 13:32:28 +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 6906F1121314; Mon, 22 Aug 2022 13:32:28 +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 0FEEC1946A7E; Mon, 22 Aug 2022 13:32:28 +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 6DFC41946A67 for ; Mon, 22 Aug 2022 13:31:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1B8AB40CFD10; Mon, 22 Aug 2022 13:31:53 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.2.16.254]) by smtp.corp.redhat.com (Postfix) with ESMTP id 05D4E40CFD0A 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=1661175155; 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=hsFld66vmjGl8fZQdSfyXAPDo4m1GZWhe8Rrdzsoc7M=; b=giHvDbeEk8g6hp1AxWzveCcidnjkj2+uSmiNX3QUYPJmc822BFZutmno7Lb3zmT5Bugjn2 0b//D7MxWSi6DYZNF/k5NTJCJKah1kHQtetVt8u4YIUE4PduFUSY3jGXRr6siqXnX+Q+xo PC7ycavjKAr+FHQr0fkbFHx4zJyV3NI= X-MC-Unique: ahbSCrESM4K2QV5vKzo73w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 16/16] util: don't use virFirewallRuleToString() to log the rule being applied Date: Mon, 22 Aug 2022 09:31:50 -0400 Message-Id: <20220822133150.1098794-17-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.3 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: 1661175157411100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Instead of separately building the commandline into a string to log, just wait a few lines until we've built the virCommand object, and call virCommandToString, which does the same thing. (As a bonus, we were already calling virCommandToString to put the commandline in a string in case of a failure when running it - from the point of view of *that* usage, we're just moving the call to virCommandToString *up* a few lines, i.e. we now only construct the commandline string once.) Signed-off-by: Laine Stump --- src/util/virfirewall.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c index 247430be2e..fbb0e438b3 100644 --- a/src/util/virfirewall.c +++ b/src/util/virfirewall.c @@ -486,6 +486,7 @@ virFirewallApplyRuleDirect(virFirewallRule *rule, size_t i; const char *bin =3D virFirewallLayerCommandTypeToString(rule->layer); g_autoptr(virCommand) cmd =3D NULL; + g_autofree char *cmdStr =3D NULL; int status; g_autofree char *error =3D NULL; =20 @@ -501,6 +502,9 @@ virFirewallApplyRuleDirect(virFirewallRule *rule, for (i =3D 0; i < rule->argsLen; i++) virCommandAddArg(cmd, rule->args[i]); =20 + cmdStr =3D virCommandToString(cmd, false); + VIR_INFO("Applying rule '%s'", NULLSTR(cmdStr)); + virCommandSetOutputBuffer(cmd, output); virCommandSetErrorBuffer(cmd, &error); =20 @@ -511,10 +515,9 @@ virFirewallApplyRuleDirect(virFirewallRule *rule, if (ignoreErrors) { VIR_DEBUG("Ignoring error running command"); } else { - g_autofree char *args =3D virCommandToString(cmd, false); virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to apply firewall rules %s: %s"), - NULLSTR(args), NULLSTR(error)); + NULLSTR(cmdStr), NULLSTR(error)); VIR_FREE(*output); return -1; } @@ -531,10 +534,6 @@ virFirewallApplyRule(virFirewall *firewall, { g_autofree char *output =3D NULL; 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) ignoreErrors =3D rule->ignoreErrors; --=20 2.37.1