]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: relax requirement for logind to be running
authorDaniel P. Berrangé <berrange@redhat.com>
Wed, 21 Jun 2023 13:03:25 +0000 (14:03 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Thu, 20 Jul 2023 10:00:18 +0000 (11:00 +0100)
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 <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
src/util/virsystemd.c

index 3112a1ba80cdfb2410b8b229090164083f6f5325..cd4de0eef805e73178a62964c55a97e72e0b1c3e 100644 (file)
@@ -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;
 }