From 29f2222dd5c94b0ac372455bc4ba1843c17ca747 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Wed, 21 Jun 2023 14:03:25 +0100 Subject: [PATCH] util: relax requirement for logind to be running MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Historically we wanted to check if logind was actually running, not merely activatable, because on systems where systemd is installed, but the OS is booted into non-systemd init, we want to fallback to pm-utils. Requiring logind to be running, however, forces us to serialize libvirtd startup on startup of logind which is undesirable. We can relax this dependancy if we check whether systemd itself is running, which implies that logind will activated when we need it. https://gitlab.com/libvirt/libvirt/-/issues/489 Reviewed-by: Peter Krempa Signed-off-by: Daniel P. Berrangé --- src/util/virsystemd.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c index 3112a1ba80..cd4de0eef8 100644 --- a/src/util/virsystemd.c +++ b/src/util/virsystemd.c @@ -184,9 +184,21 @@ virSystemdHasLogind(void) return ret; } + /* + * Want to use logind if: + * - logind is already running + * Or + * - logind is not running, but this is a systemd host + * (rely on dbus activation) + */ if ((ret = virGDBusIsServiceRegistered("org.freedesktop.login1")) == -1) return ret; + if (ret == -2) { + if ((ret = virGDBusIsServiceRegistered("org.freedesktop.systemd1")) == -1) + return ret; + } + g_atomic_int_set(&virSystemdHasLogindCachedValue, ret); return ret; }