On 09/20/2011 03:40 AM, Kazunori INOUE wrote: > Hi, > > I created the backend "pm-fence" which has met the following > configurations / requirements. > - Both hosts and VMs, cluster (Pacemaker) have been configured. > * This backend has STONITH (fencing) function of the VM cluster. > - The VMs are managed as resources (RA is VirtualDomain) by the host cluster. > * In this configuration, in order to stop a VM, > it is necessary to stop the resource through the host cluster. > When the VM was stopped without through the host cluster > (e.g., run the 'virsh destory'), the host cluster considers that > VM resource failed. >
This patch is good, but the server/Makefile.in needs to use pkg-config --cflags / --libs glib-2.0 rather than static definitions. I have included an updated patch. Otherwise, I do like this patch quite a lot. The only question I had is why there needs to be an external STONITH plugin; I was of the impression that fence_virt and fence_xvm work out of the box with Pacemaker 1.1.x. That doesn't affect this particular patch, as far as I can tell (it looks like just a glue wrapper between pacemaker and fence_virt itself). -- Lon
From ee5d4c359fde6cdd7eafa1d64bc2ccf19804a7cc Mon Sep 17 00:00:00 2001 From: Kazunori INOUE <inouek...@intellilink.co.jp> Date: Tue, 25 Oct 2011 20:48:59 -0400 Subject: [PATCH] backend plugin for Pacemaker (1) pacemaker detects failure of resource. (2) STONITH (STONITH plugin is vm-stonith) is executed, target is srv-B. (3) vm-stonith requests 'fencing' to a host with fence_virt. (4) use the serial listener. (5~7) fence_virtd (pm-fence backend) requests 'forced stop' of VM resource (that is, srv-B) to pacemaker. (8) destroy the srv-B. Signed-off-by: Lon Hohberger <l...@users.sourceforge.net> --- configure.in | 11 ++++++++++- server/Makefile.in | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletions(-) diff --git a/configure.in b/configure.in index f79801f..a596fc2 100644 --- a/configure.in +++ b/configure.in @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.59) -AC_INIT(fence-virt, 0.1, l...@users.sourceforge.net) +AC_INIT(fence-virt, 0.3, l...@users.sourceforge.net) AC_CONFIG_SRCDIR([server/main.c]) AC_CONFIG_HEADER([include/config.h]) @@ -26,6 +26,8 @@ AC_CHECK_LIB([qpidclient], [pthread_create]) AC_CHECK_LIB([virt], [virConnectOpen]) AC_CHECK_LIB([xml2], [main]) +AC_SEARCH_LIBS([read_attr_delegate], [cib], [ ], [ pm_ver=1.0 ]) +AC_SUBST(pm_ver) # Checks for header files. AC_HEADER_DIRENT @@ -92,6 +94,13 @@ AC_ARG_ENABLE(libvirt-qpid-plugin, [ mod_libvirt_qpid=$enableval ], [ mod_libvirt_qpid=yes ]) AC_SUBST(mod_libvirt_qpid) +# pm-fence plugin: Disabled by default +AC_ARG_ENABLE(pm-fence-plugin, +[AS_HELP_STRING([--enable-pm-fence-plugin], + [Enable pm-fence backend plugin])], +[ mod_pm_fence=$enableval ], [ mod_pm_fence=no ]) +AC_SUBST(mod_pm_fence) + # multicast plugin: Enabled by default AC_ARG_ENABLE(multicast-plugin, [AS_HELP_STRING([--disable-multicast-plugin], diff --git a/server/Makefile.in b/server/Makefile.in index bf5ebba..4a9f89f 100644 --- a/server/Makefile.in +++ b/server/Makefile.in @@ -22,6 +22,8 @@ TARGETS=fence_virtd MAIN_LIBS=-L../config -lsimpleconfig -ldl AIS_LIBS=-L/usr/lib64/openais -lSaCkpt COROSYNC_LIBS=-L/usr/lib64/corosync -lcpg +PACEMAKER_LIBS=-lcib -lpe_status `pkg-config --libs glib-2.0` +PACEMAKER_INCLUDES=`pkg-config --cflags glib-2.0` -I/usr/include/pacemaker -I/usr/include/heartbeat CMAN_LIBS=-lcman VIRT_LIBS=-lvirt VIRT_QPID=-lqmf2 -lqpidclient -lqpidtypes -lqpidcommon -lqpidmessaging @@ -42,6 +44,7 @@ libvirt_so_SOURCES = libvirt.c virt.c uuid-test.c null_so_SOURCES = null.c libvirt_qpid_so_SOURCES = uuid-test.c libvirt_qpid_cxx_so_SOURCES = libvirt-qpid.cpp +pm_fence_so_SOURCES = pm-fence.c multicast_so_SOURCES = mcast.c history.c checkpoint_so_SOURCES = virt.c vm_states.c history.c checkpoint.c cpg.c serial_so_SOURCES = virt-serial.c virt-sockets.c serial.c history.c @@ -54,6 +57,7 @@ mod_null=@mod_null@ mod_libvirt=@mod_libvirt@ mod_checkpoint=@mod_checkpoint@ mod_libvirt_qpid=@mod_libvirt_qpid@ +mod_pm_fence=@mod_pm_fence@ mod_multicast=@mod_multicast@ mod_serial=@mod_serial@ @@ -71,6 +75,10 @@ endif ifneq ($(mod_libvirt_qpid),no) MODULES+=libvirt-qpid.so endif +ifneq ($(mod_pm_fence),no) +MODULES+=pm-fence.so +INCLUDES+=$(PACEMAKER_INCLUDES) +endif ifneq ($(mod_multicast),no) MODULES+=multicast.so endif @@ -100,6 +108,11 @@ fence_virtd_SOURCES+=${libvirt_qpid_so_SOURCES} fence_virtd_cxx_SOURCES+=${libvirt_qpid_cxx_so_SOURCES} LIBS+=$(VIRT_QPID) endif +ifneq ($(mod_pm_fence),no) +fence_virtd_SOURCES+=${pm_fence_so_SOURCES} +INCLUDES+=$(PACEMAKER_INCLUDES) +LIBS+=$(PACEMAKER_LIBS) +endif ifneq ($(mod_multicast),no) fence_virtd_SOURCES+=${multicast_so_SOURCES} LIBS+=$(AIS_LIBS) $(NSS_LIBS) @@ -116,6 +129,11 @@ endif CFLAGS+=-DSYSCONFDIR=\"@sysconfdir@\" +pm_ver=@pm_ver@ +ifeq ($(pm_ver),1.0) +CFLAGS+=-DPM_1_0 +endif + all: ${TARGETS} ${MODULES} fence_virtd: ${fence_virtd_SOURCES:.c=.o} ${fence_virtd_cxx_SOURCES:.cpp=.opp} @@ -130,6 +148,9 @@ libvirt.so: ${libvirt_so_SOURCES:.c=.o} libvirt-qpid.so: ${libvirt_qpid_so_SOURCES:.c=.o} ${libvirt_qpid_cxx_so_SOURCES:.cpp=.opp} $(CXX) -o $@ $^ $(LIBS) -shared $(VIRT_QPID) +pm-fence.so: ${pm_fence_so_SOURCES:.c=.o} + $(CC) -o $@ $^ $(LIBS) -shared $(PACEMAKER_LIBS) + null.so: ${null_so_SOURCES:.c=.o} $(CC) -o $@ $^ $(LIBS) -shared -- 1.7.3.4