[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] [PATCH] Integrate LVMetaD with the build system



Hi,

this is a "compromise" integration: I have kept all the daemon/common
code in a single libdaemon.a, which is completely private. This is
currently linked into the lvmetad binary, and will be linked into LVM
(the client part, since static linking only picks up only symbols that
are actually used). I have also added --disable-lvmetad to ./configure
(i.e. building and using it by default; there's no LVM-side support yet,
but when there is, even when built, it'll still need to be enabled by an
lvm.conf option).

Yours,
   Petr

? daemons/dmeventd/Makefile.in.new
? daemons/dmeventd/dmeventd.c.new
? daemons/lvmetad/lvmetad
? daemons/lvmetad/testclient
Index: configure.in
===================================================================
RCS file: /cvs/lvm2/LVM2/configure.in,v
retrieving revision 1.170
diff -u -p -r1.170 configure.in
--- configure.in	24 Aug 2011 08:27:50 -0000	1.170
+++ configure.in	31 Aug 2011 03:28:23 -0000
@@ -37,6 +37,7 @@ case "$host_os" in
 		LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
 		LIB_SUFFIX=so
 		DEVMAPPER=yes
+		LVMETAD=yes
 		ODIRECT=yes
 		DM_IOCTLS=yes
 		SELINUX=yes
@@ -790,6 +791,17 @@ if test x$DEVMAPPER = xyes; then
 fi
 
 ################################################################################
+dnl -- Build lvmetad
+AC_MSG_CHECKING(whether to build LVMetaD)
+AC_ARG_ENABLE(lvmetad,
+	      AC_HELP_STRING([--disable-lvmetad],
+			     [disable the LVM Metadata Daemon]),
+	      LVMETAD=$enableval)
+AC_MSG_RESULT($LVMETAD)
+
+BUILD_LVMETAD=$LVMETAD
+
+################################################################################
 dnl -- Enable udev synchronisation
 AC_MSG_CHECKING(whether to enable synchronisation with udev processing)
 AC_ARG_ENABLE(udev_sync,
@@ -1288,6 +1300,7 @@ AC_SUBST(APPLIB)
 AC_SUBST(AWK)
 AC_SUBST(BUILD_CMIRRORD)
 AC_SUBST(BUILD_DMEVENTD)
+AC_SUBST(BUILD_LVMETAD)
 AC_SUBST(CFLAGS)
 AC_SUBST(CFLOW_CMD)
 AC_SUBST(CLDFLAGS)
@@ -1401,6 +1414,7 @@ daemons/dmeventd/plugins/lvm2/Makefile
 daemons/dmeventd/plugins/raid/Makefile
 daemons/dmeventd/plugins/mirror/Makefile
 daemons/dmeventd/plugins/snapshot/Makefile
+daemons/lvmetad/Makefile
 doc/Makefile
 doc/example.conf
 include/.symlinks
Index: daemons/Makefile.in
===================================================================
RCS file: /cvs/lvm2/LVM2/daemons/Makefile.in,v
retrieving revision 1.16
diff -u -p -r1.16 Makefile.in
--- daemons/Makefile.in	9 Apr 2010 21:34:25 -0000	1.16
+++ daemons/Makefile.in	31 Aug 2011 03:28:23 -0000
@@ -15,7 +15,10 @@ srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 top_builddir = @top_builddir@
 
-.PHONY: dmeventd clvmd cmirrord
+LIB_STATIC=libdaemon.a
+SOURCES = common/daemon-shared.c common/daemon-server.c common/daemon-client.c
+
+.PHONY: dmeventd clvmd cmirrord lvmetad
 
 ifneq ("@CLVMD@", "none")
   SUBDIRS = clvmd
@@ -25,6 +28,10 @@ ifeq ("@BUILD_CMIRRORD@", "yes")
   SUBDIRS += cmirrord
 endif
 
+ifeq ("@BUILD_LVMETAD@", "yes")
+  SUBDIRS += lvmetad
+endif
+
 ifeq ("@BUILD_DMEVENTD@", "yes")
   SUBDIRS += dmeventd
 ifneq ("$(CFLOW_CMD)", "")
@@ -33,7 +40,7 @@ endif
 endif
 
 ifeq ($(MAKECMDGOALS),distclean)
-  SUBDIRS = clvmd cmirrord dmeventd
+  SUBDIRS = clvmd cmirrord dmeventd lvmetad
 endif
 
 include $(top_builddir)/make.tmpl
@@ -41,3 +48,5 @@ include $(top_builddir)/make.tmpl
 ifeq ("@BUILD_DMEVENTD@", "yes")
 device-mapper: dmeventd.device-mapper
 endif
+
+device-mapper: libdaemon.a
Index: daemons/common/daemon-server.c
===================================================================
RCS file: /cvs/lvm2/LVM2/daemons/common/daemon-server.c,v
retrieving revision 1.10
diff -u -p -r1.10 daemon-server.c
--- daemons/common/daemon-server.c	30 Aug 2011 15:42:57 -0000	1.10
+++ daemons/common/daemon-server.c	31 Aug 2011 03:28:23 -0000
@@ -247,13 +247,13 @@ void *client_thread(void *baton)
 			fprintf(stderr, "error parsing request:\n %s\n", req.buffer);
 		response res = b->s.handler(b->s, b->client, req);
 		if (req.cft)
-			destroy_config_tree(req.cft);
+			dm_config_destroy(req.cft);
 		dm_free(req.buffer);
 
 		if (!res.buffer) {
 			dm_config_write_node(res.cft->root, buffer_line, &res);
 			buffer_rewrite(&res.buffer, "%s\n\n", NULL);
-			destroy_config_tree(res.cft);
+			dm_config_destroy(res.cft);
 		}
 
 		write_buffer(b->client.socket_fd, res.buffer, strlen(res.buffer));
Index: daemons/lvmetad/Makefile.in
===================================================================
RCS file: daemons/lvmetad/Makefile.in
diff -N daemons/lvmetad/Makefile.in
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ daemons/lvmetad/Makefile.in	31 Aug 2011 03:28:23 -0000
@@ -0,0 +1,59 @@
+# Copyright (C) 2011 Red Hat, Inc. All rights reserved.
+#
+# This file is part of the device-mapper userspace tools.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU Lesser General Public License v.2.1.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = @top_builddir@
+
+SOURCES = lvmetad-core.c
+SOURCES2 = testclient.c
+
+TARGETS = lvmetad lvmetad-testclient
+
+.PHONY: install_lib_dynamic install_lib_static install_include \
+	install_pkgconfig install_dmeventd_dynamic install_dmeventd_static \
+	install_lib install_dmeventd
+
+INCLUDES += -I$(top_srcdir)/daemons/common/
+INSTALL_LVMETAD_TARGETS = install_lvmetad
+CLEAN_TARGETS = lvmetad lvmetad-testclient
+
+CFLOW_LIST = $(SOURCES)
+CFLOW_LIST_TARGET = $(LIB_NAME).cflow
+CFLOW_TARGET = lvmetad
+
+include $(top_builddir)/make.tmpl
+
+all: device-mapper
+device-mapper: $(TARGETS)
+
+LIBS += -ldevmapper -ldaemon -lpthread
+
+lvmetad: lvmetad-core.o
+	$(CC) $(CFLAGS) $(LDFLAGS) -L$(top_builddir)/daemons -o $@ lvmetad-core.o \
+	$(DL_LIBS) $(LVMLIBS) $(LIBS) -rdynamic
+
+# TODO: No idea. No idea how to test either.
+#ifneq ("$(CFLOW_CMD)", "")
+#CFLOW_SOURCES = $(addprefix $(srcdir)/, $(SOURCES))
+#-include $(top_builddir)/libdm/libdevmapper.cflow
+#-include $(top_builddir)/lib/liblvm-internal.cflow
+#-include $(top_builddir)/lib/liblvm2cmd.cflow
+#-include $(top_builddir)/daemons/dmeventd/$(LIB_NAME).cflow
+#-include $(top_builddir)/daemons/dmeventd/plugins/mirror/$(LIB_NAME)-lvm2mirror.cflow
+#endif
+
+install_lvmetad: $(INSTALL_DMEVENTD_TARGETS)
+
+install: install_lvmetad
+
+install_device-mapper: install_lvmetad
Index: test/Makefile.in
===================================================================
RCS file: /cvs/lvm2/LVM2/test/Makefile.in,v
retrieving revision 1.56
diff -u -p -r1.56 Makefile.in
--- test/Makefile.in	28 Apr 2011 22:17:06 -0000	1.56
+++ test/Makefile.in	31 Aug 2011 03:28:23 -0000
@@ -96,10 +96,11 @@ Makefile: $(srcdir)/Makefile.in $(top_bu
 	for i in lvm $$(cat ../tools/.commands); do \
 	  ln -fs lvm-wrapper lib/$$i; \
 	done
-	ln -s "$(abs_top_builddir)/tools/dmsetup" lib/dmsetup
-	ln -s "$(abs_top_builddir)/daemons/clvmd/clvmd" lib/clvmd
-	ln -s "$(abs_top_builddir)/daemons/dmeventd/dmeventd" lib/dmeventd
-	ln -s "$(abs_top_builddir)/scripts/vgimportclone.sh" lib/vgimportclone
+	ln -fs "$(abs_top_builddir)/tools/dmsetup" lib/dmsetup
+	ln -fs "$(abs_top_builddir)/daemons/clvmd/clvmd" lib/clvmd
+	ln -fs "$(abs_top_builddir)/daemons/dmeventd/dmeventd" lib/dmeventd
+	ln -fs "$(abs_top_builddir)/daemons/lvmetad/lvmetad" lib/lvmetad
+	ln -fs "$(abs_top_builddir)/scripts/vgimportclone.sh" lib/vgimportclone
 	touch $@
 
 clean:
Index: test/lib/aux.sh
===================================================================
RCS file: /cvs/lvm2/LVM2/test/lib/aux.sh,v
retrieving revision 1.28
diff -u -p -r1.28 aux.sh
--- test/lib/aux.sh	11 Aug 2011 17:46:14 -0000	1.28
+++ test/lib/aux.sh	31 Aug 2011 03:28:23 -0000
@@ -60,6 +60,21 @@ prepare_dmeventd() {
 	sleep 1
 }
 
+prepare_lvmetad() {
+	# skip if we don't have our own lvmetad...
+	(which lvmetad | grep $abs_builddir) || {
+            touch SKIP_THIS_TEST
+            exit 1
+        }
+
+        lvmconf "global/lvmetad = 1"
+
+	lvmetad -f "$@" &
+	echo "$!" > LOCAL_LVMETAD
+
+	sleep 1
+}
+
 teardown_devs() {
 	# Delete any remaining dm/udev semaphores
 	teardown_udev_cookies
@@ -145,6 +160,7 @@ teardown() {
     echo -n .
 
     test -f LOCAL_DMEVENTD && kill -9 "$(cat LOCAL_DMEVENTD)"
+    test -f LOCAL_LVMETAD && kill -9 "$(cat LOCAL_LVMETAD)"
 
     echo -n .
 
Index: test/lib/test.sh
===================================================================
RCS file: /cvs/lvm2/LVM2/test/lib/test.sh,v
retrieving revision 1.4
diff -u -p -r1.4 test.sh
--- test/lib/test.sh	30 Jun 2011 00:57:29 -0000	1.4
+++ test/lib/test.sh	31 Aug 2011 03:28:23 -0000
@@ -54,6 +54,7 @@ ln -s $abs_top_builddir/test/lib/* $TEST
 set -eE -o pipefail
 aux lvmconf
 aux prepare_clvmd
+aux prepare_lvmetad
 echo "@TESTDIR=$TESTDIR"
 echo "@PREFIX=$PREFIX"
 
-- 
id' Ash = Ash; id' Dust = Dust; id' _ = undefined

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]