rpc: make virNetDaemonCallInhibit a no-op with no logind

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>
This commit is contained in:
Ján Tomko 2019-08-13 16:43:27 +02:00
parent dd16434a2a
commit 257f96eb1e
4 changed files with 7 additions and 1 deletions

View File

@ -3135,6 +3135,7 @@ virSystemdCanSuspend;
virSystemdCreateMachine; virSystemdCreateMachine;
virSystemdGetActivation; virSystemdGetActivation;
virSystemdGetMachineNameByPID; virSystemdGetMachineNameByPID;
virSystemdHasLogind;
virSystemdHasLogindResetCachedValue; virSystemdHasLogindResetCachedValue;
virSystemdHasMachinedResetCachedValue; virSystemdHasMachinedResetCachedValue;
virSystemdMakeScopeName; virSystemdMakeScopeName;

View File

@ -508,6 +508,9 @@ virNetDaemonCallInhibit(virNetDaemonPtr dmn,
VIR_DEBUG("dmn=%p what=%s who=%s why=%s mode=%s", VIR_DEBUG("dmn=%p what=%s who=%s why=%s mode=%s",
dmn, NULLSTR(what), NULLSTR(who), NULLSTR(why), NULLSTR(mode)); dmn, NULLSTR(what), NULLSTR(who), NULLSTR(why), NULLSTR(mode));
if (virSystemdHasLogind() < 0)
return;
if (!(systemBus = virDBusGetSystemBus())) if (!(systemBus = virDBusGetSystemBus()))
return; return;

View File

@ -181,7 +181,7 @@ virSystemdHasMachined(void)
return ret; return ret;
} }
static int int
virSystemdHasLogind(void) virSystemdHasLogind(void)
{ {
int ret; int ret;

View File

@ -57,6 +57,8 @@ int virSystemdTerminateMachine(const char *name);
void virSystemdNotifyStartup(void); void virSystemdNotifyStartup(void);
int virSystemdHasLogind(void);
int virSystemdCanSuspend(bool *result); int virSystemdCanSuspend(bool *result);
int virSystemdCanHibernate(bool *result); int virSystemdCanHibernate(bool *result);