From 2ecd68297fc5bf010785764221b05d43e20a95f5 Mon Sep 17 00:00:00 2001 From: Lon Hohberger Date: Tue, 15 Sep 2009 10:29:08 -0400 Subject: [PATCH] Add checkpoint.c stub functions Signed-off-by: Lon Hohberger --- server/Makefile | 2 +- server/checkpoint.c | 188 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 189 insertions(+), 1 deletion(-) create mode 100644 server/checkpoint.c diff --git a/server/Makefile b/server/Makefile index 28e1fc7..e58a4fe 100644 --- a/server/Makefile +++ b/server/Makefile @@ -21,7 +21,7 @@ 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_so_SOURCES = virt.c vm_states.c history.c checkpoint.c INCLUDES=-I../include\ -I/usr/include/openais -I/usr/include/libvirt \ diff --git a/server/checkpoint.c b/server/checkpoint.c new file mode 100644 index 0000000..a8d471f --- /dev/null +++ b/server/checkpoint.c @@ -0,0 +1,188 @@ +/* + Copyright Red Hat, Inc. 2009 + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 675 Mass Ave, Cambridge, + MA 02139, USA. +*/ +/* + * Author: Lon Hohberger + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef OPENAIS +#include +#else +#include +#endif + + +#define NAME "checkpoint" +#define VERSION "0.8" + +#define MAGIC 0x1e017afe + +struct check_info { + int magic; + int pad; + cpg_handle_t h; + virConnectPtr vp; +}; + +#define VALIDATE(arg) \ +do {\ + if (!arg || ((struct check_info *)arg)->magic != MAGIC) { \ + errno = EINVAL;\ + return -1; \ + } \ +} while(0) + + +static int +ckpt_null(const char *vm_name, void *priv) +{ + VALIDATE(priv); + printf("[CKPT] Null operation on %s\n", vm_name); + + return 1; +} + + +static int +ckpt_off(const char *vm_name, uint32_t seqno, void *priv) +{ + VALIDATE(priv); + printf("[CKPT] OFF operation on %s seq %d\n", vm_name, seqno); + + return 1; +} + + +static int +ckpt_on(const char *vm_name, uint32_t seqno, void *priv) +{ + VALIDATE(priv); + printf("[CKPT] ON operation on %s seq %d\n", vm_name, seqno); + + return 1; +} + + +static int +ckpt_devstatus(void *priv) +{ + printf("[CKPT] Device status\n"); + VALIDATE(priv); + + return 0; +} + + +static int +ckpt_status(const char *vm_name, void *priv) +{ + VALIDATE(priv); + printf("[CKPT] STATUS operation on %s\n", vm_name); + + return 1; +} + + +static int +ckpt_reboot(const char *vm_name, uint32_t seqno, void *priv) +{ + VALIDATE(priv); + printf("[CKPT] REBOOT operation on %s seq %d\n", vm_name, seqno); + + return 1; +} + + +static int +ckpt_init(backend_context_t *c, config_object_t *config) +{ + //char value[256]; + struct check_info *info = NULL; + + info = malloc(sizeof(*info)); + if (!info) + return -1; + + memset(info, 0, sizeof(*info)); + + info->magic = MAGIC; + + *c = (void *)info; + return 0; +} + + +static int +ckpt_shutdown(backend_context_t c) +{ + struct check_info *info = (struct check_info *)c; + + VALIDATE(info); + info->magic = 0; + free(info); + + return 0; +} + + +static fence_callbacks_t ckpt_callbacks = { + .null = ckpt_null, + .off = ckpt_off, + .on = ckpt_on, + .reboot = ckpt_reboot, + .status = ckpt_status, + .devstatus = ckpt_devstatus +}; + +static backend_plugin_t ckpt_plugin = { + .name = NAME, + .version = VERSION, + .callbacks = &ckpt_callbacks, + .init = ckpt_init, + .cleanup = ckpt_shutdown, +}; + + +#ifdef _MODULE +double +BACKEND_VER_SYM(void) +{ + return PLUGIN_VERSION_BACKEND; +} + +const backend_plugin_t * +BACKEND_INFO_SYM(void) +{ + return &ckpt_plugin; +} +#else +static void __attribute__((constructor)) +ckpt_register_plugin(void) +{ + plugin_register(&ckpt_plugin); +} +#endif