From ecfb82c0b54082a3d5cf89c0f8d329a20dc8dcc8 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 14 Apr 2026 19:13:26 +0200 Subject: [PATCH] xf86: add an option to avoid connecting to D-Bus Distributions typically build Xorg with dbus support. When running such a build on a system without a dbus server, Xorg will keep trying to initiate a dbus connection ever 10 seconds, spamming the logs with connection failures. Add a -noDbus option, that prevents these connection attempts from happening. Fixes #554 and Debian bug https://bugs.debian.org/868453 Signed-off-by: Anton Khirnov --- hw/xfree86/common/xf86Config.c | 9 +++++++++ hw/xfree86/common/xf86Globals.c | 2 ++ hw/xfree86/common/xf86Init.c | 16 ++++++++++++---- hw/xfree86/common/xf86Priv.h | 1 + hw/xfree86/common/xf86Privstr.h | 2 ++ hw/xfree86/man/Xorg.man | 3 +++ hw/xfree86/man/xorg.conf.man | 3 +++ 7 files changed, 32 insertions(+), 4 deletions(-) diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c index fce7c401d..dea726fab 100644 --- a/hw/xfree86/common/xf86Config.c +++ b/hw/xfree86/common/xf86Config.c @@ -650,6 +650,7 @@ typedef enum { FLAG_IGLX, FLAG_DEBUG, FLAG_ALLOW_BYTE_SWAPPED_CLIENTS, + FLAG_NODBUS, } FlagValues; /** @@ -711,6 +712,8 @@ static OptionInfoRec FlagOptions[] = { {0}, FALSE}, {FLAG_ALLOW_BYTE_SWAPPED_CLIENTS, "AllowByteSwappedClients", OPTV_BOOLEAN, {0}, FALSE}, + {FLAG_NODBUS, "NoDbus", OPTV_BOOLEAN, + {0}, FALSE}, {-1, NULL, OPTV_NONE, {0}, FALSE}, }; @@ -820,6 +823,9 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts) if (xf86GetOptValBool(FlagOptions, FLAG_ALLOWMOUSEOPENFAIL, &value)) xf86Info.allowMouseOpenFail = value; + if (xf86GetOptValBool(FlagOptions, FLAG_NODBUS, &value)) + xf86Info.noDbus = value; + xf86Info.pmFlag = TRUE; if (xf86GetOptValBool(FlagOptions, FLAG_NOPM, &value)) xf86Info.pmFlag = !value; @@ -2473,6 +2479,9 @@ xf86HandleConfigFile(Bool autoconfig) if (xf86AllowMouseOpenFail) xf86Info.allowMouseOpenFail = TRUE; + if (xf86DbusDisabled) + xf86Info.noDbus = TRUE; + return CONFIG_OK; } diff --git a/hw/xfree86/common/xf86Globals.c b/hw/xfree86/common/xf86Globals.c index b48b7aada..604e7e7a9 100644 --- a/hw/xfree86/common/xf86Globals.c +++ b/hw/xfree86/common/xf86Globals.c @@ -133,6 +133,7 @@ xf86InfoRec xf86Info = { .autoAddGPU = FALSE, #endif .autoBindGPU = TRUE, + .noDbus = FALSE, }; const char *xf86ConfigFile = NULL; @@ -199,3 +200,4 @@ Bool xf86VidModeDisabled = FALSE; Bool xf86VidModeAllowNonLocal = FALSE; #endif Bool xorgHWAccess = FALSE; +Bool xf86DbusDisabled = FALSE; diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index ff3fa8973..fc16fc725 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -335,8 +335,10 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv) if (xf86DoShowOptions) DoShowOptions(); - dbus_core_init(); - systemd_logind_init(); + if (!xf86Info.noDbus) { + dbus_core_init(); + systemd_logind_init(); + } /* Do a general bus probe. This will be a PCI probe for x86 platforms */ xf86BusProbe(); @@ -844,8 +846,10 @@ ddxGiveUp(enum ExitCode error) if (xorgHWOpenConsole) xf86CloseConsole(); - systemd_logind_fini(); - dbus_core_fini(); + if (!xf86Info.noDbus) { + systemd_logind_fini(); + dbus_core_fini(); + } xf86CloseLog(error); } @@ -969,6 +973,10 @@ ddxProcessArgument(int argc, char **argv, int i) xf86AllowMouseOpenFail = TRUE; return 1; } + if (!strcmp(argv[i], "-noDbus")) { + xf86DbusDisabled = TRUE; + return 1; + } if (!strcmp(argv[i], "-ignoreABI")) { LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL); return 1; diff --git a/hw/xfree86/common/xf86Priv.h b/hw/xfree86/common/xf86Priv.h index f6c70fa17..179cd57af 100644 --- a/hw/xfree86/common/xf86Priv.h +++ b/hw/xfree86/common/xf86Priv.h @@ -47,6 +47,7 @@ extern _X_EXPORT const char *xf86ConfigFile; extern _X_EXPORT const char *xf86ConfigDir; extern _X_EXPORT Bool xf86AllowMouseOpenFail; extern _X_EXPORT Bool xf86AutoBindGPUDisabled; +extern _X_EXPORT Bool xf86DbusDisabled; #ifdef XF86VIDMODE extern _X_EXPORT Bool xf86VidModeDisabled; diff --git a/hw/xfree86/common/xf86Privstr.h b/hw/xfree86/common/xf86Privstr.h index 31861148f..e82787ffa 100644 --- a/hw/xfree86/common/xf86Privstr.h +++ b/hw/xfree86/common/xf86Privstr.h @@ -97,6 +97,8 @@ typedef struct { Bool autoAddGPU; const char *debug; Bool autoBindGPU; + + Bool noDbus; } xf86InfoRec, *xf86InfoPtr; /* ISC's cc can't handle ~ of UL constants, so explicitly type cast them. */ diff --git a/hw/xfree86/man/Xorg.man b/hw/xfree86/man/Xorg.man index 8aa9a4e7b..041c1d105 100644 --- a/hw/xfree86/man/Xorg.man +++ b/hw/xfree86/man/Xorg.man @@ -308,6 +308,9 @@ sources. This is equivalent to setting the file option. To .B false. .TP 8 +.B \-noDbus +Do not connect to D-Bus. +.TP 8 .B \-nosilk Disable Silken Mouse support. .TP 8 diff --git a/hw/xfree86/man/xorg.conf.man b/hw/xfree86/man/xorg.conf.man index a8107d9ad..088902b61 100644 --- a/hw/xfree86/man/xorg.conf.man +++ b/hw/xfree86/man/xorg.conf.man @@ -687,6 +687,9 @@ Unset by default. .TP 7 .BI "Option \*qAllowByteSwappedClients\*q \*q" boolean \*q Allow clients with a different byte-order than the server. Disabled by default. +.TP 7 +.BI "Option \*qNoDbus\*q \*q" boolean \*q +Do not connect to D-Bus. .SH "MODULE SECTION" The .B Module