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(a)redhat.com>
---
src/libvirt_private.syms | 1 +
src/rpc/virnetdaemon.c | 3 +++
src/util/virsystemd.c | 2 +-
src/util/virsystemd.h | 2 ++
4 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 5940342087..ff4ddd1c5c 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -3135,6 +3135,7 @@ virSystemdCanSuspend;
virSystemdCreateMachine;
virSystemdGetActivation;
virSystemdGetMachineNameByPID;
+virSystemdHasLogind;
virSystemdHasLogindResetCachedValue;
virSystemdHasMachinedResetCachedValue;
virSystemdMakeScopeName;
diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c
index d098cf4ae9..7b68ddbdf2 100644
--- a/src/rpc/virnetdaemon.c
+++ b/src/rpc/virnetdaemon.c
@@ -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;
diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c
index 66d0b7bd53..e75c5b835a 100644
--- a/src/util/virsystemd.c
+++ b/src/util/virsystemd.c
@@ -181,7 +181,7 @@ virSystemdHasMachined(void)
return ret;
}
-static int
+int
virSystemdHasLogind(void)
{
int ret;
diff --git a/src/util/virsystemd.h b/src/util/virsystemd.h
index 96626f8fff..5f1a4413fe 100644
--- a/src/util/virsystemd.h
+++ b/src/util/virsystemd.h
@@ -57,6 +57,8 @@ int virSystemdTerminateMachine(const char *name);
void virSystemdNotifyStartup(void);
+int virSystemdHasLogind(void);
+
int virSystemdCanSuspend(bool *result);
int virSystemdCanHibernate(bool *result);
--
2.19.2