1 | /* |
---|
2 | * Copyright (c) 2006-2007, XenSource Inc. |
---|
3 | * |
---|
4 | * This library is free software; you can redistribute it and/or |
---|
5 | * modify it under the terms of the GNU Lesser General Public |
---|
6 | * License as published by the Free Software Foundation; either |
---|
7 | * version 2.1 of the License, or (at your option) any later version. |
---|
8 | * |
---|
9 | * This library is distributed in the hope that it will be useful, |
---|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
12 | * Lesser General Public License for more details. |
---|
13 | * |
---|
14 | * You should have received a copy of the GNU Lesser General Public |
---|
15 | * License along with this library; if not, write to the Free Software |
---|
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
17 | */ |
---|
18 | |
---|
19 | #ifndef XEN_HOST_H |
---|
20 | #define XEN_HOST_H |
---|
21 | |
---|
22 | #include <xen/api/xen_common.h> |
---|
23 | #include <xen/api/xen_host_cpu_decl.h> |
---|
24 | #include <xen/api/xen_host_decl.h> |
---|
25 | #include <xen/api/xen_host_metrics_decl.h> |
---|
26 | #include <xen/api/xen_pbd_decl.h> |
---|
27 | #include <xen/api/xen_pif_decl.h> |
---|
28 | #include <xen/api/xen_sr_decl.h> |
---|
29 | #include <xen/api/xen_string_set.h> |
---|
30 | #include <xen/api/xen_string_string_map.h> |
---|
31 | #include <xen/api/xen_vm_decl.h> |
---|
32 | |
---|
33 | |
---|
34 | /* |
---|
35 | * The host class. |
---|
36 | * |
---|
37 | * A physical host. |
---|
38 | */ |
---|
39 | |
---|
40 | |
---|
41 | /** |
---|
42 | * Free the given xen_host. The given handle must have been allocated |
---|
43 | * by this library. |
---|
44 | */ |
---|
45 | extern void |
---|
46 | xen_host_free(xen_host host); |
---|
47 | |
---|
48 | |
---|
49 | typedef struct xen_host_set |
---|
50 | { |
---|
51 | size_t size; |
---|
52 | xen_host *contents[]; |
---|
53 | } xen_host_set; |
---|
54 | |
---|
55 | /** |
---|
56 | * Allocate a xen_host_set of the given size. |
---|
57 | */ |
---|
58 | extern xen_host_set * |
---|
59 | xen_host_set_alloc(size_t size); |
---|
60 | |
---|
61 | /** |
---|
62 | * Free the given xen_host_set. The given set must have been allocated |
---|
63 | * by this library. |
---|
64 | */ |
---|
65 | extern void |
---|
66 | xen_host_set_free(xen_host_set *set); |
---|
67 | |
---|
68 | |
---|
69 | typedef struct xen_host_record |
---|
70 | { |
---|
71 | xen_host handle; |
---|
72 | char *uuid; |
---|
73 | char *name_label; |
---|
74 | char *name_description; |
---|
75 | int64_t api_version_major; |
---|
76 | int64_t api_version_minor; |
---|
77 | char *api_version_vendor; |
---|
78 | xen_string_string_map *api_version_vendor_implementation; |
---|
79 | bool enabled; |
---|
80 | xen_string_string_map *software_version; |
---|
81 | xen_string_string_map *other_config; |
---|
82 | struct xen_string_set *capabilities; |
---|
83 | xen_string_string_map *cpu_configuration; |
---|
84 | char *sched_policy; |
---|
85 | struct xen_string_set *supported_bootloaders; |
---|
86 | struct xen_vm_record_opt_set *resident_vms; |
---|
87 | xen_string_string_map *logging; |
---|
88 | struct xen_pif_record_opt_set *pifs; |
---|
89 | struct xen_sr_record_opt *suspend_image_sr; |
---|
90 | struct xen_sr_record_opt *crash_dump_sr; |
---|
91 | struct xen_pbd_record_opt_set *pbds; |
---|
92 | struct xen_host_cpu_record_opt_set *host_cpus; |
---|
93 | struct xen_host_metrics_record_opt *metrics; |
---|
94 | } xen_host_record; |
---|
95 | |
---|
96 | /** |
---|
97 | * Allocate a xen_host_record. |
---|
98 | */ |
---|
99 | extern xen_host_record * |
---|
100 | xen_host_record_alloc(void); |
---|
101 | |
---|
102 | /** |
---|
103 | * Free the given xen_host_record, and all referenced values. The |
---|
104 | * given record must have been allocated by this library. |
---|
105 | */ |
---|
106 | extern void |
---|
107 | xen_host_record_free(xen_host_record *record); |
---|
108 | |
---|
109 | |
---|
110 | typedef struct xen_host_record_opt |
---|
111 | { |
---|
112 | bool is_record; |
---|
113 | union |
---|
114 | { |
---|
115 | xen_host handle; |
---|
116 | xen_host_record *record; |
---|
117 | } u; |
---|
118 | } xen_host_record_opt; |
---|
119 | |
---|
120 | /** |
---|
121 | * Allocate a xen_host_record_opt. |
---|
122 | */ |
---|
123 | extern xen_host_record_opt * |
---|
124 | xen_host_record_opt_alloc(void); |
---|
125 | |
---|
126 | /** |
---|
127 | * Free the given xen_host_record_opt, and all referenced values. The |
---|
128 | * given record_opt must have been allocated by this library. |
---|
129 | */ |
---|
130 | extern void |
---|
131 | xen_host_record_opt_free(xen_host_record_opt *record_opt); |
---|
132 | |
---|
133 | |
---|
134 | typedef struct xen_host_record_set |
---|
135 | { |
---|
136 | size_t size; |
---|
137 | xen_host_record *contents[]; |
---|
138 | } xen_host_record_set; |
---|
139 | |
---|
140 | /** |
---|
141 | * Allocate a xen_host_record_set of the given size. |
---|
142 | */ |
---|
143 | extern xen_host_record_set * |
---|
144 | xen_host_record_set_alloc(size_t size); |
---|
145 | |
---|
146 | /** |
---|
147 | * Free the given xen_host_record_set, and all referenced values. The |
---|
148 | * given set must have been allocated by this library. |
---|
149 | */ |
---|
150 | extern void |
---|
151 | xen_host_record_set_free(xen_host_record_set *set); |
---|
152 | |
---|
153 | |
---|
154 | |
---|
155 | typedef struct xen_host_record_opt_set |
---|
156 | { |
---|
157 | size_t size; |
---|
158 | xen_host_record_opt *contents[]; |
---|
159 | } xen_host_record_opt_set; |
---|
160 | |
---|
161 | /** |
---|
162 | * Allocate a xen_host_record_opt_set of the given size. |
---|
163 | */ |
---|
164 | extern xen_host_record_opt_set * |
---|
165 | xen_host_record_opt_set_alloc(size_t size); |
---|
166 | |
---|
167 | /** |
---|
168 | * Free the given xen_host_record_opt_set, and all referenced values. |
---|
169 | * The given set must have been allocated by this library. |
---|
170 | */ |
---|
171 | extern void |
---|
172 | xen_host_record_opt_set_free(xen_host_record_opt_set *set); |
---|
173 | |
---|
174 | |
---|
175 | /** |
---|
176 | * Get a record containing the current state of the given host. |
---|
177 | */ |
---|
178 | extern bool |
---|
179 | xen_host_get_record(xen_session *session, xen_host_record **result, xen_host host); |
---|
180 | |
---|
181 | |
---|
182 | /** |
---|
183 | * Get a reference to the host instance with the specified UUID. |
---|
184 | */ |
---|
185 | extern bool |
---|
186 | xen_host_get_by_uuid(xen_session *session, xen_host *result, char *uuid); |
---|
187 | |
---|
188 | |
---|
189 | /** |
---|
190 | * Get all the host instances with the given label. |
---|
191 | */ |
---|
192 | extern bool |
---|
193 | xen_host_get_by_name_label(xen_session *session, struct xen_host_set **result, char *label); |
---|
194 | |
---|
195 | |
---|
196 | /** |
---|
197 | * Get the uuid field of the given host. |
---|
198 | */ |
---|
199 | extern bool |
---|
200 | xen_host_get_uuid(xen_session *session, char **result, xen_host host); |
---|
201 | |
---|
202 | |
---|
203 | /** |
---|
204 | * Get the name/label field of the given host. |
---|
205 | */ |
---|
206 | extern bool |
---|
207 | xen_host_get_name_label(xen_session *session, char **result, xen_host host); |
---|
208 | |
---|
209 | |
---|
210 | /** |
---|
211 | * Get the name/description field of the given host. |
---|
212 | */ |
---|
213 | extern bool |
---|
214 | xen_host_get_name_description(xen_session *session, char **result, xen_host host); |
---|
215 | |
---|
216 | |
---|
217 | /** |
---|
218 | * Get the API_version/major field of the given host. |
---|
219 | */ |
---|
220 | extern bool |
---|
221 | xen_host_get_api_version_major(xen_session *session, int64_t *result, xen_host host); |
---|
222 | |
---|
223 | |
---|
224 | /** |
---|
225 | * Get the API_version/minor field of the given host. |
---|
226 | */ |
---|
227 | extern bool |
---|
228 | xen_host_get_api_version_minor(xen_session *session, int64_t *result, xen_host host); |
---|
229 | |
---|
230 | |
---|
231 | /** |
---|
232 | * Get the API_version/vendor field of the given host. |
---|
233 | */ |
---|
234 | extern bool |
---|
235 | xen_host_get_api_version_vendor(xen_session *session, char **result, xen_host host); |
---|
236 | |
---|
237 | |
---|
238 | /** |
---|
239 | * Get the API_version/vendor_implementation field of the given host. |
---|
240 | */ |
---|
241 | extern bool |
---|
242 | xen_host_get_api_version_vendor_implementation(xen_session *session, xen_string_string_map **result, xen_host host); |
---|
243 | |
---|
244 | |
---|
245 | /** |
---|
246 | * Get the enabled field of the given host. |
---|
247 | */ |
---|
248 | extern bool |
---|
249 | xen_host_get_enabled(xen_session *session, bool *result, xen_host host); |
---|
250 | |
---|
251 | |
---|
252 | /** |
---|
253 | * Get the software_version field of the given host. |
---|
254 | */ |
---|
255 | extern bool |
---|
256 | xen_host_get_software_version(xen_session *session, xen_string_string_map **result, xen_host host); |
---|
257 | |
---|
258 | |
---|
259 | /** |
---|
260 | * Get the other_config field of the given host. |
---|
261 | */ |
---|
262 | extern bool |
---|
263 | xen_host_get_other_config(xen_session *session, xen_string_string_map **result, xen_host host); |
---|
264 | |
---|
265 | |
---|
266 | /** |
---|
267 | * Get the capabilities field of the given host. |
---|
268 | */ |
---|
269 | extern bool |
---|
270 | xen_host_get_capabilities(xen_session *session, struct xen_string_set **result, xen_host host); |
---|
271 | |
---|
272 | |
---|
273 | /** |
---|
274 | * Get the cpu_configuration field of the given host. |
---|
275 | */ |
---|
276 | extern bool |
---|
277 | xen_host_get_cpu_configuration(xen_session *session, xen_string_string_map **result, xen_host host); |
---|
278 | |
---|
279 | |
---|
280 | /** |
---|
281 | * Get the sched_policy field of the given host. |
---|
282 | */ |
---|
283 | extern bool |
---|
284 | xen_host_get_sched_policy(xen_session *session, char **result, xen_host host); |
---|
285 | |
---|
286 | |
---|
287 | /** |
---|
288 | * Get the supported_bootloaders field of the given host. |
---|
289 | */ |
---|
290 | extern bool |
---|
291 | xen_host_get_supported_bootloaders(xen_session *session, struct xen_string_set **result, xen_host host); |
---|
292 | |
---|
293 | |
---|
294 | /** |
---|
295 | * Get the resident_VMs field of the given host. |
---|
296 | */ |
---|
297 | extern bool |
---|
298 | xen_host_get_resident_vms(xen_session *session, struct xen_vm_set **result, xen_host host); |
---|
299 | |
---|
300 | |
---|
301 | /** |
---|
302 | * Get the logging field of the given host. |
---|
303 | */ |
---|
304 | extern bool |
---|
305 | xen_host_get_logging(xen_session *session, xen_string_string_map **result, xen_host host); |
---|
306 | |
---|
307 | |
---|
308 | /** |
---|
309 | * Get the PIFs field of the given host. |
---|
310 | */ |
---|
311 | extern bool |
---|
312 | xen_host_get_pifs(xen_session *session, struct xen_pif_set **result, xen_host host); |
---|
313 | |
---|
314 | |
---|
315 | /** |
---|
316 | * Get the suspend_image_sr field of the given host. |
---|
317 | */ |
---|
318 | extern bool |
---|
319 | xen_host_get_suspend_image_sr(xen_session *session, xen_sr *result, xen_host host); |
---|
320 | |
---|
321 | |
---|
322 | /** |
---|
323 | * Get the crash_dump_sr field of the given host. |
---|
324 | */ |
---|
325 | extern bool |
---|
326 | xen_host_get_crash_dump_sr(xen_session *session, xen_sr *result, xen_host host); |
---|
327 | |
---|
328 | |
---|
329 | /** |
---|
330 | * Get the PBDs field of the given host. |
---|
331 | */ |
---|
332 | extern bool |
---|
333 | xen_host_get_pbds(xen_session *session, struct xen_pbd_set **result, xen_host host); |
---|
334 | |
---|
335 | |
---|
336 | /** |
---|
337 | * Get the host_CPUs field of the given host. |
---|
338 | */ |
---|
339 | extern bool |
---|
340 | xen_host_get_host_cpus(xen_session *session, struct xen_host_cpu_set **result, xen_host host); |
---|
341 | |
---|
342 | |
---|
343 | /** |
---|
344 | * Get the metrics field of the given host. |
---|
345 | */ |
---|
346 | extern bool |
---|
347 | xen_host_get_metrics(xen_session *session, xen_host_metrics *result, xen_host host); |
---|
348 | |
---|
349 | |
---|
350 | /** |
---|
351 | * Set the name/label field of the given host. |
---|
352 | */ |
---|
353 | extern bool |
---|
354 | xen_host_set_name_label(xen_session *session, xen_host host, char *label); |
---|
355 | |
---|
356 | |
---|
357 | /** |
---|
358 | * Set the name/description field of the given host. |
---|
359 | */ |
---|
360 | extern bool |
---|
361 | xen_host_set_name_description(xen_session *session, xen_host host, char *description); |
---|
362 | |
---|
363 | |
---|
364 | /** |
---|
365 | * Set the other_config field of the given host. |
---|
366 | */ |
---|
367 | extern bool |
---|
368 | xen_host_set_other_config(xen_session *session, xen_host host, xen_string_string_map *other_config); |
---|
369 | |
---|
370 | |
---|
371 | /** |
---|
372 | * Add the given key-value pair to the other_config field of the given |
---|
373 | * host. |
---|
374 | */ |
---|
375 | extern bool |
---|
376 | xen_host_add_to_other_config(xen_session *session, xen_host host, char *key, char *value); |
---|
377 | |
---|
378 | |
---|
379 | /** |
---|
380 | * Remove the given key and its corresponding value from the |
---|
381 | * other_config field of the given host. If the key is not in that Map, then |
---|
382 | * do nothing. |
---|
383 | */ |
---|
384 | extern bool |
---|
385 | xen_host_remove_from_other_config(xen_session *session, xen_host host, char *key); |
---|
386 | |
---|
387 | |
---|
388 | /** |
---|
389 | * Set the logging field of the given host. |
---|
390 | */ |
---|
391 | extern bool |
---|
392 | xen_host_set_logging(xen_session *session, xen_host host, xen_string_string_map *logging); |
---|
393 | |
---|
394 | |
---|
395 | /** |
---|
396 | * Add the given key-value pair to the logging field of the given host. |
---|
397 | */ |
---|
398 | extern bool |
---|
399 | xen_host_add_to_logging(xen_session *session, xen_host host, char *key, char *value); |
---|
400 | |
---|
401 | |
---|
402 | /** |
---|
403 | * Remove the given key and its corresponding value from the logging |
---|
404 | * field of the given host. If the key is not in that Map, then do nothing. |
---|
405 | */ |
---|
406 | extern bool |
---|
407 | xen_host_remove_from_logging(xen_session *session, xen_host host, char *key); |
---|
408 | |
---|
409 | |
---|
410 | /** |
---|
411 | * Set the suspend_image_sr field of the given host. |
---|
412 | */ |
---|
413 | extern bool |
---|
414 | xen_host_set_suspend_image_sr(xen_session *session, xen_host host, xen_sr suspend_image_sr); |
---|
415 | |
---|
416 | |
---|
417 | /** |
---|
418 | * Set the crash_dump_sr field of the given host. |
---|
419 | */ |
---|
420 | extern bool |
---|
421 | xen_host_set_crash_dump_sr(xen_session *session, xen_host host, xen_sr crash_dump_sr); |
---|
422 | |
---|
423 | |
---|
424 | /** |
---|
425 | * Puts the host into a state in which no new VMs can be started. |
---|
426 | * Currently active VMs on the host continue to execute. |
---|
427 | */ |
---|
428 | extern bool |
---|
429 | xen_host_disable(xen_session *session, xen_host host); |
---|
430 | |
---|
431 | |
---|
432 | /** |
---|
433 | * Puts the host into a state in which new VMs can be started. |
---|
434 | */ |
---|
435 | extern bool |
---|
436 | xen_host_enable(xen_session *session, xen_host host); |
---|
437 | |
---|
438 | |
---|
439 | /** |
---|
440 | * Shutdown the host. (This function can only be called if there are no |
---|
441 | * currently running VMs on the host and it is disabled.). |
---|
442 | */ |
---|
443 | extern bool |
---|
444 | xen_host_shutdown(xen_session *session, xen_host host); |
---|
445 | |
---|
446 | |
---|
447 | /** |
---|
448 | * Reboot the host. (This function can only be called if there are no |
---|
449 | * currently running VMs on the host and it is disabled.). |
---|
450 | */ |
---|
451 | extern bool |
---|
452 | xen_host_reboot(xen_session *session, xen_host host); |
---|
453 | |
---|
454 | |
---|
455 | /** |
---|
456 | * Get the host xen dmesg. |
---|
457 | */ |
---|
458 | extern bool |
---|
459 | xen_host_dmesg(xen_session *session, char **result, xen_host host); |
---|
460 | |
---|
461 | |
---|
462 | /** |
---|
463 | * Get the host xen dmesg, and clear the buffer. |
---|
464 | */ |
---|
465 | extern bool |
---|
466 | xen_host_dmesg_clear(xen_session *session, char **result, xen_host host); |
---|
467 | |
---|
468 | |
---|
469 | /** |
---|
470 | * Get the host's log file. |
---|
471 | */ |
---|
472 | extern bool |
---|
473 | xen_host_get_log(xen_session *session, char **result, xen_host host); |
---|
474 | |
---|
475 | |
---|
476 | /** |
---|
477 | * Inject the given string as debugging keys into Xen. |
---|
478 | */ |
---|
479 | extern bool |
---|
480 | xen_host_send_debug_keys(xen_session *session, xen_host host, char *keys); |
---|
481 | |
---|
482 | |
---|
483 | /** |
---|
484 | * List all supported methods. |
---|
485 | */ |
---|
486 | extern bool |
---|
487 | xen_host_list_methods(xen_session *session, struct xen_string_set **result); |
---|
488 | |
---|
489 | |
---|
490 | /** |
---|
491 | * Return a list of all the hosts known to the system. |
---|
492 | */ |
---|
493 | extern bool |
---|
494 | xen_host_get_all(xen_session *session, struct xen_host_set **result); |
---|
495 | |
---|
496 | |
---|
497 | #endif |
---|