]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
network: ignore/don't log errors when unsetting firewalld zone
authorLaine Stump <laine@redhat.com>
Mon, 21 Oct 2024 17:55:16 +0000 (13:55 -0400)
committerLaine Stump <laine@redhat.com>
Thu, 24 Oct 2024 15:50:41 +0000 (11:50 -0400)
The most common "error" when trying to unset the firewalld zone of an
interface is for firewalld to tell us that the interface already isn't
in any zone. Since this is what we want, no need to alarm the user by
logging it as an error.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virfirewalld.c
src/util/virfirewalld.h

index ca61ed5ac0266528a29a9a234c1a6c725cca0b14..0a886780add0ee821a651b88592f2785d3c8c8f3 100644 (file)
@@ -449,26 +449,37 @@ virFirewallDInterfaceSetZone(const char *iface,
 }
 
 
-int
+void
 virFirewallDInterfaceUnsetZone(const char *iface)
 {
     GDBusConnection *sysbus = virGDBusGetSystemBus();
     g_autoptr(GVariant) message = NULL;
+    g_autoptr(virError) error = NULL;
 
     if (!sysbus)
-        return -1;
+        return;
+
+    /* we are sending virGDBusCallMethod an error object so that it
+     * will put the error message there rather than logging it,
+     * because we want to ignore any error as it doesn't matter - the
+     * most common "error" is to inform us that the interface is
+     * already not in any zone, and that is of course just fine, since
+     * that's what we're trying to do anyway. If there is an error,
+     * we'll just throw it away without logging it anywhere.
+     */
+    error = g_new0(virError, 1);
 
     message = g_variant_new("(ss)", "", iface);
 
-    return virGDBusCallMethod(sysbus,
-                              NULL,
-                              NULL,
-                              NULL,
-                              VIR_FIREWALL_FIREWALLD_SERVICE,
-                              "/org/fedoraproject/FirewallD1",
-                              "org.fedoraproject.FirewallD1.zone",
-                              "removeInterface",
-                              message);
+    virGDBusCallMethod(sysbus,
+                       NULL,
+                       NULL,
+                       error,
+                       VIR_FIREWALL_FIREWALLD_SERVICE,
+                       "/org/fedoraproject/FirewallD1",
+                       "org.fedoraproject.FirewallD1.zone",
+                       "removeInterface",
+                       message);
 }
 
 
index 0dbe66d435d355a30f6b09389247439d431479f3..43803ee89ad817a31b0f1f1739d93eccd3e350e3 100644 (file)
@@ -46,6 +46,6 @@ int virFirewallDApplyRule(virFirewallLayer layer,
 int virFirewallDInterfaceSetZone(const char *iface,
                                  const char *zone);
 
-int virFirewallDInterfaceUnsetZone(const char *iface);
+void virFirewallDInterfaceUnsetZone(const char *iface);
 
 void virFirewallDSynchronize(void);