2 * libvscmgmt.h: Library for Virtualized Super Computer Management
4 * Copyright (C) 2009 Matthias Bolte <matthias.bolte@googlemail.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #ifndef __VSC_MGMT_H__
22 #define __VSC_MGMT_H__
24 #include <stdio.h> /* for FILE */
25 #include <sys/time.h> /* for struct timeval */
31 #define VSC_MGMT__VERION__MAJOR 0
32 #define VSC_MGMT__VERION__MINOR 1
33 #define VSC_MGMT__VERION__PATCH 0
35 #define VSC_MGMT__UUID__SIZE 16
36 #define VSC_MGMT__UUID__STRING_SIZE (36 + 1)
38 #define VSC_MGMT__IPV4__SIZE 4
39 #define VSC_MGMT__IPV4__STRING_SIZE (16 + 1)
41 typedef enum _VscMgmtCode VscMgmtCode;
42 typedef enum _VscMgmtVmState VscMgmtVmState;
43 typedef enum _VscMgmtHostType VscMgmtHostType;
44 typedef enum _VscMgmtUuidType VscMgmtUuidType;
45 typedef struct _VscMgmtError VscMgmtError;
46 typedef struct _VscMgmtUuid VscMgmtUuid;
47 typedef struct _VscMgmtIpv4 VscMgmtIpv4;
48 typedef struct _VscMgmtVmInfo VscMgmtVmInfo;
49 typedef struct _VscMgmtVmResourceConfig VscMgmtVmResourceConfig;
50 typedef struct _VscMgmtVmNetworkConfig VscMgmtVmNetworkConfig;
51 typedef struct _VscMgmtSuspensionInfo VscMgmtSuspensionInfo;
52 typedef struct _VscMgmtCheckpointInfo VscMgmtCheckpointInfo;
53 typedef struct _VscMgmtHostInfo VscMgmtHostInfo;
56 VSC_MGMT__CODE__UNDEFINED = 0,
57 VSC_MGMT__CODE__INTERNAL_ERROR,
58 VSC_MGMT__CODE__OUT_OF_MEMORY,
59 VSC_MGMT__CODE__XMLRPC_ERROR,
60 VSC_MGMT__CODE__INVALID_ARGUMENT,
61 VSC_MGMT__CODE__INVALID_CALL,
62 VSC_MGMT__CODE__INVALID_UUID_STRING,
63 VSC_MGMT__CODE__INVALID_IPV4_STRING,
64 VSC_MGMT__CODE__INVALID_HOST_TYPE_STRING,
65 VSC_MGMT__CODE__NOT_INITIALIZED,
66 VSC_MGMT__CODE__NOT_IMPLEMENTED_YET,
67 VSC_MGMT__CODE__TRACE,
70 enum _VscMgmtVmState {
71 VSC_MGMT__VM_STATE__UNDEFINED = 0,
72 VSC_MGMT__VM_STATE__RUNNING,
73 VSC_MGMT__VM_STATE__SUSPENDED,
74 VSC_MGMT__VM_STATE__ERROR,
77 enum _VscMgmtHostType {
78 VSC_MGMT__HOST_TYPE__UNDEFINED = 0,
79 VSC_MGMT__HOST_TYPE__XEN,
80 VSC_MGMT__HOST_TYPE__ESX,
81 VSC_MGMT__HOST_TYPE__KVM,
84 enum _VscMgmtUuidType {
85 VSC_MGMT__UUID_TYPE__UNDEFINED = 0,
86 VSC_MGMT__UUID_TYPE__INVALID,
87 VSC_MGMT__UUID_TYPE__VM,
88 VSC_MGMT__UUID_TYPE__SUSPENSION,
89 VSC_MGMT__UUID_TYPE__CHECKPOINT,
92 struct _VscMgmtError {
100 struct timeval timestamp;
103 struct _VscMgmtUuid {
105 unsigned char bytes[VSC_MGMT__UUID__SIZE];
108 struct _VscMgmtIpv4 {
110 unsigned char bytes[VSC_MGMT__IPV4__SIZE];
113 struct _VscMgmtVmResourceConfig {
117 struct _VscMgmtVmNetworkConfig {
119 VscMgmtIpv4 vm_subnet;
120 VscMgmtIpv4 vm_subnet_mask;
123 struct _VscMgmtVmInfo {
125 VscMgmtIpv4 host_ipv4;
126 VscMgmtVmState vm_state;
127 VscMgmtVmResourceConfig vm_resource_config;
128 VscMgmtVmNetworkConfig vm_network_config;
131 struct _VscMgmtSuspensionInfo {
135 struct _VscMgmtCheckpointInfo {
139 struct _VscMgmtHostInfo {
140 VscMgmtHostInfo *next;
141 VscMgmtIpv4 host_ipv4;
142 VscMgmtHostType host_type;
152 vsc_mgmt_error_init (VscMgmtError *error);
155 vsc_mgmt_error_cleanup (VscMgmtError *error);
158 * Returns the string representaion of the given error code.
160 * The string must not be freed by the caller.
162 const char * /* error_string */
163 vsc_mgmt_error_string (VscMgmtCode code);
166 vsc_mgmt_error_fprint (VscMgmtError *error, FILE *stream);
173 vsc_mgmt_free (void *memory);
180 * Appends a duplicate of the given UUID to the list.
182 * Always returns a pointer to the first UUID item in the list, so that this
183 * function can be used for initialization and for appending.
185 VscMgmtUuid * /* uuid_list */
186 vsc_mgmt_uuid_list_append (VscMgmtError *error, VscMgmtUuid *uuid_list,
187 const VscMgmtUuid *uuid);
190 * Recursively frees the given UUID list.
193 vsc_mgmt_uuid_list_free (VscMgmtUuid *uuid_list);
196 * Parses a UUID from its string representation.
199 vsc_mgmt_uuid_parse (VscMgmtError *error, const char *uuid_string,
203 * Formats a UUID to its string representation.
206 vsc_mgmt_uuid_format (const VscMgmtUuid *uuid, char *uuid_string);
213 * Appends a duplicate of the given IPv4 to the list.
215 * Always returns a pointer to the first IPv4 item in the list, so that this
216 * function can be used for initialization and for appending.
218 VscMgmtIpv4 * /* ipv4_list */
219 vsc_mgmt_ipv4_list_append (VscMgmtError *error,
220 VscMgmtIpv4 *ipv4_list,
221 const VscMgmtIpv4 *ipv4);
224 * Recursively frees the given IPv4 list.
227 vsc_mgmt_ipv4_list_free (VscMgmtIpv4 *ipv4_list);
230 * Parses an IPv4 from its string representation.
233 vsc_mgmt_ipv4_parse (VscMgmtError *error, const char *ipv4_string,
237 * Formats an IPv4 to its string representation.
240 vsc_mgmt_ipv4_format (const VscMgmtIpv4 *ipv4, char *ipv4_string);
247 vsc_mgmt_global_init (VscMgmtError *error, const char *backend_config);
250 vsc_mgmt_global_cleanup (void);
253 vsc_mgmt_global_backup (VscMgmtError *error);
256 vsc_mgmt_global_recover (VscMgmtError *error);
262 VscMgmtUuid * /* vm_uuid_list */
263 vsc_mgmt_vm_start (VscMgmtError *error, const char* image_path,
264 const VscMgmtIpv4 *host_ipv4_list,
265 const VscMgmtVmResourceConfig *vm_resource_config,
266 const VscMgmtVmNetworkConfig *vm_network_config);
269 vsc_mgmt_vm_stop (VscMgmtError *error,
270 const VscMgmtUuid *vm_uuid);
273 vsc_mgmt_vm_reboot (VscMgmtError *error,
274 const VscMgmtUuid *vm_uuid);
277 vsc_mgmt_vm_migrate (VscMgmtError *error,
278 const VscMgmtUuid *vm_uuid,
279 const VscMgmtIpv4 *host_ipv4);
282 vsc_mgmt_vm_get_info (VscMgmtError *error,
283 const VscMgmtUuid *vm_uuid,
284 VscMgmtVmInfo *vm_info);
287 vsc_mgmt_vm_get_uuid (VscMgmtError *error,
288 const VscMgmtIpv4 *vm_ipv4,
289 VscMgmtUuid *vm_uuid);
292 vsc_mgmt_vm_get_host (VscMgmtError *error,
293 const VscMgmtUuid *vm_uuid,
294 VscMgmtIpv4 *host_ipv4);
296 VscMgmtVmState /* vm_state */
297 vsc_mgmt_vm_get_state (VscMgmtError *error,
298 const VscMgmtUuid *vm_uuid);
301 vsc_mgmt_vm_set_resource_config (VscMgmtError *error,
302 const VscMgmtUuid *vm_uuid,
303 const VscMgmtVmResourceConfig *vm_resource_config);
306 vsc_mgmt_vm_get_resource_config (VscMgmtError *error,
307 const VscMgmtUuid *vm_uuid,
308 VscMgmtVmResourceConfig *vm_resource_config);
311 vsc_mgmt_vm_get_network_config (VscMgmtError *error,
312 const VscMgmtUuid *vm_uuid,
313 VscMgmtVmNetworkConfig *vm_network_config);
320 vsc_mgmt_suspension_create (VscMgmtError *error,
321 const VscMgmtUuid *vm_uuid_list,
322 VscMgmtUuid *suspension_uuid);
325 vsc_mgmt_suspension_resume (VscMgmtError *error,
326 const VscMgmtUuid *suspension_uuid);
329 vsc_mgmt_suspension_get_info (VscMgmtError *error,
330 const VscMgmtUuid *suspension_uuid,
331 VscMgmtSuspensionInfo *suspension_info);
338 vsc_mgmt_checkpoint_create (VscMgmtError *error,
339 const VscMgmtUuid *vm_uuid_list,
340 VscMgmtUuid *checkpoint_uuid);
343 vsc_mgmt_checkpoint_delete (VscMgmtError *error,
344 const VscMgmtUuid *checkpoint_uuid);
347 vsc_mgmt_checkpoint_restore (VscMgmtError *error,
348 const VscMgmtUuid *checkpoint_uuid);
351 vsc_mgmt_checkpoint_get_info (VscMgmtError *error,
352 const VscMgmtUuid *checkpoint_uuid,
353 VscMgmtCheckpointInfo *checkpoint_info);
360 vsc_mgmt_host_add (VscMgmtError *error,
361 const VscMgmtHostInfo *host_info);
364 vsc_mgmt_host_remove (VscMgmtError *error,
365 const VscMgmtIpv4 *host_ipv4);
368 vsc_mgmt_host_get_info (VscMgmtError *error,
369 const VscMgmtIpv4 *host_ipv4,
370 VscMgmtHostInfo *host_info);
373 * Returns a UUID list representing all virtual machines currently available
376 * The list must be freed by the caller via the vsc_mgmt_uuid_list_free
379 VscMgmtUuid * /* vm_uuid_list */
380 vsc_mgmt_host_get_vm_list (VscMgmtError *error,
381 const VscMgmtIpv4 *host_ipv4);
388 * Parses a host type from its string representation and returns it.
390 VscMgmtHostType /* host_type */
391 vsc_mgmt_host_type_parse (VscMgmtError *error,
392 const char *host_type_string);
395 * Returns the string representaion of the given host type.
397 * The string must not be freed by the caller.
399 const char * /* host_type_string */
400 vsc_mgmt_host_type_string (VscMgmtHostType host_type);
407 * Returns an IPv4 list representing all currently known host.
409 * The list must be freed by the caller via the vsc_mgmt_ipv4_list_free
412 VscMgmtIpv4 * /* host_ipv4_list */
413 vsc_mgmt_get_host_list (VscMgmtError *error);
415 VscMgmtUuid * /* checkpoint_uuid_list */
416 vsc_mgmt_get_checkpoint_list (VscMgmtError *error);
418 VscMgmtUuidType /* uuid_type */
419 vsc_mgmt_get_uuid_type (VscMgmtError *error, const VscMgmtUuid *uuid);
422 vsc_mgmt_get_version (int *major, int *minor, int *patch);
428 #endif /* __VSC_MGMT_H__ */