File: server_plugin.h

package info (click to toggle)
fence-virt 1.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 772 kB
  • sloc: ansic: 10,257; cpp: 382; makefile: 272; sh: 214; lex: 113; yacc: 105
file content (131 lines) | stat: -rw-r--r-- 3,699 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*  */

#ifndef _SERVER_PLUGIN_H
#define _SERVER_PLUGIN_H

#include "config.h"

#define PLUGIN_VERSION_LISTENER ((double)0.3)
#define PLUGIN_VERSION_BACKEND  ((double)0.2)

#define LISTENER_VER_SYM listener_plugin_version
#define BACKEND_VER_SYM backend_plugin_version
#define LISTENER_INFO_SYM listener_plugin_info
#define BACKEND_INFO_SYM backend_plugin_info
#define LISTENER_VER_STR "listener_plugin_version"
#define BACKEND_VER_STR "backend_plugin_version"
#define LISTENER_INFO_STR "listener_plugin_info"
#define BACKEND_INFO_STR "backend_plugin_info"




typedef void * listener_context_t;
typedef void * backend_context_t;

/* 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. */
typedef int (*fence_off_callback)(const char *vm_name, const char *src,
				  uint32_t seqno, void *priv);

/* Turn the VM 'on'.  Returns 0 to caller if successful or
   nonzero if unsuccessful. */
typedef int (*fence_on_callback)(const char *vm_name, const char *src,
				 uint32_t seqno, void *priv);

/* Reboot a VM.  Returns 0 to caller if successful or
   nonzero if unsuccessful. */
typedef int (*fence_reboot_callback)(const char *vm_name, const char *src,
				     uint32_t seqno, 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);


/* VMs available to fence.  Returns 0 to caller if backend
   is responding to requests and a host list can be produced */
typedef int (*hostlist_callback)(const char *vm_name, const char *uuid,
				 int state, void *arg);
typedef int (*fence_hostlist_callback)(hostlist_callback cb,
				       void *arg, void *priv);

typedef int (*backend_init_fn)(backend_context_t *c,
    			       config_object_t *config);
typedef int (*backend_cleanup_fn)(backend_context_t c);

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_hostlist_callback hostlist;
} fence_callbacks_t;

typedef struct backend_plugin {
	const char *name;
	const char *version;
	const fence_callbacks_t *callbacks;
	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, 
				map_object_t *map,
				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;

#ifdef __cplusplus
extern "C" {
#endif

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);

void plugin_dump(void);
#ifdef _MODULE
int plugin_load(const char *filename);
int plugin_search(const char *pathname);
#endif

#ifdef __cplusplus
}
#endif
#endif