summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2015-12-07 11:54:26 -0600
committerDavid Teigland <teigland@redhat.com>2015-12-07 13:07:39 -0600
commit20798b209703342c943567fa5c317a852d12add9 (patch)
treedd8499eba999e0c355ad6581ff825eae3f0a5586
parent5ba1d5e4cce92fce1ff4ceabd9a2388e99f8ac8f (diff)
downloadlvm2-20798b209703342c943567fa5c317a852d12add9.tar.gz
Use sd-bus from libsystemd instead of gdbus
-rw-r--r--configure.in7
-rw-r--r--lib/Makefile.in7
-rw-r--r--lib/notify/lvmnotify.c69
-rw-r--r--make.tmpl.in3
-rw-r--r--tools/Makefile.in5
5 files changed, 33 insertions, 58 deletions
diff --git a/configure.in b/configure.in
index 80bc75388..9b212b442 100644
--- a/configure.in
+++ b/configure.in
@@ -854,8 +854,6 @@ if test "$BUILDOPENAIS" = yes; then
CHECKCPG=yes
fi
-PKG_CHECK_MODULES([GIO], [gio-unix-2.0])
-
dnl -- Below are checks for libraries common to more than one build.
dnl -- Check confdb library.
@@ -1290,12 +1288,13 @@ BUILD_NOTIFYDBUS=$NOTIFYDBUS
if test "$BUILD_NOTIFYDBUS" = yes; then
AC_DEFINE([NOTIFYDBUS_SUPPORT], 1, [Define to 1 to include code that uses dbus notification.])
+ LIBS="-lsystemd $LIBS"
fi
################################################################################
dnl -- Look for dbus libraries
if test "$BUILD_NOTIFYDBUS" = yes; then
- PKG_CHECK_MODULES(NOTIFY_DBUS, gio-unix-2.0, [HAVE_NOTIFY_DBUS=yes], $bailout)
+ PKG_CHECK_MODULES(NOTIFY_DBUS, systemd >= 221, [HAVE_NOTIFY_DBUS=yes], $bailout)
fi
################################################################################
@@ -2033,8 +2032,6 @@ AC_SUBST(SACKPT_CFLAGS)
AC_SUBST(SACKPT_LIBS)
AC_SUBST(SALCK_CFLAGS)
AC_SUBST(SALCK_LIBS)
-AC_SUBST(GIO_CFLAGS)
-AC_SUBST(GIO_LIBS)
AC_SUBST(SELINUX_LIBS)
AC_SUBST(SELINUX_PC)
AC_SUBST(SNAPSHOTS)
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 014fbd8cf..d881e797b 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -206,11 +206,6 @@ ifeq ("@DMEVENTD@", "yes")
LIBS += -ldevmapper-event
endif
-ifeq ("@BUILD_NOTIFYDBUS@", "yes")
- LIBS += $(GIO_LIBS)
- CFLAGS += $(GIO_CFLAGS)
-endif
-
LIB_NAME = liblvm-internal
LIB_STATIC = $(LIB_NAME).a
@@ -233,7 +228,7 @@ CFLOW_LIST_TARGET = $(LIB_NAME).cflow
include $(top_builddir)/make.tmpl
-CFLAGS += $(BLKID_CFLAGS) $(UDEV_CFLAGS) $(VALGRIND_CFLAGS) $(GIO_CFLAGS)
+CFLAGS += $(BLKID_CFLAGS) $(UDEV_CFLAGS) $(VALGRIND_CFLAGS)
$(SUBDIRS): $(LIB_STATIC)
diff --git a/lib/notify/lvmnotify.c b/lib/notify/lvmnotify.c
index cdd3d5b5f..30399533c 100644
--- a/lib/notify/lvmnotify.c
+++ b/lib/notify/lvmnotify.c
@@ -14,59 +14,50 @@
#include "lvmnotify.h"
#ifdef NOTIFYDBUS_SUPPORT
-#include <gio/gio.h>
+#include <systemd/sd-bus.h>
void lvmnotify_send(struct cmd_context *cmd)
{
- GDBusProxy *con = NULL;
- GError *error = NULL;
+ sd_bus *bus = NULL;
+ sd_bus_message *m = NULL;
+ sd_bus_error error = SD_BUS_ERROR_NULL;
+ const char *path;
const char *cmd_name;
- GVariant *rc;
- int result = 0;
+ int ret;
if (!cmd->vg_notify && !cmd->lv_notify && !cmd->pv_notify)
return;
- con = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- NULL,
- "com.redhat.lvmdbus1.Manager",
- "/com/redhat/lvmdbus1/Manager",
- "com.redhat.lvmdbus1.Manager",
- NULL,
- &error);
- if (!con && error) {
- log_debug("Failed to connect to dbus %d %s",
- error->code, error->message);
- g_error_free(error);
+ cmd_name = get_cmd_name();
+
+ ret = sd_bus_open_system(&bus);
+ if (ret < 0) {
+ log_debug("Failed to connect to dbus: %d", ret);
return;
}
- cmd_name = get_cmd_name();
-
- rc = g_dbus_proxy_call_sync(con,
- "ExternalEvent",
- g_variant_new("(s)", cmd_name),
- G_DBUS_CALL_FLAGS_NONE,
- -1, NULL, &error);
-
- if (rc) {
- g_variant_get(rc, "(i)", &result);
- if (result)
- log_debug("Error from sending dbus notification %d", result);
- g_variant_unref(rc);
-
- } else if (error) {
- if (error->code != 2)
- log_debug("Failed to send dbus notification %d %s", error->code, error->message);
- g_error_free(error);
-
- } else {
- log_debug("Undefined dbus result");
+ ret = sd_bus_call_method(bus,
+ "com.redhat.lvmdbus1.Manager",
+ "/com/redhat/lvmdbus1/Manager",
+ "com.redhat.lvmdbus1.Manager",
+ "ExternalEvent",
+ &error,
+ NULL,
+ "s",
+ cmd_name);
+
+ if (ret < 0) {
+ log_debug("Failed to issue dbus method call: %s", error.message);
+ goto out;
}
+ ret = sd_bus_message_read(m, "o", &path);
+ if (ret < 0)
+ log_debug("Failed to parse dbus response message: %d", ret);
- g_object_unref(con);
+ sd_bus_error_free(&error);
+ sd_bus_message_unref(m);
+ sd_bus_unref(bus);
}
void set_vg_notify(struct cmd_context *cmd)
diff --git a/make.tmpl.in b/make.tmpl.in
index 7b295c2ba..f1d4fada7 100644
--- a/make.tmpl.in
+++ b/make.tmpl.in
@@ -65,9 +65,6 @@ BLKID_LIBS = @BLKID_LIBS@
VALGRIND_CFLAGS = @VALGRIND_CFLAGS@
TESTING = @TESTING@
-GIO_CFLAGS = @GIO_CFLAGS@
-GIO_LIBS = @GIO_LIBS@
-
# Setup directory variables
prefix = @prefix@
exec_prefix = @exec_prefix@
diff --git a/tools/Makefile.in b/tools/Makefile.in
index f531ed0e5..d6e54f0ac 100644
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -109,11 +109,6 @@ ifeq ("@DMEVENTD@", "yes")
LVMLIBS += -ldevmapper-event
endif
-ifeq ("@BUILD_NOTIFYDBUS@", "yes")
- EXTRA_EXEC_CFLAGS += $(GIO_CFLAGS)
- EXTRA_EXEC_LDFLAGS += $(GIO_LIBS)
-endif
-
LVMLIBS += -ldevmapper
EXPORTED_HEADER = $(srcdir)/lvm2cmd.h