[PATCH 0/2] Silence more DBus errors

This is basically a follow up to [1] as new places were identified which suffer the same problem. 1: https://lists.libvirt.org/archives/list/devel@lists.libvirt.org/thread/WGFBR... Michal Prívozník (2): virinhibitor: Suppress reporting an error when D-Bus is unavailable in virInhibitorAcquire() network: Suppress reporting an error when D-Bus is unavailable in networkStateInitialize() src/network/bridge_driver.c | 3 ++- src/util/virinhibitor.c | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) -- 2.49.0

From: Michal Privoznik <mprivozn@redhat.com> At the beginning of virInhibitorAcquire() the system D-Bus connection is obtained by calling virGDBusGetSystemBus(). If there's no D-Bus available then an debug message is printed out and function returns early. Problem is, in case of no D-Bus an error message was reported by virGDBusGetSystemBus() and thus logs were polluted which may mislead users. Just check whether D-Bus is available first (by calling virGDBusHasSystemBus()). If it is then virGDBusGetSystemBus() should return a valid connection. Nevertheless, respect previous logic and don't propagate error to the caller, just return 0. Resolves: https://issues.redhat.com/browse/RHEL-79088 Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/util/virinhibitor.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/util/virinhibitor.c b/src/util/virinhibitor.c index a95021de5a..6796938936 100644 --- a/src/util/virinhibitor.c +++ b/src/util/virinhibitor.c @@ -70,11 +70,14 @@ virInhibitorAcquire(const char *what, VIR_DEBUG("what=%s who=%s why=%s mode=%s", NULLSTR(what), NULLSTR(who), NULLSTR(why), NULLSTR(mode)); - if (!(systemBus = virGDBusGetSystemBus())) { + if (!virGDBusHasSystemBus()) { VIR_DEBUG("system dbus not available, skipping system inhibitor"); return 0; } + if (!(systemBus = virGDBusGetSystemBus())) + return 0; + if (virSystemdHasLogind() < 0) { VIR_DEBUG("logind not available, skipping system inhibitor"); return 0; -- 2.49.0

From: Michal Privoznik <mprivozn@redhat.com> When the network driver initializes itself, it tries to subscribe to signals from Firewalld sent over system D-Bus. Well, the code is written in best effort mode, i.e. lack of D-Bus is not considered an error. Problem is, virGDBusGetSystemBus() which is used to obtain system D-Bus prints out an error in case of lacking system D-Bus. This pollutes the logs (which may mislead users) and goes against the best-effort nature of aforementioned code. Check for the system D-Bus presence via virGDBusHasSystemBus() first. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/network/bridge_driver.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 2cad1c8cbe..34b655e816 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -710,7 +710,8 @@ networkStateInitialize(bool privileged, network_driver->networkEventState = virObjectEventStateNew(); #ifdef WITH_FIREWALLD - if (!(sysbus = virGDBusGetSystemBus())) { + if (!virGDBusHasSystemBus() || + !(sysbus = virGDBusGetSystemBus())) { VIR_WARN("DBus not available, disabling firewalld support " "in bridge_network_driver: %s", virGetLastErrorMessage()); } else { -- 2.49.0

On Thu, Apr 10, 2025 at 11:21:58 +0200, Michal Privoznik wrote:
This is basically a follow up to [1] as new places were identified which suffer the same problem.
1: https://lists.libvirt.org/archives/list/devel@lists.libvirt.org/thread/WGFBR...
Michal Prívozník (2): virinhibitor: Suppress reporting an error when D-Bus is unavailable in virInhibitorAcquire() network: Suppress reporting an error when D-Bus is unavailable in networkStateInitialize()
src/network/bridge_driver.c | 3 ++- src/util/virinhibitor.c | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-)
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
participants (2)
-
Jiri Denemark
-
Michal Privoznik