]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
rpc: make virNetDaemonCallInhibit a no-op with no logind
authorJán Tomko <jtomko@redhat.com>
Tue, 13 Aug 2019 14:43:27 +0000 (16:43 +0200)
committerJán Tomko <jtomko@redhat.com>
Wed, 14 Aug 2019 14:22:13 +0000 (16:22 +0200)
As a side effect, this also silences the possible:
  internal error: Unable to get DBus system bus connection:
  Failed to connect to socket /run/dbus/system_bus_socket:
  No such file or directory
error, since we check upfront whether dbus is available.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/libvirt_private.syms
src/rpc/virnetdaemon.c
src/util/virsystemd.c
src/util/virsystemd.h

index 594034208727cde569b21297c887c38f0ffa0a9a..ff4ddd1c5c55872fc317b38076331978d3d7773a 100644 (file)
@@ -3135,6 +3135,7 @@ virSystemdCanSuspend;
 virSystemdCreateMachine;
 virSystemdGetActivation;
 virSystemdGetMachineNameByPID;
+virSystemdHasLogind;
 virSystemdHasLogindResetCachedValue;
 virSystemdHasMachinedResetCachedValue;
 virSystemdMakeScopeName;
index d098cf4ae92113c8c603f9d9bf916015e6c97188..7b68ddbdf279d904f775b97b89ce8435a1e00c46 100644 (file)
@@ -508,6 +508,9 @@ virNetDaemonCallInhibit(virNetDaemonPtr dmn,
     VIR_DEBUG("dmn=%p what=%s who=%s why=%s mode=%s",
               dmn, NULLSTR(what), NULLSTR(who), NULLSTR(why), NULLSTR(mode));
 
+    if (virSystemdHasLogind() < 0)
+        return;
+
     if (!(systemBus = virDBusGetSystemBus()))
         return;
 
index 66d0b7bd53a89cfe3f26f55fbde1b8311e0d1157..e75c5b835a569dbbb8dc28e1bcecdfed72e82735 100644 (file)
@@ -181,7 +181,7 @@ virSystemdHasMachined(void)
     return ret;
 }
 
-static int
+int
 virSystemdHasLogind(void)
 {
     int ret;
index 96626f8fff0d2fba1c32e69d8eb8573fd73e5606..5f1a4413fe57cbc5982787055cb2bc5442438ba1 100644 (file)
@@ -57,6 +57,8 @@ int virSystemdTerminateMachine(const char *name);
 
 void virSystemdNotifyStartup(void);
 
+int virSystemdHasLogind(void);
+
 int virSystemdCanSuspend(bool *result);
 
 int virSystemdCanHibernate(bool *result);