2009-07-28 18:46:53 +04:00
/* */
2009-09-02 00:22:30 +04:00
# define PLUGIN_VERSION_LISTENER ((double)0.1)
2009-08-17 17:58:06 +04:00
# define PLUGIN_VERSION_BACKEND ((double)0.1)
2009-09-02 00:22:30 +04:00
# define LISTENER_VER_SYM listener_plugin_version
2009-08-17 17:58:06 +04:00
# define BACKEND_VER_SYM backend_plugin_version
2009-09-02 00:22:30 +04:00
# define LISTENER_INFO_SYM listener_plugin_info
2009-08-17 17:58:06 +04:00
# define BACKEND_INFO_SYM backend_plugin_info
2009-09-02 00:22:30 +04:00
# define LISTENER_VER_STR "listener_plugin_version"
2009-08-17 17:58:06 +04:00
# define BACKEND_VER_STR "backend_plugin_version"
2009-09-02 00:22:30 +04:00
# define LISTENER_INFO_STR "listener_plugin_info"
2009-08-17 17:58:06 +04:00
# define BACKEND_INFO_STR "backend_plugin_info"
2009-08-28 22:12:46 +04:00
typedef void * listener_context_t ;
typedef void * backend_context_t ;
2009-07-28 18:46:53 +04:00
/* These callbacks hand requests off to the
appropriate backend . */
/* Do nothing. Returns 1 (failure) to caller */
typedef int ( * fence_null_callback ) ( const char * vm_name ,
void * priv ) ;
/* Turn the VM 'off'. Returns 0 to caller if successful or
nonzero if unsuccessful . */
2009-09-15 18:28:20 +04:00
typedef int ( * fence_off_callback ) ( const char * vm_name , uint32_t seqno ,
2009-07-28 18:46:53 +04:00
void * priv ) ;
/* Turn the VM 'on'. Returns 0 to caller if successful or
nonzero if unsuccessful . */
2009-09-15 18:28:20 +04:00
typedef int ( * fence_on_callback ) ( const char * vm_name , uint32_t seqno ,
2009-07-28 18:46:53 +04:00
void * priv ) ;
/* Reboot a VM. Returns 0 to caller if successful or
nonzero if unsuccessful . */
2009-09-15 18:28:20 +04:00
typedef int ( * fence_reboot_callback ) ( const char * vm_name , uint32_t seqno ,
2009-07-28 18:46:53 +04:00
void * priv ) ;
/* Get status of a VM. Returns 0 to caller if VM is alive or
nonzero if VM is not alive . */
typedef int ( * fence_status_callback ) ( const char * vm_name ,
void * priv ) ;
/* Get status of backend. Returns 0 to caller if backend
is responding to requests . */
typedef int ( * fence_devstatus_callback ) ( void * priv ) ;
2009-09-02 00:22:30 +04:00
typedef int ( * backend_init_fn ) ( backend_context_t * c ,
config_object_t * config ) ;
typedef int ( * backend_cleanup_fn ) ( backend_context_t c ) ;
2009-08-12 21:20:50 +04:00
2009-07-28 18:46:53 +04:00
typedef struct _fence_callbacks {
fence_null_callback null ;
fence_off_callback off ;
fence_on_callback on ;
fence_reboot_callback reboot ;
fence_status_callback status ;
fence_devstatus_callback devstatus ;
} fence_callbacks_t ;
2009-09-02 00:22:30 +04:00
typedef struct backend_plugin {
2009-08-12 21:20:50 +04:00
const char * name ;
const char * version ;
const fence_callbacks_t * callbacks ;
2009-09-02 00:22:30 +04:00
backend_init_fn init ;
backend_cleanup_fn cleanup ;
} backend_plugin_t ;
typedef int ( * listener_init_fn ) ( listener_context_t * c ,
const fence_callbacks_t * cb ,
config_object_t * config ,
void * priv ) ;
typedef int ( * listener_dispatch_fn ) ( listener_context_t c ,
struct timeval * timeout ) ;
typedef int ( * listener_cleanup_fn ) ( listener_context_t c ) ;
typedef struct listener_plugin {
const char * name ;
const char * version ;
listener_init_fn init ;
listener_dispatch_fn dispatch ;
listener_cleanup_fn cleanup ;
} listener_plugin_t ;
typedef enum {
PLUGIN_NONE = 0 ,
PLUGIN_LISTENER = 1 ,
PLUGIN_BACKEND = 2
} plugin_type_t ;
int plugin_reg_backend ( const backend_plugin_t * plugin ) ;
int plugin_reg_listener ( const listener_plugin_t * plugin ) ;
const backend_plugin_t * plugin_find_backend ( const char * name ) ;
const listener_plugin_t * plugin_find_listener ( const char * name ) ;
2009-07-28 18:46:53 +04:00
2009-08-12 21:20:50 +04:00
void plugin_dump ( void ) ;
2009-08-17 17:58:06 +04:00
# ifdef _MODULE
2009-09-02 02:54:17 +04:00
int plugin_load ( const char * filename ) ;
int plugin_search ( const char * pathname ) ;
2009-08-12 21:20:50 +04:00
# endif
2009-07-28 18:46:53 +04:00