forked from altcloud/fence-virt
Fix context type names
Signed-off-by: Lon Hohberger <lhh@redhat.com>
This commit is contained in:
parent
58467292b1
commit
28627c9796
@ -16,7 +16,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef void * srv_context_t;
|
typedef void * listener_context_t;
|
||||||
|
typedef void * backend_context_t;
|
||||||
|
|
||||||
/* These callbacks hand requests off to the
|
/* These callbacks hand requests off to the
|
||||||
appropriate backend. */
|
appropriate backend. */
|
||||||
@ -49,8 +50,9 @@ typedef int (*fence_status_callback)(const char *vm_name,
|
|||||||
is responding to requests. */
|
is responding to requests. */
|
||||||
typedef int (*fence_devstatus_callback)(void *priv);
|
typedef int (*fence_devstatus_callback)(void *priv);
|
||||||
|
|
||||||
typedef int (*fence_init_callback)(srv_context_t *c, config_object_t *config);
|
typedef int (*fence_init_callback)(backend_context_t *c,
|
||||||
typedef int (*fence_cleanup_callback)(srv_context_t c);
|
config_object_t *config);
|
||||||
|
typedef int (*fence_cleanup_callback)(backend_context_t c);
|
||||||
|
|
||||||
typedef struct _fence_callbacks {
|
typedef struct _fence_callbacks {
|
||||||
fence_null_callback null;
|
fence_null_callback null;
|
||||||
@ -82,15 +84,15 @@ typedef void serial_options;
|
|||||||
/* Directory path / hypervisor uri if using libvirt...
|
/* Directory path / hypervisor uri if using libvirt...
|
||||||
.. whatever you think you need... */
|
.. whatever you think you need... */
|
||||||
|
|
||||||
int serial_init(srv_context_t *, fence_callbacks_t *,
|
int serial_init(listener_context_t *, fence_callbacks_t *,
|
||||||
config_object_t *, void *priv);
|
config_object_t *, void *priv);
|
||||||
|
|
||||||
/* NULL = no timeout; wait forever */
|
/* NULL = no timeout; wait forever */
|
||||||
int serial_dispatch(srv_context_t, struct timeval *timeout);
|
int serial_dispatch(listener_context_t, struct timeval *timeout);
|
||||||
int serial_shutdown(srv_context_t);
|
int serial_shutdown(listener_context_t);
|
||||||
|
|
||||||
int mcast_init(srv_context_t *, const fence_callbacks_t *,
|
int mcast_init(listener_context_t *, const fence_callbacks_t *,
|
||||||
config_object_t *, void *priv);
|
config_object_t *, void *priv);
|
||||||
int mcast_dispatch(srv_context_t, struct timeval *timeout);
|
int mcast_dispatch(listener_context_t, struct timeval *timeout);
|
||||||
int mcast_shutdown(srv_context_t);
|
int mcast_shutdown(listener_context_t);
|
||||||
|
|
||||||
|
@ -278,7 +278,7 @@ libvirt_reboot(const char *vm_name, void *priv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
libvirt_init(srv_context_t *c, config_object_t *config)
|
libvirt_init(backend_context_t *c, config_object_t *config)
|
||||||
{
|
{
|
||||||
virConnectPtr vp;
|
virConnectPtr vp;
|
||||||
char value[256];
|
char value[256];
|
||||||
@ -298,7 +298,7 @@ libvirt_init(srv_context_t *c, config_object_t *config)
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
libvirt_shutdown(srv_context_t c)
|
libvirt_shutdown(backend_context_t c)
|
||||||
{
|
{
|
||||||
return virConnectClose((virConnectPtr)c);
|
return virConnectClose((virConnectPtr)c);
|
||||||
}
|
}
|
||||||
|
@ -16,12 +16,13 @@ int
|
|||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char val[80];
|
char val[80];
|
||||||
|
char listener_name[80];
|
||||||
|
char backend_name[80];
|
||||||
const char *config_file = DEFAULT_CONFIG_FILE;
|
const char *config_file = DEFAULT_CONFIG_FILE;
|
||||||
config_object_t *config;
|
config_object_t *config;
|
||||||
const plugin_t *p;
|
const plugin_t *p;
|
||||||
srv_context_t mcast_context = NULL;
|
listener_context_t listener_ctx = NULL;
|
||||||
srv_context_t libvirt_context; /*XXX these should be differently
|
backend_context_t backend_ctx = NULL;
|
||||||
named context types */
|
|
||||||
int debug_set = 0;
|
int debug_set = 0;
|
||||||
int opt;
|
int opt;
|
||||||
|
|
||||||
@ -55,13 +56,21 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
sc_dump(config, stdout);
|
sc_dump(config, stdout);
|
||||||
|
|
||||||
if (sc_get(config, "fence_virtd/@backend", val, sizeof(val))) {
|
if (sc_get(config, "fence_virtd/@backend", backend_name,
|
||||||
|
sizeof(backend_name))) {
|
||||||
printf("Failed to determine backend.\n");
|
printf("Failed to determine backend.\n");
|
||||||
printf("%s\n", val);
|
printf("%s\n", val);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Backend plugin: %s\n", val);
|
if (sc_get(config, "fence_virtd/@listener", listener_name,
|
||||||
|
sizeof(listener_name))) {
|
||||||
|
printf("Failed to determine backend.\n");
|
||||||
|
printf("%s\n", val);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Backend plugin: %s\n", backend_name);
|
||||||
|
|
||||||
#ifdef _MODULE
|
#ifdef _MODULE
|
||||||
if (plugin_load("./libvirt.so") < 0) {
|
if (plugin_load("./libvirt.so") < 0) {
|
||||||
@ -79,22 +88,22 @@ main(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->init(&libvirt_context, config) < 0) {
|
if (p->init(&backend_ctx, config) < 0) {
|
||||||
printf("%s failed to initialize\n", val);
|
printf("%s failed to initialize\n", val);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* only client we have now is mcast (fence_xvm behavior) */
|
/* only client we have now is mcast (fence_xvm behavior) */
|
||||||
if (mcast_init(&mcast_context, p->callbacks, config,
|
if (mcast_init(&listener_ctx, p->callbacks, config,
|
||||||
libvirt_context) < 0) {
|
backend_ctx) < 0) {
|
||||||
printf("Failed initialization!\n");
|
printf("Failed initialization!\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (mcast_dispatch(mcast_context, NULL) >= 0);
|
while (mcast_dispatch(listener_ctx, NULL) >= 0);
|
||||||
|
|
||||||
mcast_shutdown(mcast_context);
|
mcast_shutdown(listener_ctx);
|
||||||
p->cleanup(libvirt_context);
|
p->cleanup(backend_ctx);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -256,7 +256,7 @@ out:
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
mcast_dispatch(srv_context_t c, struct timeval *timeout)
|
mcast_dispatch(listener_context_t c, struct timeval *timeout)
|
||||||
{
|
{
|
||||||
mcast_info *info;
|
mcast_info *info;
|
||||||
fence_req_t data;
|
fence_req_t data;
|
||||||
@ -459,7 +459,7 @@ mcast_config(config_object_t *config, mcast_options *args)
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
mcast_init(srv_context_t *c, const fence_callbacks_t *cb,
|
mcast_init(listener_context_t *c, const fence_callbacks_t *cb,
|
||||||
config_object_t *config, void *priv)
|
config_object_t *config, void *priv)
|
||||||
{
|
{
|
||||||
mcast_info *info;
|
mcast_info *info;
|
||||||
@ -516,13 +516,13 @@ mcast_init(srv_context_t *c, const fence_callbacks_t *cb,
|
|||||||
|
|
||||||
info->magic = MCAST_MAGIC;
|
info->magic = MCAST_MAGIC;
|
||||||
info->mc_sock = mc_sock;
|
info->mc_sock = mc_sock;
|
||||||
*c = (srv_context_t)info;
|
*c = (listener_context_t)info;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
mcast_shutdown(srv_context_t c)
|
mcast_shutdown(listener_context_t c)
|
||||||
{
|
{
|
||||||
mcast_info *info = (mcast_info *)c;
|
mcast_info *info = (mcast_info *)c;
|
||||||
|
|
||||||
|
@ -83,14 +83,14 @@ plugin_find(const char *name)
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
plugin_init(const plugin_t *p, srv_context_t *c, config_object_t *config)
|
plugin_init(const plugin_t *p, backend_context_t *c, config_object_t *config)
|
||||||
{
|
{
|
||||||
return p->init(c, config);
|
return p->init(c, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
plugin_shutdown(const plugin_t *p, srv_context_t c)
|
plugin_shutdown(const plugin_t *p, backend_context_t c)
|
||||||
{
|
{
|
||||||
return p->cleanup(c);
|
return p->cleanup(c);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user