Page MenuHomeClusterLabs Projects

No OneTemporary

diff --git a/server/Makefile.in b/server/Makefile.in
index edf453f3..9697d382 100644
--- a/server/Makefile.in
+++ b/server/Makefile.in
@@ -1,130 +1,130 @@
###############################################################################
###############################################################################
##
## Copyright (C) 2006 Red Hat, Inc.
##
## 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 General Public License v.2.
##
###############################################################################
###############################################################################
include ../Makefile.top
#
# Modular information
#
with_modules=@modules@
TARGETS=fence_virtd
MAIN_LIBS=-L../config -lsimpleconfig -ldl
AIS_LIBS=-L@libdir@/openais -lSaCkpt
COROSYNC_LIBS=-L@libdir@/corosync -lcpg
VIRT_LIBS=-lvirt
NSS_LIBS=-lnss3
INCLUDES=-I../include `nss-config --cflags` `nspr-config --cflags`
LIBS+=-L../common -lfence_virt -Wl,-wrap,syslog,-wrap,closelog -lpthread
MODULE_PATH=${libdir}/${PACKAGE_NAME}
#
# Module sources
#
fence_virtd_SOURCES = main.c plugin.c
libvirt_so_SOURCES = libvirt.c
null_so_SOURCES = null.c
multicast_so_SOURCES = mcast.c history.c
-checkpoint_so_SOURCES = virt.c vm_states.c history.c checkpoint.c
+checkpoint_so_SOURCES = virt.c vm_states.c history.c checkpoint.c cpg.c
################################
ifeq ($(with_modules),yes)
mod_null=@mod_null@
mod_libvirt=@mod_libvirt@
mod_checkpoint=@mod_checkpoint@
mod_multicast=@mod_multicast@
mod_serial=@mod_serial@ # XXX Not done yet
#################
# Modular build #
#################
CFLAGS+=-D_MODULE -DMODULE_PATH=\"${MODULE_PATH}\"
MODULES=
ifneq ($(mod_libvirt),no)
MODULES+=libvirt.so
endif
ifneq ($(mod_checkpoint),no)
MODULES+=checkpoint.so
endif
ifneq ($(mod_multicast),no)
MODULES+=multicast.so
endif
ifneq ($(mod_null),no)
MODULES+=null.so
endif
else
####################
# Monolithic build #
####################
ifneq ($(mod_libvirt),no)
fence_virtd_SOURCES+=${libvirt_so_SOURCES}
LIBS+=$(VIRT_LIBS)
endif
ifneq ($(mod_checkpoint),no)
fence_virtd_SOURCES+=${checkpoint_so_SOURCES}
LIBS+=$(AIS_LIBS) $(COROSYNC_LIBS)
endif
ifneq ($(mod_multicast),no)
fence_virtd_SOURCES+=${multicast_so_SOURCES}
LIBS+=$(AIS_LIBS) $(NSS_LIBS)
endif
ifneq ($(mod_null),no)
fence_virtd_SOURCES+=${null_so_SOURCES}
endif
endif
CFLAGS+=-DSYSCONFDIR=\"@sysconfdir@\"
all: ${TARGETS} ${MODULES}
fence_virtd: ${fence_virtd_SOURCES:.c=.o}
$(CC) -o $@ $^ $(LIBS) $(MAIN_LIBS)
multicast.so: ${multicast_so_SOURCES:.c=.o}
$(CC) -o $@ $^ $(LIBS) -shared $(NSS_LIBS)
libvirt.so: ${libvirt_so_SOURCES:.c=.o}
$(CC) -o $@ $^ $(LIBS) -shared $(VIRT_LIBS)
null.so: ${null_so_SOURCES:.c=.o}
$(CC) -o $@ $^ $(LIBS) -shared
checkpoint.so: ${checkpoint_so_SOURCES:.c=.o}
$(CC) -o $@ $^ $(LIBS) -shared $(AIS_LIBS) $(VIRT_LIBS) $(COROSYNC_LIBS)
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $^ $(INCLUDES)
install: all
if [ ! -d ${sbindir} ]; then \
install -d ${sbindir} ; \
fi
install -m755 ${TARGETS} ${sbindir}
ifeq ($(with_modules),yes)
if [ ! -d ${MODULE_PATH} ]; then \
install -d ${MODULE_PATH} ; \
fi
install -m755 ${MODULES} ${MODULE_PATH}
endif
clean:
rm -f ${TARGETS} ${MODULES} *.o *.d *~
diff --git a/server/cpg.c b/server/cpg.c
new file mode 100644
index 00000000..4ea64f98
--- /dev/null
+++ b/server/cpg.c
@@ -0,0 +1,178 @@
+#include <config.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <stdint.h>
+#include <malloc.h>
+#include <signal.h>
+#include <unistd.h>
+#include <sys/select.h>
+#include <string.h>
+#include <errno.h>
+#include <time.h>
+#include <sys/uio.h>
+#include <list.h>
+#ifdef HAVE_OPENAIS_CPG_H
+#include <openais/cpg.h>
+#else
+#ifdef HAVE_COROSYNC_CPG_H
+#include <corosync/cpg.h>
+#endif
+#endif
+
+
+void
+#ifdef HAVE_OPENAIS_CPG_H
+cpg_deliver_func(cpg_handle_t h,
+ struct cpg_name *group_name,
+ uint32_t nodeid,
+ uint32_t pid,
+ void *msg,
+ int msglen)
+#else
+cpg_deliver_func(cpg_handle_t h,
+ const struct cpg_name *group_name,
+ uint32_t nodeid,
+ uint32_t pid,
+ void *msg,
+ size_t msglen)
+#endif
+{
+ printf("%s (len = %d) from node %d pid %d\n)\n",
+ (char *)msg, (int)msglen, nodeid, pid);
+}
+
+void
+#ifdef HAVE_OPENAIS_CPG_H
+cpg_config_change(cpg_handle_t h,
+ struct cpg_name *group_name,
+ struct cpg_address *members, int memberlen,
+ struct cpg_address *left, int leftlen,
+ struct cpg_address *join, int joinlen)
+#else
+cpg_config_change(cpg_handle_t h,
+ const struct cpg_name *group_name,
+ const struct cpg_address *members, size_t memberlen,
+ const struct cpg_address *left, size_t leftlen,
+ const struct cpg_address *join, size_t joinlen)
+#endif
+{
+ /* Don't care */
+ return;
+}
+
+
+static cpg_callbacks_t my_callbacks = {
+ .cpg_deliver_fn = cpg_deliver_func,
+ .cpg_confchg_fn = cpg_config_change
+};
+
+
+int
+cpg_send(cpg_handle_t h, void *data, size_t len)
+{
+ struct iovec iov;
+
+ iov.iov_base = data;
+ iov.iov_len = len;
+ return cpg_mcast_joined(h, CPG_TYPE_AGREED, &iov, 1);
+}
+
+
+int
+cpg_start(const char *name, cpg_handle_t *handle, struct cpg_name *grpname)
+{
+ cpg_handle_t h;
+ struct cpg_name gname;
+
+ errno = EINVAL;
+
+ if (!name || !handle || !grpname)
+ return -1;
+
+ gname.length = snprintf(gname.value,
+ sizeof(gname.value), name);
+ if (gname.length >= sizeof(gname.value)) {
+ errno = ENAMETOOLONG;
+ return -1;
+ }
+
+ if (gname.length <= 0)
+ return -1;
+
+ memset(&h, 0, sizeof(h));
+ if (cpg_initialize(&h, &my_callbacks) != CPG_OK) {
+ perror("cpg_initialize");
+ return -1;
+ }
+
+ if (cpg_join(h, &gname) != CPG_OK) {
+ perror("cpg_join");
+ return -1;
+ }
+
+ memcpy(handle, &h, sizeof(h));
+ memcpy(grpname, &gname, sizeof(gname));
+
+ return 0;
+}
+
+
+int
+cpg_end(cpg_handle_t h, struct cpg_name *gname)
+{
+ cpg_leave(h, gname);
+ cpg_finalize(h);
+ return 0;
+}
+
+
+#ifdef STANDALONE
+int please_quit = 0;
+
+void
+go_away(int sig)
+{
+ please_quit = 1;
+}
+
+
+int
+main(int argc, char **argv)
+{
+ cpg_handle_t h;
+ struct cpg_name gname;
+ fd_set rfds;
+ int fd;
+
+ signal(SIGINT, go_away);
+
+ if (cpg_start("lhh1", &h, &gname) < 0) {
+ perror("cpg_start");
+ return 1;
+ }
+
+ if (cpg_fd_get(h, &fd) != CPG_OK) {
+ perror("cpg_fd_get");
+ return -1;
+ }
+
+ cpg_send(h, "hi", 2);
+
+ while (please_quit != 1) {
+ FD_ZERO(&rfds);
+ FD_SET(fd, &rfds);
+
+ if (select(fd+1, &rfds, NULL, NULL, NULL) < 0)
+ continue;
+
+ cpg_dispatch(h, CPG_DISPATCH_ALL);
+ }
+
+ printf("going bye\n");
+
+ cpg_leave(h, &gname);
+ cpg_finalize(h);
+
+ return 0;
+}
+#endif

File Metadata

Mime Type
text/x-diff
Expires
Thu, Oct 16, 12:01 AM (3 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2530614
Default Alt Text
(6 KB)

Event Timeline