ia64/xen-unstable

view tools/libxen/src/xen_vm.c @ 12317:4e3ddf1288fb

Add support for VM.destroy RPC in libxen.

Signed-off-by: Jim Fehlig <jfehlig@novell.com>
author jfehlig@jfehlig2.provo.novell.com
date Tue Nov 07 18:14:16 2006 -0700 (2006-11-07)
parents 5bef3f695b55
children 08b38d041269
line source
1 /*
2 * Copyright (c) 2006, 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 */
20 #include <stddef.h>
21 #include <stdlib.h>
23 #include "xen_boot_type_internal.h"
24 #include "xen_common.h"
25 #include "xen_cpu_feature.h"
26 #include "xen_cpu_feature_internal.h"
27 #include "xen_host.h"
28 #include "xen_int_float_map.h"
29 #include "xen_internal.h"
30 #include "xen_on_crash_behaviour_internal.h"
31 #include "xen_on_normal_exit_internal.h"
32 #include "xen_string_string_map.h"
33 #include "xen_vbd.h"
34 #include "xen_vif.h"
35 #include "xen_vm.h"
36 #include "xen_vm_power_state_internal.h"
37 #include "xen_vtpm.h"
40 XEN_FREE(xen_vm)
41 XEN_SET_ALLOC_FREE(xen_vm)
42 XEN_ALLOC(xen_vm_record)
43 XEN_SET_ALLOC_FREE(xen_vm_record)
44 XEN_ALLOC(xen_vm_record_opt)
45 XEN_RECORD_OPT_FREE(xen_vm)
46 XEN_SET_ALLOC_FREE(xen_vm_record_opt)
49 static const struct_member xen_vm_record_struct_members[] =
50 {
51 { .key = "uuid",
52 .type = &abstract_type_string,
53 .offset = offsetof(xen_vm_record, uuid) },
54 { .key = "power_state",
55 .type = &xen_vm_power_state_abstract_type_,
56 .offset = offsetof(xen_vm_record, power_state) },
57 { .key = "name_label",
58 .type = &abstract_type_string,
59 .offset = offsetof(xen_vm_record, name_label) },
60 { .key = "name_description",
61 .type = &abstract_type_string,
62 .offset = offsetof(xen_vm_record, name_description) },
63 { .key = "user_version",
64 .type = &abstract_type_int,
65 .offset = offsetof(xen_vm_record, user_version) },
66 { .key = "is_a_template",
67 .type = &abstract_type_bool,
68 .offset = offsetof(xen_vm_record, is_a_template) },
69 { .key = "resident_on",
70 .type = &abstract_type_ref,
71 .offset = offsetof(xen_vm_record, resident_on) },
72 { .key = "memory_static_max",
73 .type = &abstract_type_int,
74 .offset = offsetof(xen_vm_record, memory_static_max) },
75 { .key = "memory_dynamic_max",
76 .type = &abstract_type_int,
77 .offset = offsetof(xen_vm_record, memory_dynamic_max) },
78 { .key = "memory_actual",
79 .type = &abstract_type_int,
80 .offset = offsetof(xen_vm_record, memory_actual) },
81 { .key = "memory_dynamic_min",
82 .type = &abstract_type_int,
83 .offset = offsetof(xen_vm_record, memory_dynamic_min) },
84 { .key = "memory_static_min",
85 .type = &abstract_type_int,
86 .offset = offsetof(xen_vm_record, memory_static_min) },
87 { .key = "vcpus_policy",
88 .type = &abstract_type_string,
89 .offset = offsetof(xen_vm_record, vcpus_policy) },
90 { .key = "vcpus_params",
91 .type = &abstract_type_string,
92 .offset = offsetof(xen_vm_record, vcpus_params) },
93 { .key = "vcpus_number",
94 .type = &abstract_type_int,
95 .offset = offsetof(xen_vm_record, vcpus_number) },
96 { .key = "vcpus_utilisation",
97 .type = &abstract_type_int_float_map,
98 .offset = offsetof(xen_vm_record, vcpus_utilisation) },
99 { .key = "vcpus_features_required",
100 .type = &xen_cpu_feature_set_abstract_type_,
101 .offset = offsetof(xen_vm_record, vcpus_features_required) },
102 { .key = "vcpus_features_can_use",
103 .type = &xen_cpu_feature_set_abstract_type_,
104 .offset = offsetof(xen_vm_record, vcpus_features_can_use) },
105 { .key = "vcpus_features_force_on",
106 .type = &xen_cpu_feature_set_abstract_type_,
107 .offset = offsetof(xen_vm_record, vcpus_features_force_on) },
108 { .key = "vcpus_features_force_off",
109 .type = &xen_cpu_feature_set_abstract_type_,
110 .offset = offsetof(xen_vm_record, vcpus_features_force_off) },
111 { .key = "actions_after_shutdown",
112 .type = &xen_on_normal_exit_abstract_type_,
113 .offset = offsetof(xen_vm_record, actions_after_shutdown) },
114 { .key = "actions_after_reboot",
115 .type = &xen_on_normal_exit_abstract_type_,
116 .offset = offsetof(xen_vm_record, actions_after_reboot) },
117 { .key = "actions_after_suspend",
118 .type = &xen_on_normal_exit_abstract_type_,
119 .offset = offsetof(xen_vm_record, actions_after_suspend) },
120 { .key = "actions_after_crash",
121 .type = &xen_on_crash_behaviour_abstract_type_,
122 .offset = offsetof(xen_vm_record, actions_after_crash) },
123 { .key = "VIFs",
124 .type = &abstract_type_ref_set,
125 .offset = offsetof(xen_vm_record, vifs) },
126 { .key = "VBDs",
127 .type = &abstract_type_ref_set,
128 .offset = offsetof(xen_vm_record, vbds) },
129 { .key = "VTPMs",
130 .type = &abstract_type_ref_set,
131 .offset = offsetof(xen_vm_record, vtpms) },
132 { .key = "bios_boot",
133 .type = &abstract_type_string,
134 .offset = offsetof(xen_vm_record, bios_boot) },
135 { .key = "platform_std_VGA",
136 .type = &abstract_type_bool,
137 .offset = offsetof(xen_vm_record, platform_std_vga) },
138 { .key = "platform_serial",
139 .type = &abstract_type_string,
140 .offset = offsetof(xen_vm_record, platform_serial) },
141 { .key = "platform_localtime",
142 .type = &abstract_type_bool,
143 .offset = offsetof(xen_vm_record, platform_localtime) },
144 { .key = "platform_clock_offset",
145 .type = &abstract_type_bool,
146 .offset = offsetof(xen_vm_record, platform_clock_offset) },
147 { .key = "platform_enable_audio",
148 .type = &abstract_type_bool,
149 .offset = offsetof(xen_vm_record, platform_enable_audio) },
150 { .key = "builder",
151 .type = &abstract_type_string,
152 .offset = offsetof(xen_vm_record, builder) },
153 { .key = "boot_method",
154 .type = &xen_boot_type_abstract_type_,
155 .offset = offsetof(xen_vm_record, boot_method) },
156 { .key = "kernel_kernel",
157 .type = &abstract_type_string,
158 .offset = offsetof(xen_vm_record, kernel_kernel) },
159 { .key = "kernel_initrd",
160 .type = &abstract_type_string,
161 .offset = offsetof(xen_vm_record, kernel_initrd) },
162 { .key = "kernel_args",
163 .type = &abstract_type_string,
164 .offset = offsetof(xen_vm_record, kernel_args) },
165 { .key = "grub_cmdline",
166 .type = &abstract_type_string,
167 .offset = offsetof(xen_vm_record, grub_cmdline) },
168 { .key = "PCI_bus",
169 .type = &abstract_type_string,
170 .offset = offsetof(xen_vm_record, pci_bus) },
171 { .key = "tools_version",
172 .type = &abstract_type_string_string_map,
173 .offset = offsetof(xen_vm_record, tools_version) },
174 { .key = "otherConfig",
175 .type = &abstract_type_string_string_map,
176 .offset = offsetof(xen_vm_record, otherconfig) }
177 };
179 const abstract_type xen_vm_record_abstract_type_ =
180 {
181 .typename = STRUCT,
182 .struct_size = sizeof(xen_vm_record),
183 .member_count =
184 sizeof(xen_vm_record_struct_members) / sizeof(struct_member),
185 .members = xen_vm_record_struct_members
186 };
189 void
190 xen_vm_record_free(xen_vm_record *record)
191 {
192 if (record == NULL)
193 {
194 return;
195 }
196 free(record->handle);
197 free(record->uuid);
198 free(record->name_label);
199 free(record->name_description);
200 xen_host_record_opt_free(record->resident_on);
201 free(record->vcpus_policy);
202 free(record->vcpus_params);
203 xen_int_float_map_free(record->vcpus_utilisation);
204 xen_cpu_feature_set_free(record->vcpus_features_required);
205 xen_cpu_feature_set_free(record->vcpus_features_can_use);
206 xen_cpu_feature_set_free(record->vcpus_features_force_on);
207 xen_cpu_feature_set_free(record->vcpus_features_force_off);
208 xen_vif_record_opt_set_free(record->vifs);
209 xen_vbd_record_opt_set_free(record->vbds);
210 xen_vtpm_record_opt_set_free(record->vtpms);
211 free(record->bios_boot);
212 free(record->platform_serial);
213 free(record->builder);
214 free(record->kernel_kernel);
215 free(record->kernel_initrd);
216 free(record->kernel_args);
217 free(record->grub_cmdline);
218 free(record->pci_bus);
219 xen_string_string_map_free(record->tools_version);
220 xen_string_string_map_free(record->otherconfig);
221 free(record);
222 }
225 bool
226 xen_vm_get_record(xen_session *session, xen_vm_record **result, xen_vm vm)
227 {
228 abstract_value param_values[] =
229 {
230 { .type = &abstract_type_string,
231 .u.string_val = vm }
232 };
234 abstract_type result_type = xen_vm_record_abstract_type_;
236 *result = NULL;
237 XEN_CALL_("VM.get_record");
239 if (session->ok)
240 {
241 (*result)->handle = xen_strdup_((*result)->uuid);
242 }
244 return session->ok;
245 }
248 bool
249 xen_vm_get_by_uuid(xen_session *session, xen_vm *result, char *uuid)
250 {
251 abstract_value param_values[] =
252 {
253 { .type = &abstract_type_string,
254 .u.string_val = uuid }
255 };
257 abstract_type result_type = abstract_type_string;
259 *result = NULL;
260 XEN_CALL_("VM.get_by_uuid");
261 return session->ok;
262 }
265 bool
266 xen_vm_create(xen_session *session, xen_vm *result, xen_vm_record *record)
267 {
268 abstract_value param_values[] =
269 {
270 { .type = &xen_vm_record_abstract_type_,
271 .u.struct_val = record }
272 };
274 abstract_type result_type = abstract_type_string;
276 *result = NULL;
277 XEN_CALL_("VM.create");
278 return session->ok;
279 }
282 bool
283 xen_vm_get_by_name_label(xen_session *session, struct xen_vm_set **result, char *label)
284 {
285 abstract_value param_values[] =
286 {
287 { .type = &abstract_type_string,
288 .u.string_val = label }
289 };
291 abstract_type result_type = abstract_type_string_set;
293 *result = NULL;
294 XEN_CALL_("VM.get_by_name_label");
295 return session->ok;
296 }
299 bool
300 xen_vm_get_power_state(xen_session *session, enum xen_vm_power_state *result, xen_vm vm)
301 {
302 abstract_value param_values[] =
303 {
304 { .type = &abstract_type_string,
305 .u.string_val = vm }
306 };
308 abstract_type result_type = xen_vm_power_state_abstract_type_;
309 char *result_str = NULL;
310 XEN_CALL_("VM.get_power_state");
311 *result = xen_vm_power_state_from_string(session, result_str);
312 return session->ok;
313 }
316 bool
317 xen_vm_get_name_label(xen_session *session, char **result, xen_vm vm)
318 {
319 abstract_value param_values[] =
320 {
321 { .type = &abstract_type_string,
322 .u.string_val = vm }
323 };
325 abstract_type result_type = abstract_type_string;
327 *result = NULL;
328 XEN_CALL_("VM.get_name_label");
329 return session->ok;
330 }
333 bool
334 xen_vm_get_name_description(xen_session *session, char **result, xen_vm vm)
335 {
336 abstract_value param_values[] =
337 {
338 { .type = &abstract_type_string,
339 .u.string_val = vm }
340 };
342 abstract_type result_type = abstract_type_string;
344 *result = NULL;
345 XEN_CALL_("VM.get_name_description");
346 return session->ok;
347 }
350 bool
351 xen_vm_get_user_version(xen_session *session, int64_t *result, xen_vm vm)
352 {
353 abstract_value param_values[] =
354 {
355 { .type = &abstract_type_string,
356 .u.string_val = vm }
357 };
359 abstract_type result_type = abstract_type_int;
361 XEN_CALL_("VM.get_user_version");
362 return session->ok;
363 }
366 bool
367 xen_vm_get_is_a_template(xen_session *session, bool *result, xen_vm vm)
368 {
369 abstract_value param_values[] =
370 {
371 { .type = &abstract_type_string,
372 .u.string_val = vm }
373 };
375 abstract_type result_type = abstract_type_bool;
377 XEN_CALL_("VM.get_is_a_template");
378 return session->ok;
379 }
382 bool
383 xen_vm_get_resident_on(xen_session *session, xen_host *result, xen_vm vm)
384 {
385 abstract_value param_values[] =
386 {
387 { .type = &abstract_type_string,
388 .u.string_val = vm }
389 };
391 abstract_type result_type = abstract_type_string;
393 *result = NULL;
394 XEN_CALL_("VM.get_resident_on");
395 return session->ok;
396 }
399 bool
400 xen_vm_get_memory_static_max(xen_session *session, int64_t *result, xen_vm vm)
401 {
402 abstract_value param_values[] =
403 {
404 { .type = &abstract_type_string,
405 .u.string_val = vm }
406 };
408 abstract_type result_type = abstract_type_int;
410 XEN_CALL_("VM.get_memory_static_max");
411 return session->ok;
412 }
415 bool
416 xen_vm_get_memory_dynamic_max(xen_session *session, int64_t *result, xen_vm vm)
417 {
418 abstract_value param_values[] =
419 {
420 { .type = &abstract_type_string,
421 .u.string_val = vm }
422 };
424 abstract_type result_type = abstract_type_int;
426 XEN_CALL_("VM.get_memory_dynamic_max");
427 return session->ok;
428 }
431 bool
432 xen_vm_get_memory_actual(xen_session *session, int64_t *result, xen_vm vm)
433 {
434 abstract_value param_values[] =
435 {
436 { .type = &abstract_type_string,
437 .u.string_val = vm }
438 };
440 abstract_type result_type = abstract_type_int;
442 XEN_CALL_("VM.get_memory_actual");
443 return session->ok;
444 }
447 bool
448 xen_vm_get_memory_dynamic_min(xen_session *session, int64_t *result, xen_vm vm)
449 {
450 abstract_value param_values[] =
451 {
452 { .type = &abstract_type_string,
453 .u.string_val = vm }
454 };
456 abstract_type result_type = abstract_type_int;
458 XEN_CALL_("VM.get_memory_dynamic_min");
459 return session->ok;
460 }
463 bool
464 xen_vm_get_memory_static_min(xen_session *session, int64_t *result, xen_vm vm)
465 {
466 abstract_value param_values[] =
467 {
468 { .type = &abstract_type_string,
469 .u.string_val = vm }
470 };
472 abstract_type result_type = abstract_type_int;
474 XEN_CALL_("VM.get_memory_static_min");
475 return session->ok;
476 }
479 bool
480 xen_vm_get_vcpus_policy(xen_session *session, char **result, xen_vm vm)
481 {
482 abstract_value param_values[] =
483 {
484 { .type = &abstract_type_string,
485 .u.string_val = vm }
486 };
488 abstract_type result_type = abstract_type_string;
490 *result = NULL;
491 XEN_CALL_("VM.get_vcpus_policy");
492 return session->ok;
493 }
496 bool
497 xen_vm_get_vcpus_params(xen_session *session, char **result, xen_vm vm)
498 {
499 abstract_value param_values[] =
500 {
501 { .type = &abstract_type_string,
502 .u.string_val = vm }
503 };
505 abstract_type result_type = abstract_type_string;
507 *result = NULL;
508 XEN_CALL_("VM.get_vcpus_params");
509 return session->ok;
510 }
513 bool
514 xen_vm_get_vcpus_number(xen_session *session, int64_t *result, xen_vm vm)
515 {
516 abstract_value param_values[] =
517 {
518 { .type = &abstract_type_string,
519 .u.string_val = vm }
520 };
522 abstract_type result_type = abstract_type_int;
524 XEN_CALL_("VM.get_vcpus_number");
525 return session->ok;
526 }
529 bool
530 xen_vm_get_vcpus_utilisation(xen_session *session, xen_int_float_map **result, xen_vm vm)
531 {
532 abstract_value param_values[] =
533 {
534 { .type = &abstract_type_string,
535 .u.string_val = vm }
536 };
538 abstract_type result_type = abstract_type_int_float_map;
540 *result = NULL;
541 XEN_CALL_("VM.get_vcpus_utilisation");
542 return session->ok;
543 }
546 bool
547 xen_vm_get_vcpus_features_required(xen_session *session, struct xen_cpu_feature_set **result, xen_vm vm)
548 {
549 abstract_value param_values[] =
550 {
551 { .type = &abstract_type_string,
552 .u.string_val = vm }
553 };
555 abstract_type result_type = xen_cpu_feature_set_abstract_type_;
557 *result = NULL;
558 XEN_CALL_("VM.get_vcpus_features_required");
559 return session->ok;
560 }
563 bool
564 xen_vm_get_vcpus_features_can_use(xen_session *session, struct xen_cpu_feature_set **result, xen_vm vm)
565 {
566 abstract_value param_values[] =
567 {
568 { .type = &abstract_type_string,
569 .u.string_val = vm }
570 };
572 abstract_type result_type = xen_cpu_feature_set_abstract_type_;
574 *result = NULL;
575 XEN_CALL_("VM.get_vcpus_features_can_use");
576 return session->ok;
577 }
580 bool
581 xen_vm_get_vcpus_features_force_on(xen_session *session, struct xen_cpu_feature_set **result, xen_vm vm)
582 {
583 abstract_value param_values[] =
584 {
585 { .type = &abstract_type_string,
586 .u.string_val = vm }
587 };
589 abstract_type result_type = xen_cpu_feature_set_abstract_type_;
591 *result = NULL;
592 XEN_CALL_("VM.get_vcpus_features_force_on");
593 return session->ok;
594 }
597 bool
598 xen_vm_get_vcpus_features_force_off(xen_session *session, struct xen_cpu_feature_set **result, xen_vm vm)
599 {
600 abstract_value param_values[] =
601 {
602 { .type = &abstract_type_string,
603 .u.string_val = vm }
604 };
606 abstract_type result_type = xen_cpu_feature_set_abstract_type_;
608 *result = NULL;
609 XEN_CALL_("VM.get_vcpus_features_force_off");
610 return session->ok;
611 }
614 bool
615 xen_vm_get_actions_after_shutdown(xen_session *session, enum xen_on_normal_exit *result, xen_vm vm)
616 {
617 abstract_value param_values[] =
618 {
619 { .type = &abstract_type_string,
620 .u.string_val = vm }
621 };
623 abstract_type result_type = xen_on_normal_exit_abstract_type_;
624 char *result_str = NULL;
625 XEN_CALL_("VM.get_actions_after_shutdown");
626 *result = xen_on_normal_exit_from_string(session, result_str);
627 return session->ok;
628 }
631 bool
632 xen_vm_get_actions_after_reboot(xen_session *session, enum xen_on_normal_exit *result, xen_vm vm)
633 {
634 abstract_value param_values[] =
635 {
636 { .type = &abstract_type_string,
637 .u.string_val = vm }
638 };
640 abstract_type result_type = xen_on_normal_exit_abstract_type_;
641 char *result_str = NULL;
642 XEN_CALL_("VM.get_actions_after_reboot");
643 *result = xen_on_normal_exit_from_string(session, result_str);
644 return session->ok;
645 }
648 bool
649 xen_vm_get_actions_after_suspend(xen_session *session, enum xen_on_normal_exit *result, xen_vm vm)
650 {
651 abstract_value param_values[] =
652 {
653 { .type = &abstract_type_string,
654 .u.string_val = vm }
655 };
657 abstract_type result_type = xen_on_normal_exit_abstract_type_;
658 char *result_str = NULL;
659 XEN_CALL_("VM.get_actions_after_suspend");
660 *result = xen_on_normal_exit_from_string(session, result_str);
661 return session->ok;
662 }
665 bool
666 xen_vm_get_actions_after_crash(xen_session *session, enum xen_on_crash_behaviour *result, xen_vm vm)
667 {
668 abstract_value param_values[] =
669 {
670 { .type = &abstract_type_string,
671 .u.string_val = vm }
672 };
674 abstract_type result_type = xen_on_crash_behaviour_abstract_type_;
675 char *result_str = NULL;
676 XEN_CALL_("VM.get_actions_after_crash");
677 *result = xen_on_crash_behaviour_from_string(session, result_str);
678 return session->ok;
679 }
682 bool
683 xen_vm_get_vifs(xen_session *session, struct xen_vif_set **result, xen_vm vm)
684 {
685 abstract_value param_values[] =
686 {
687 { .type = &abstract_type_string,
688 .u.string_val = vm }
689 };
691 abstract_type result_type = abstract_type_string_set;
693 *result = NULL;
694 XEN_CALL_("VM.get_vifs");
695 return session->ok;
696 }
699 bool
700 xen_vm_get_vbds(xen_session *session, struct xen_vbd_set **result, xen_vm vm)
701 {
702 abstract_value param_values[] =
703 {
704 { .type = &abstract_type_string,
705 .u.string_val = vm }
706 };
708 abstract_type result_type = abstract_type_string_set;
710 *result = NULL;
711 XEN_CALL_("VM.get_vbds");
712 return session->ok;
713 }
716 bool
717 xen_vm_get_vtpms(xen_session *session, struct xen_vtpm_set **result, xen_vm vm)
718 {
719 abstract_value param_values[] =
720 {
721 { .type = &abstract_type_string,
722 .u.string_val = vm }
723 };
725 abstract_type result_type = abstract_type_string_set;
727 *result = NULL;
728 XEN_CALL_("VM.get_vtpms");
729 return session->ok;
730 }
733 bool
734 xen_vm_get_bios_boot(xen_session *session, char **result, xen_vm vm)
735 {
736 abstract_value param_values[] =
737 {
738 { .type = &abstract_type_string,
739 .u.string_val = vm }
740 };
742 abstract_type result_type = abstract_type_string;
744 *result = NULL;
745 XEN_CALL_("VM.get_bios_boot");
746 return session->ok;
747 }
750 bool
751 xen_vm_get_platform_std_vga(xen_session *session, bool *result, xen_vm vm)
752 {
753 abstract_value param_values[] =
754 {
755 { .type = &abstract_type_string,
756 .u.string_val = vm }
757 };
759 abstract_type result_type = abstract_type_bool;
761 XEN_CALL_("VM.get_platform_std_vga");
762 return session->ok;
763 }
766 bool
767 xen_vm_get_platform_serial(xen_session *session, char **result, xen_vm vm)
768 {
769 abstract_value param_values[] =
770 {
771 { .type = &abstract_type_string,
772 .u.string_val = vm }
773 };
775 abstract_type result_type = abstract_type_string;
777 *result = NULL;
778 XEN_CALL_("VM.get_platform_serial");
779 return session->ok;
780 }
783 bool
784 xen_vm_get_platform_localtime(xen_session *session, bool *result, xen_vm vm)
785 {
786 abstract_value param_values[] =
787 {
788 { .type = &abstract_type_string,
789 .u.string_val = vm }
790 };
792 abstract_type result_type = abstract_type_bool;
794 XEN_CALL_("VM.get_platform_localtime");
795 return session->ok;
796 }
799 bool
800 xen_vm_get_platform_clock_offset(xen_session *session, bool *result, xen_vm vm)
801 {
802 abstract_value param_values[] =
803 {
804 { .type = &abstract_type_string,
805 .u.string_val = vm }
806 };
808 abstract_type result_type = abstract_type_bool;
810 XEN_CALL_("VM.get_platform_clock_offset");
811 return session->ok;
812 }
815 bool
816 xen_vm_get_platform_enable_audio(xen_session *session, bool *result, xen_vm vm)
817 {
818 abstract_value param_values[] =
819 {
820 { .type = &abstract_type_string,
821 .u.string_val = vm }
822 };
824 abstract_type result_type = abstract_type_bool;
826 XEN_CALL_("VM.get_platform_enable_audio");
827 return session->ok;
828 }
831 bool
832 xen_vm_get_builder(xen_session *session, char **result, xen_vm vm)
833 {
834 abstract_value param_values[] =
835 {
836 { .type = &abstract_type_string,
837 .u.string_val = vm }
838 };
840 abstract_type result_type = abstract_type_string;
842 *result = NULL;
843 XEN_CALL_("VM.get_builder");
844 return session->ok;
845 }
848 bool
849 xen_vm_get_boot_method(xen_session *session, enum xen_boot_type *result, xen_vm vm)
850 {
851 abstract_value param_values[] =
852 {
853 { .type = &abstract_type_string,
854 .u.string_val = vm }
855 };
857 abstract_type result_type = xen_boot_type_abstract_type_;
858 char *result_str = NULL;
859 XEN_CALL_("VM.get_boot_method");
860 *result = xen_boot_type_from_string(session, result_str);
861 return session->ok;
862 }
865 bool
866 xen_vm_get_kernel_kernel(xen_session *session, char **result, xen_vm vm)
867 {
868 abstract_value param_values[] =
869 {
870 { .type = &abstract_type_string,
871 .u.string_val = vm }
872 };
874 abstract_type result_type = abstract_type_string;
876 *result = NULL;
877 XEN_CALL_("VM.get_kernel_kernel");
878 return session->ok;
879 }
882 bool
883 xen_vm_get_kernel_initrd(xen_session *session, char **result, xen_vm vm)
884 {
885 abstract_value param_values[] =
886 {
887 { .type = &abstract_type_string,
888 .u.string_val = vm }
889 };
891 abstract_type result_type = abstract_type_string;
893 *result = NULL;
894 XEN_CALL_("VM.get_kernel_initrd");
895 return session->ok;
896 }
899 bool
900 xen_vm_get_kernel_args(xen_session *session, char **result, xen_vm vm)
901 {
902 abstract_value param_values[] =
903 {
904 { .type = &abstract_type_string,
905 .u.string_val = vm }
906 };
908 abstract_type result_type = abstract_type_string;
910 *result = NULL;
911 XEN_CALL_("VM.get_kernel_args");
912 return session->ok;
913 }
916 bool
917 xen_vm_get_grub_cmdline(xen_session *session, char **result, xen_vm vm)
918 {
919 abstract_value param_values[] =
920 {
921 { .type = &abstract_type_string,
922 .u.string_val = vm }
923 };
925 abstract_type result_type = abstract_type_string;
927 *result = NULL;
928 XEN_CALL_("VM.get_grub_cmdline");
929 return session->ok;
930 }
933 bool
934 xen_vm_get_pci_bus(xen_session *session, char **result, xen_vm vm)
935 {
936 abstract_value param_values[] =
937 {
938 { .type = &abstract_type_string,
939 .u.string_val = vm }
940 };
942 abstract_type result_type = abstract_type_string;
944 *result = NULL;
945 XEN_CALL_("VM.get_pci_bus");
946 return session->ok;
947 }
950 bool
951 xen_vm_get_tools_version(xen_session *session, xen_string_string_map **result, xen_vm vm)
952 {
953 abstract_value param_values[] =
954 {
955 { .type = &abstract_type_string,
956 .u.string_val = vm }
957 };
959 abstract_type result_type = abstract_type_string_string_map;
961 *result = NULL;
962 XEN_CALL_("VM.get_tools_version");
963 return session->ok;
964 }
967 bool
968 xen_vm_get_otherconfig(xen_session *session, xen_string_string_map **result, xen_vm vm)
969 {
970 abstract_value param_values[] =
971 {
972 { .type = &abstract_type_string,
973 .u.string_val = vm }
974 };
976 abstract_type result_type = abstract_type_string_string_map;
978 *result = NULL;
979 XEN_CALL_("VM.get_otherconfig");
980 return session->ok;
981 }
984 bool
985 xen_vm_set_name_label(xen_session *session, xen_vm xen_vm, char *label)
986 {
987 abstract_value param_values[] =
988 {
989 { .type = &abstract_type_string,
990 .u.string_val = xen_vm },
991 { .type = &abstract_type_string,
992 .u.string_val = label }
993 };
995 xen_call_(session, "VM.set_name_label", param_values, 2, NULL, NULL);
996 return session->ok;
997 }
1000 bool
1001 xen_vm_set_name_description(xen_session *session, xen_vm xen_vm, char *description)
1003 abstract_value param_values[] =
1005 { .type = &abstract_type_string,
1006 .u.string_val = xen_vm },
1007 { .type = &abstract_type_string,
1008 .u.string_val = description }
1009 };
1011 xen_call_(session, "VM.set_name_description", param_values, 2, NULL, NULL);
1012 return session->ok;
1016 bool
1017 xen_vm_set_user_version(xen_session *session, xen_vm xen_vm, int64_t user_version)
1019 abstract_value param_values[] =
1021 { .type = &abstract_type_string,
1022 .u.string_val = xen_vm },
1023 { .type = &abstract_type_int,
1024 .u.int_val = user_version }
1025 };
1027 xen_call_(session, "VM.set_user_version", param_values, 2, NULL, NULL);
1028 return session->ok;
1032 bool
1033 xen_vm_set_is_a_template(xen_session *session, xen_vm xen_vm, bool is_a_template)
1035 abstract_value param_values[] =
1037 { .type = &abstract_type_string,
1038 .u.string_val = xen_vm },
1039 { .type = &abstract_type_bool,
1040 .u.bool_val = is_a_template }
1041 };
1043 xen_call_(session, "VM.set_is_a_template", param_values, 2, NULL, NULL);
1044 return session->ok;
1048 bool
1049 xen_vm_set_memory_dynamic_max(xen_session *session, xen_vm xen_vm, int64_t dynamic_max)
1051 abstract_value param_values[] =
1053 { .type = &abstract_type_string,
1054 .u.string_val = xen_vm },
1055 { .type = &abstract_type_int,
1056 .u.int_val = dynamic_max }
1057 };
1059 xen_call_(session, "VM.set_memory_dynamic_max", param_values, 2, NULL, NULL);
1060 return session->ok;
1064 bool
1065 xen_vm_set_memory_dynamic_min(xen_session *session, xen_vm xen_vm, int64_t dynamic_min)
1067 abstract_value param_values[] =
1069 { .type = &abstract_type_string,
1070 .u.string_val = xen_vm },
1071 { .type = &abstract_type_int,
1072 .u.int_val = dynamic_min }
1073 };
1075 xen_call_(session, "VM.set_memory_dynamic_min", param_values, 2, NULL, NULL);
1076 return session->ok;
1080 bool
1081 xen_vm_set_vcpus_policy(xen_session *session, xen_vm xen_vm, char *policy)
1083 abstract_value param_values[] =
1085 { .type = &abstract_type_string,
1086 .u.string_val = xen_vm },
1087 { .type = &abstract_type_string,
1088 .u.string_val = policy }
1089 };
1091 xen_call_(session, "VM.set_vcpus_policy", param_values, 2, NULL, NULL);
1092 return session->ok;
1096 bool
1097 xen_vm_set_vcpus_params(xen_session *session, xen_vm xen_vm, char *params)
1099 abstract_value param_values[] =
1101 { .type = &abstract_type_string,
1102 .u.string_val = xen_vm },
1103 { .type = &abstract_type_string,
1104 .u.string_val = params }
1105 };
1107 xen_call_(session, "VM.set_vcpus_params", param_values, 2, NULL, NULL);
1108 return session->ok;
1112 bool
1113 xen_vm_set_vcpus_features_force_on(xen_session *session, xen_vm xen_vm, struct xen_cpu_feature_set *force_on)
1115 abstract_value param_values[] =
1117 { .type = &abstract_type_string,
1118 .u.string_val = xen_vm },
1119 { .type = &xen_cpu_feature_set_abstract_type_,
1120 .u.set_val = (arbitrary_set *)force_on }
1121 };
1123 xen_call_(session, "VM.set_vcpus_features_force_on", param_values, 2, NULL, NULL);
1124 return session->ok;
1128 bool
1129 xen_vm_set_vcpus_features_force_off(xen_session *session, xen_vm xen_vm, struct xen_cpu_feature_set *force_off)
1131 abstract_value param_values[] =
1133 { .type = &abstract_type_string,
1134 .u.string_val = xen_vm },
1135 { .type = &xen_cpu_feature_set_abstract_type_,
1136 .u.set_val = (arbitrary_set *)force_off }
1137 };
1139 xen_call_(session, "VM.set_vcpus_features_force_off", param_values, 2, NULL, NULL);
1140 return session->ok;
1144 bool
1145 xen_vm_set_actions_after_shutdown(xen_session *session, xen_vm xen_vm, enum xen_on_normal_exit after_shutdown)
1147 abstract_value param_values[] =
1149 { .type = &abstract_type_string,
1150 .u.string_val = xen_vm },
1151 { .type = &xen_on_normal_exit_abstract_type_,
1152 .u.string_val = xen_on_normal_exit_to_string(after_shutdown) }
1153 };
1155 xen_call_(session, "VM.set_actions_after_shutdown", param_values, 2, NULL, NULL);
1156 return session->ok;
1160 bool
1161 xen_vm_set_actions_after_reboot(xen_session *session, xen_vm xen_vm, enum xen_on_normal_exit after_reboot)
1163 abstract_value param_values[] =
1165 { .type = &abstract_type_string,
1166 .u.string_val = xen_vm },
1167 { .type = &xen_on_normal_exit_abstract_type_,
1168 .u.string_val = xen_on_normal_exit_to_string(after_reboot) }
1169 };
1171 xen_call_(session, "VM.set_actions_after_reboot", param_values, 2, NULL, NULL);
1172 return session->ok;
1176 bool
1177 xen_vm_set_actions_after_suspend(xen_session *session, xen_vm xen_vm, enum xen_on_normal_exit after_suspend)
1179 abstract_value param_values[] =
1181 { .type = &abstract_type_string,
1182 .u.string_val = xen_vm },
1183 { .type = &xen_on_normal_exit_abstract_type_,
1184 .u.string_val = xen_on_normal_exit_to_string(after_suspend) }
1185 };
1187 xen_call_(session, "VM.set_actions_after_suspend", param_values, 2, NULL, NULL);
1188 return session->ok;
1192 bool
1193 xen_vm_set_actions_after_crash(xen_session *session, xen_vm xen_vm, enum xen_on_crash_behaviour after_crash)
1195 abstract_value param_values[] =
1197 { .type = &abstract_type_string,
1198 .u.string_val = xen_vm },
1199 { .type = &xen_on_crash_behaviour_abstract_type_,
1200 .u.string_val = xen_on_crash_behaviour_to_string(after_crash) }
1201 };
1203 xen_call_(session, "VM.set_actions_after_crash", param_values, 2, NULL, NULL);
1204 return session->ok;
1208 bool
1209 xen_vm_set_bios_boot(xen_session *session, xen_vm xen_vm, char *boot)
1211 abstract_value param_values[] =
1213 { .type = &abstract_type_string,
1214 .u.string_val = xen_vm },
1215 { .type = &abstract_type_string,
1216 .u.string_val = boot }
1217 };
1219 xen_call_(session, "VM.set_bios_boot", param_values, 2, NULL, NULL);
1220 return session->ok;
1224 bool
1225 xen_vm_set_platform_std_vga(xen_session *session, xen_vm xen_vm, bool std_vga)
1227 abstract_value param_values[] =
1229 { .type = &abstract_type_string,
1230 .u.string_val = xen_vm },
1231 { .type = &abstract_type_bool,
1232 .u.bool_val = std_vga }
1233 };
1235 xen_call_(session, "VM.set_platform_std_vga", param_values, 2, NULL, NULL);
1236 return session->ok;
1240 bool
1241 xen_vm_set_platform_serial(xen_session *session, xen_vm xen_vm, char *serial)
1243 abstract_value param_values[] =
1245 { .type = &abstract_type_string,
1246 .u.string_val = xen_vm },
1247 { .type = &abstract_type_string,
1248 .u.string_val = serial }
1249 };
1251 xen_call_(session, "VM.set_platform_serial", param_values, 2, NULL, NULL);
1252 return session->ok;
1256 bool
1257 xen_vm_set_platform_localtime(xen_session *session, xen_vm xen_vm, bool localtime)
1259 abstract_value param_values[] =
1261 { .type = &abstract_type_string,
1262 .u.string_val = xen_vm },
1263 { .type = &abstract_type_bool,
1264 .u.bool_val = localtime }
1265 };
1267 xen_call_(session, "VM.set_platform_localtime", param_values, 2, NULL, NULL);
1268 return session->ok;
1272 bool
1273 xen_vm_set_platform_clock_offset(xen_session *session, xen_vm xen_vm, bool clock_offset)
1275 abstract_value param_values[] =
1277 { .type = &abstract_type_string,
1278 .u.string_val = xen_vm },
1279 { .type = &abstract_type_bool,
1280 .u.bool_val = clock_offset }
1281 };
1283 xen_call_(session, "VM.set_platform_clock_offset", param_values, 2, NULL, NULL);
1284 return session->ok;
1288 bool
1289 xen_vm_set_platform_enable_audio(xen_session *session, xen_vm xen_vm, bool enable_audio)
1291 abstract_value param_values[] =
1293 { .type = &abstract_type_string,
1294 .u.string_val = xen_vm },
1295 { .type = &abstract_type_bool,
1296 .u.bool_val = enable_audio }
1297 };
1299 xen_call_(session, "VM.set_platform_enable_audio", param_values, 2, NULL, NULL);
1300 return session->ok;
1304 bool
1305 xen_vm_set_builder(xen_session *session, xen_vm xen_vm, char *builder)
1307 abstract_value param_values[] =
1309 { .type = &abstract_type_string,
1310 .u.string_val = xen_vm },
1311 { .type = &abstract_type_string,
1312 .u.string_val = builder }
1313 };
1315 xen_call_(session, "VM.set_builder", param_values, 2, NULL, NULL);
1316 return session->ok;
1320 bool
1321 xen_vm_set_boot_method(xen_session *session, xen_vm xen_vm, enum xen_boot_type boot_method)
1323 abstract_value param_values[] =
1325 { .type = &abstract_type_string,
1326 .u.string_val = xen_vm },
1327 { .type = &xen_boot_type_abstract_type_,
1328 .u.string_val = xen_boot_type_to_string(boot_method) }
1329 };
1331 xen_call_(session, "VM.set_boot_method", param_values, 2, NULL, NULL);
1332 return session->ok;
1336 bool
1337 xen_vm_set_kernel_kernel(xen_session *session, xen_vm xen_vm, char *kernel)
1339 abstract_value param_values[] =
1341 { .type = &abstract_type_string,
1342 .u.string_val = xen_vm },
1343 { .type = &abstract_type_string,
1344 .u.string_val = kernel }
1345 };
1347 xen_call_(session, "VM.set_kernel_kernel", param_values, 2, NULL, NULL);
1348 return session->ok;
1352 bool
1353 xen_vm_set_kernel_initrd(xen_session *session, xen_vm xen_vm, char *initrd)
1355 abstract_value param_values[] =
1357 { .type = &abstract_type_string,
1358 .u.string_val = xen_vm },
1359 { .type = &abstract_type_string,
1360 .u.string_val = initrd }
1361 };
1363 xen_call_(session, "VM.set_kernel_initrd", param_values, 2, NULL, NULL);
1364 return session->ok;
1368 bool
1369 xen_vm_set_kernel_args(xen_session *session, xen_vm xen_vm, char *args)
1371 abstract_value param_values[] =
1373 { .type = &abstract_type_string,
1374 .u.string_val = xen_vm },
1375 { .type = &abstract_type_string,
1376 .u.string_val = args }
1377 };
1379 xen_call_(session, "VM.set_kernel_args", param_values, 2, NULL, NULL);
1380 return session->ok;
1384 bool
1385 xen_vm_set_grub_cmdline(xen_session *session, xen_vm xen_vm, char *cmdline)
1387 abstract_value param_values[] =
1389 { .type = &abstract_type_string,
1390 .u.string_val = xen_vm },
1391 { .type = &abstract_type_string,
1392 .u.string_val = cmdline }
1393 };
1395 xen_call_(session, "VM.set_grub_cmdline", param_values, 2, NULL, NULL);
1396 return session->ok;
1400 bool
1401 xen_vm_set_otherconfig(xen_session *session, xen_vm xen_vm, xen_string_string_map *otherconfig)
1403 abstract_value param_values[] =
1405 { .type = &abstract_type_string,
1406 .u.string_val = xen_vm },
1407 { .type = &abstract_type_string_string_map,
1408 .u.set_val = (arbitrary_set *)otherconfig }
1409 };
1411 xen_call_(session, "VM.set_otherconfig", param_values, 2, NULL, NULL);
1412 return session->ok;
1416 bool
1417 xen_vm_clone(xen_session *session, xen_vm *result, xen_vm vm, char *new_name)
1419 abstract_value param_values[] =
1421 { .type = &abstract_type_string,
1422 .u.string_val = vm },
1423 { .type = &abstract_type_string,
1424 .u.string_val = new_name }
1425 };
1427 abstract_type result_type = abstract_type_string;
1429 *result = NULL;
1430 XEN_CALL_("VM.clone");
1431 return session->ok;
1435 bool
1436 xen_vm_start(xen_session *session, xen_vm vm, bool start_paused)
1438 abstract_value param_values[] =
1440 { .type = &abstract_type_string,
1441 .u.string_val = vm },
1442 { .type = &abstract_type_bool,
1443 .u.bool_val = start_paused }
1444 };
1446 xen_call_(session, "VM.start", param_values, 2, NULL, NULL);
1447 return session->ok;
1451 bool
1452 xen_vm_pause(xen_session *session, xen_vm vm)
1454 abstract_value param_values[] =
1456 { .type = &abstract_type_string,
1457 .u.string_val = vm }
1458 };
1460 xen_call_(session, "VM.pause", param_values, 1, NULL, NULL);
1461 return session->ok;
1465 bool
1466 xen_vm_unpause(xen_session *session, xen_vm vm)
1468 abstract_value param_values[] =
1470 { .type = &abstract_type_string,
1471 .u.string_val = vm }
1472 };
1474 xen_call_(session, "VM.unpause", param_values, 1, NULL, NULL);
1475 return session->ok;
1479 bool
1480 xen_vm_clean_shutdown(xen_session *session, xen_vm vm)
1482 abstract_value param_values[] =
1484 { .type = &abstract_type_string,
1485 .u.string_val = vm }
1486 };
1488 xen_call_(session, "VM.clean_shutdown", param_values, 1, NULL, NULL);
1489 return session->ok;
1493 bool
1494 xen_vm_clean_reboot(xen_session *session, xen_vm vm)
1496 abstract_value param_values[] =
1498 { .type = &abstract_type_string,
1499 .u.string_val = vm }
1500 };
1502 xen_call_(session, "VM.clean_reboot", param_values, 1, NULL, NULL);
1503 return session->ok;
1507 bool
1508 xen_vm_hard_shutdown(xen_session *session, xen_vm vm)
1510 abstract_value param_values[] =
1512 { .type = &abstract_type_string,
1513 .u.string_val = vm }
1514 };
1516 xen_call_(session, "VM.hard_shutdown", param_values, 1, NULL, NULL);
1517 return session->ok;
1521 bool
1522 xen_vm_hard_reboot(xen_session *session, xen_vm vm)
1524 abstract_value param_values[] =
1526 { .type = &abstract_type_string,
1527 .u.string_val = vm }
1528 };
1530 xen_call_(session, "VM.hard_reboot", param_values, 1, NULL, NULL);
1531 return session->ok;
1535 bool
1536 xen_vm_suspend(xen_session *session, xen_vm vm)
1538 abstract_value param_values[] =
1540 { .type = &abstract_type_string,
1541 .u.string_val = vm }
1542 };
1544 xen_call_(session, "VM.suspend", param_values, 1, NULL, NULL);
1545 return session->ok;
1549 bool
1550 xen_vm_resume(xen_session *session, xen_vm vm, bool start_paused)
1552 abstract_value param_values[] =
1554 { .type = &abstract_type_string,
1555 .u.string_val = vm },
1556 { .type = &abstract_type_bool,
1557 .u.bool_val = start_paused }
1558 };
1560 xen_call_(session, "VM.resume", param_values, 2, NULL, NULL);
1561 return session->ok;
1565 bool
1566 xen_vm_get_all(xen_session *session, struct xen_vm_set **result)
1569 abstract_type result_type = abstract_type_string_set;
1571 *result = NULL;
1572 xen_call_(session, "VM.get_all", NULL, 0, &result_type, result);
1573 return session->ok;
1577 bool
1578 xen_vm_get_uuid(xen_session *session, char **result, xen_vm vm)
1580 *result = session->ok ? xen_strdup_((char *)vm) : NULL;
1581 return session->ok;
1585 bool
1586 xen_vm_destroy(xen_session *session, xen_vm vm)
1588 abstract_value param_values[] =
1590 { .type = &abstract_type_string,
1591 .u.string_val = vm }
1592 };
1594 xen_call_(session, "VM.destroy", param_values, 1, NULL, NULL);
1595 return session->ok;