libblockdev/better_lvm_dbus_check.patch

47 lines
1.5 KiB
Diff
Raw Normal View History

From 68afb7d855e269e22fb5fdee60afb73c842534e3 Mon Sep 17 00:00:00 2001
From: Vratislav Podzimek <vpodzime@redhat.com>
Date: Tue, 15 Mar 2016 10:21:01 +0100
Subject: [PATCH 1/2] Better check for the LVM DBus API
The fact that the service is running doens't automatically mean that we can
access and use it. In order to check for that we may simply try to introspect
the root node which is guaranteed to always be there. If things work nicely, we
may also trigger autostart the service this way.
Signed-off-by: Vratislav Podzimek <vpodzime@redhat.com>
---
src/plugins/lvm-dbus.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/plugins/lvm-dbus.c b/src/plugins/lvm-dbus.c
index a508b3f..e21568f 100644
--- a/src/plugins/lvm-dbus.c
+++ b/src/plugins/lvm-dbus.c
@@ -230,10 +230,21 @@ gboolean check() {
found = (g_strcmp0 (g_variant_get_string (service, NULL), LVM_BUS_NAME) == 0);
g_variant_unref (service);
}
-
g_variant_unref (real_ret);
- return found;
+ if (!found)
+ return FALSE;
+
+ /* try to introspect the root node - i.e. check we can access it and possibly
+ autostart the service */
+ ret = g_dbus_connection_call_sync (bus, LVM_BUS_NAME, LVM_OBJ_PREFIX, DBUS_INTRO_IFACE,
+ "Introspect", NULL, NULL, G_DBUS_CALL_FLAGS_NONE,
+ -1, NULL, &error);
+ if (ret)
+ g_variant_unref (ret);
+
+ /* there has to be no error reported */
+ return (error == NULL);
}
/**
--
2.5.0