Split it out from virSystemdPMSupportTarget.
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
src/util/virsystemd.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c
index 26b751311f..b401eda6a2 100644
--- a/src/util/virsystemd.c
+++ b/src/util/virsystemd.c
@@ -174,6 +174,21 @@ virSystemdHasMachined(void)
return ret;
}
+static int
+virSystemdHasLogind(void)
+{
+ int ret;
+
+ ret = virDBusIsServiceEnabled("org.freedesktop.login1");
+ if (ret < 0)
+ return ret;
+
+ if ((ret = virDBusIsServiceRegistered("org.freedesktop.login1")) < 0)
+ return ret;
+
+ return ret;
+}
+
char *
virSystemdGetMachineNameByPID(pid_t pid)
@@ -547,11 +562,7 @@ virSystemdPMSupportTarget(const char *methodName, bool *result)
DBusMessage *message = NULL;
char *response;
- ret = virDBusIsServiceEnabled("org.freedesktop.login1");
- if (ret < 0)
- return ret;
-
- if ((ret = virDBusIsServiceRegistered("org.freedesktop.login1")) < 0)
+ if ((ret = virSystemdHasLogind()) < 0)
return ret;
if (!(conn = virDBusGetSystemBus()))
--
2.19.2