ia64/xen-unstable

view tools/libxen/src/xen_vm.c @ 12784:4e3a7d82917c

More capitalisation fixes.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Mon Dec 04 10:24:54 2006 +0000 (2006-12-04)
parents 5e9812e53300
children 737c1c11497d
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_console.h"
26 #include "xen_cpu_feature.h"
27 #include "xen_cpu_feature_internal.h"
28 #include "xen_host.h"
29 #include "xen_int_float_map.h"
30 #include "xen_internal.h"
31 #include "xen_on_crash_behaviour_internal.h"
32 #include "xen_on_normal_exit_internal.h"
33 #include "xen_string_string_map.h"
34 #include "xen_vbd.h"
35 #include "xen_vif.h"
36 #include "xen_vm.h"
37 #include "xen_vm_power_state_internal.h"
38 #include "xen_vtpm.h"
41 XEN_FREE(xen_vm)
42 XEN_SET_ALLOC_FREE(xen_vm)
43 XEN_ALLOC(xen_vm_record)
44 XEN_SET_ALLOC_FREE(xen_vm_record)
45 XEN_ALLOC(xen_vm_record_opt)
46 XEN_RECORD_OPT_FREE(xen_vm)
47 XEN_SET_ALLOC_FREE(xen_vm_record_opt)
50 static const struct_member xen_vm_record_struct_members[] =
51 {
52 { .key = "uuid",
53 .type = &abstract_type_string,
54 .offset = offsetof(xen_vm_record, uuid) },
55 { .key = "power_state",
56 .type = &xen_vm_power_state_abstract_type_,
57 .offset = offsetof(xen_vm_record, power_state) },
58 { .key = "name_label",
59 .type = &abstract_type_string,
60 .offset = offsetof(xen_vm_record, name_label) },
61 { .key = "name_description",
62 .type = &abstract_type_string,
63 .offset = offsetof(xen_vm_record, name_description) },
64 { .key = "user_version",
65 .type = &abstract_type_int,
66 .offset = offsetof(xen_vm_record, user_version) },
67 { .key = "is_a_template",
68 .type = &abstract_type_bool,
69 .offset = offsetof(xen_vm_record, is_a_template) },
70 { .key = "resident_on",
71 .type = &abstract_type_ref,
72 .offset = offsetof(xen_vm_record, resident_on) },
73 { .key = "memory_static_max",
74 .type = &abstract_type_int,
75 .offset = offsetof(xen_vm_record, memory_static_max) },
76 { .key = "memory_dynamic_max",
77 .type = &abstract_type_int,
78 .offset = offsetof(xen_vm_record, memory_dynamic_max) },
79 { .key = "memory_actual",
80 .type = &abstract_type_int,
81 .offset = offsetof(xen_vm_record, memory_actual) },
82 { .key = "memory_dynamic_min",
83 .type = &abstract_type_int,
84 .offset = offsetof(xen_vm_record, memory_dynamic_min) },
85 { .key = "memory_static_min",
86 .type = &abstract_type_int,
87 .offset = offsetof(xen_vm_record, memory_static_min) },
88 { .key = "VCPUs_policy",
89 .type = &abstract_type_string,
90 .offset = offsetof(xen_vm_record, vcpus_policy) },
91 { .key = "VCPUs_params",
92 .type = &abstract_type_string,
93 .offset = offsetof(xen_vm_record, vcpus_params) },
94 { .key = "VCPUs_number",
95 .type = &abstract_type_int,
96 .offset = offsetof(xen_vm_record, vcpus_number) },
97 { .key = "VCPUs_utilisation",
98 .type = &abstract_type_int_float_map,
99 .offset = offsetof(xen_vm_record, vcpus_utilisation) },
100 { .key = "VCPUs_features_required",
101 .type = &xen_cpu_feature_set_abstract_type_,
102 .offset = offsetof(xen_vm_record, vcpus_features_required) },
103 { .key = "VCPUs_features_can_use",
104 .type = &xen_cpu_feature_set_abstract_type_,
105 .offset = offsetof(xen_vm_record, vcpus_features_can_use) },
106 { .key = "VCPUs_features_force_on",
107 .type = &xen_cpu_feature_set_abstract_type_,
108 .offset = offsetof(xen_vm_record, vcpus_features_force_on) },
109 { .key = "VCPUs_features_force_off",
110 .type = &xen_cpu_feature_set_abstract_type_,
111 .offset = offsetof(xen_vm_record, vcpus_features_force_off) },
112 { .key = "actions_after_shutdown",
113 .type = &xen_on_normal_exit_abstract_type_,
114 .offset = offsetof(xen_vm_record, actions_after_shutdown) },
115 { .key = "actions_after_reboot",
116 .type = &xen_on_normal_exit_abstract_type_,
117 .offset = offsetof(xen_vm_record, actions_after_reboot) },
118 { .key = "actions_after_suspend",
119 .type = &xen_on_normal_exit_abstract_type_,
120 .offset = offsetof(xen_vm_record, actions_after_suspend) },
121 { .key = "actions_after_crash",
122 .type = &xen_on_crash_behaviour_abstract_type_,
123 .offset = offsetof(xen_vm_record, actions_after_crash) },
124 { .key = "consoles",
125 .type = &abstract_type_ref_set,
126 .offset = offsetof(xen_vm_record, consoles) },
127 { .key = "VIFs",
128 .type = &abstract_type_ref_set,
129 .offset = offsetof(xen_vm_record, vifs) },
130 { .key = "VBDs",
131 .type = &abstract_type_ref_set,
132 .offset = offsetof(xen_vm_record, vbds) },
133 { .key = "VTPMs",
134 .type = &abstract_type_ref_set,
135 .offset = offsetof(xen_vm_record, vtpms) },
136 { .key = "bios_boot",
137 .type = &abstract_type_string,
138 .offset = offsetof(xen_vm_record, bios_boot) },
139 { .key = "platform_std_VGA",
140 .type = &abstract_type_bool,
141 .offset = offsetof(xen_vm_record, platform_std_vga) },
142 { .key = "platform_serial",
143 .type = &abstract_type_string,
144 .offset = offsetof(xen_vm_record, platform_serial) },
145 { .key = "platform_localtime",
146 .type = &abstract_type_bool,
147 .offset = offsetof(xen_vm_record, platform_localtime) },
148 { .key = "platform_clock_offset",
149 .type = &abstract_type_bool,
150 .offset = offsetof(xen_vm_record, platform_clock_offset) },
151 { .key = "platform_enable_audio",
152 .type = &abstract_type_bool,
153 .offset = offsetof(xen_vm_record, platform_enable_audio) },
154 { .key = "builder",
155 .type = &abstract_type_string,
156 .offset = offsetof(xen_vm_record, builder) },
157 { .key = "boot_method",
158 .type = &xen_boot_type_abstract_type_,
159 .offset = offsetof(xen_vm_record, boot_method) },
160 { .key = "kernel_kernel",
161 .type = &abstract_type_string,
162 .offset = offsetof(xen_vm_record, kernel_kernel) },
163 { .key = "kernel_initrd",
164 .type = &abstract_type_string,
165 .offset = offsetof(xen_vm_record, kernel_initrd) },
166 { .key = "kernel_args",
167 .type = &abstract_type_string,
168 .offset = offsetof(xen_vm_record, kernel_args) },
169 { .key = "grub_cmdline",
170 .type = &abstract_type_string,
171 .offset = offsetof(xen_vm_record, grub_cmdline) },
172 { .key = "PCI_bus",
173 .type = &abstract_type_string,
174 .offset = offsetof(xen_vm_record, pci_bus) },
175 { .key = "tools_version",
176 .type = &abstract_type_string_string_map,
177 .offset = offsetof(xen_vm_record, tools_version) },
178 { .key = "otherConfig",
179 .type = &abstract_type_string_string_map,
180 .offset = offsetof(xen_vm_record, otherconfig) }
181 };
183 const abstract_type xen_vm_record_abstract_type_ =
184 {
185 .typename = STRUCT,
186 .struct_size = sizeof(xen_vm_record),
187 .member_count =
188 sizeof(xen_vm_record_struct_members) / sizeof(struct_member),
189 .members = xen_vm_record_struct_members
190 };
193 void
194 xen_vm_record_free(xen_vm_record *record)
195 {
196 if (record == NULL)
197 {
198 return;
199 }
200 free(record->handle);
201 free(record->uuid);
202 free(record->name_label);
203 free(record->name_description);
204 xen_host_record_opt_free(record->resident_on);
205 free(record->vcpus_policy);
206 free(record->vcpus_params);
207 xen_int_float_map_free(record->vcpus_utilisation);
208 xen_cpu_feature_set_free(record->vcpus_features_required);
209 xen_cpu_feature_set_free(record->vcpus_features_can_use);
210 xen_cpu_feature_set_free(record->vcpus_features_force_on);
211 xen_cpu_feature_set_free(record->vcpus_features_force_off);
212 xen_console_record_opt_set_free(record->consoles);
213 xen_vif_record_opt_set_free(record->vifs);
214 xen_vbd_record_opt_set_free(record->vbds);
215 xen_vtpm_record_opt_set_free(record->vtpms);
216 free(record->bios_boot);
217 free(record->platform_serial);
218 free(record->builder);
219 free(record->kernel_kernel);
220 free(record->kernel_initrd);
221 free(record->kernel_args);
222 free(record->grub_cmdline);
223 free(record->pci_bus);
224 xen_string_string_map_free(record->tools_version);
225 xen_string_string_map_free(record->otherconfig);
226 free(record);
227 }
230 bool
231 xen_vm_get_record(xen_session *session, xen_vm_record **result, xen_vm vm)
232 {
233 abstract_value param_values[] =
234 {
235 { .type = &abstract_type_string,
236 .u.string_val = vm }
237 };
239 abstract_type result_type = xen_vm_record_abstract_type_;
241 *result = NULL;
242 XEN_CALL_("VM.get_record");
244 if (session->ok)
245 {
246 (*result)->handle = xen_strdup_((*result)->uuid);
247 }
249 return session->ok;
250 }
253 bool
254 xen_vm_get_by_uuid(xen_session *session, xen_vm *result, char *uuid)
255 {
256 abstract_value param_values[] =
257 {
258 { .type = &abstract_type_string,
259 .u.string_val = uuid }
260 };
262 abstract_type result_type = abstract_type_string;
264 *result = NULL;
265 XEN_CALL_("VM.get_by_uuid");
266 return session->ok;
267 }
270 bool
271 xen_vm_create(xen_session *session, xen_vm *result, xen_vm_record *record)
272 {
273 abstract_value param_values[] =
274 {
275 { .type = &xen_vm_record_abstract_type_,
276 .u.struct_val = record }
277 };
279 abstract_type result_type = abstract_type_string;
281 *result = NULL;
282 XEN_CALL_("VM.create");
283 return session->ok;
284 }
287 bool
288 xen_vm_destroy(xen_session *session, xen_vm vm)
289 {
290 abstract_value param_values[] =
291 {
292 { .type = &abstract_type_string,
293 .u.string_val = vm }
294 };
296 xen_call_(session, "VM.destroy", param_values, 1, NULL, NULL);
297 return session->ok;
298 }
301 bool
302 xen_vm_get_by_name_label(xen_session *session, struct xen_vm_set **result, char *label)
303 {
304 abstract_value param_values[] =
305 {
306 { .type = &abstract_type_string,
307 .u.string_val = label }
308 };
310 abstract_type result_type = abstract_type_string_set;
312 *result = NULL;
313 XEN_CALL_("VM.get_by_name_label");
314 return session->ok;
315 }
318 bool
319 xen_vm_get_power_state(xen_session *session, enum xen_vm_power_state *result, xen_vm vm)
320 {
321 abstract_value param_values[] =
322 {
323 { .type = &abstract_type_string,
324 .u.string_val = vm }
325 };
327 abstract_type result_type = xen_vm_power_state_abstract_type_;
328 char *result_str = NULL;
329 XEN_CALL_("VM.get_power_state");
330 *result = xen_vm_power_state_from_string(session, result_str);
331 return session->ok;
332 }
335 bool
336 xen_vm_get_name_label(xen_session *session, char **result, xen_vm vm)
337 {
338 abstract_value param_values[] =
339 {
340 { .type = &abstract_type_string,
341 .u.string_val = vm }
342 };
344 abstract_type result_type = abstract_type_string;
346 *result = NULL;
347 XEN_CALL_("VM.get_name_label");
348 return session->ok;
349 }
352 bool
353 xen_vm_get_name_description(xen_session *session, char **result, xen_vm vm)
354 {
355 abstract_value param_values[] =
356 {
357 { .type = &abstract_type_string,
358 .u.string_val = vm }
359 };
361 abstract_type result_type = abstract_type_string;
363 *result = NULL;
364 XEN_CALL_("VM.get_name_description");
365 return session->ok;
366 }
369 bool
370 xen_vm_get_user_version(xen_session *session, int64_t *result, xen_vm vm)
371 {
372 abstract_value param_values[] =
373 {
374 { .type = &abstract_type_string,
375 .u.string_val = vm }
376 };
378 abstract_type result_type = abstract_type_int;
380 XEN_CALL_("VM.get_user_version");
381 return session->ok;
382 }
385 bool
386 xen_vm_get_is_a_template(xen_session *session, bool *result, xen_vm vm)
387 {
388 abstract_value param_values[] =
389 {
390 { .type = &abstract_type_string,
391 .u.string_val = vm }
392 };
394 abstract_type result_type = abstract_type_bool;
396 XEN_CALL_("VM.get_is_a_template");
397 return session->ok;
398 }
401 bool
402 xen_vm_get_resident_on(xen_session *session, xen_host *result, xen_vm vm)
403 {
404 abstract_value param_values[] =
405 {
406 { .type = &abstract_type_string,
407 .u.string_val = vm }
408 };
410 abstract_type result_type = abstract_type_string;
412 *result = NULL;
413 XEN_CALL_("VM.get_resident_on");
414 return session->ok;
415 }
418 bool
419 xen_vm_get_memory_static_max(xen_session *session, int64_t *result, xen_vm vm)
420 {
421 abstract_value param_values[] =
422 {
423 { .type = &abstract_type_string,
424 .u.string_val = vm }
425 };
427 abstract_type result_type = abstract_type_int;
429 XEN_CALL_("VM.get_memory_static_max");
430 return session->ok;
431 }
434 bool
435 xen_vm_get_memory_dynamic_max(xen_session *session, int64_t *result, xen_vm vm)
436 {
437 abstract_value param_values[] =
438 {
439 { .type = &abstract_type_string,
440 .u.string_val = vm }
441 };
443 abstract_type result_type = abstract_type_int;
445 XEN_CALL_("VM.get_memory_dynamic_max");
446 return session->ok;
447 }
450 bool
451 xen_vm_get_memory_actual(xen_session *session, int64_t *result, xen_vm vm)
452 {
453 abstract_value param_values[] =
454 {
455 { .type = &abstract_type_string,
456 .u.string_val = vm }
457 };
459 abstract_type result_type = abstract_type_int;
461 XEN_CALL_("VM.get_memory_actual");
462 return session->ok;
463 }
466 bool
467 xen_vm_get_memory_dynamic_min(xen_session *session, int64_t *result, xen_vm vm)
468 {
469 abstract_value param_values[] =
470 {
471 { .type = &abstract_type_string,
472 .u.string_val = vm }
473 };
475 abstract_type result_type = abstract_type_int;
477 XEN_CALL_("VM.get_memory_dynamic_min");
478 return session->ok;
479 }
482 bool
483 xen_vm_get_memory_static_min(xen_session *session, int64_t *result, xen_vm vm)
484 {
485 abstract_value param_values[] =
486 {
487 { .type = &abstract_type_string,
488 .u.string_val = vm }
489 };
491 abstract_type result_type = abstract_type_int;
493 XEN_CALL_("VM.get_memory_static_min");
494 return session->ok;
495 }
498 bool
499 xen_vm_get_vcpus_policy(xen_session *session, char **result, xen_vm vm)
500 {
501 abstract_value param_values[] =
502 {
503 { .type = &abstract_type_string,
504 .u.string_val = vm }
505 };
507 abstract_type result_type = abstract_type_string;
509 *result = NULL;
510 XEN_CALL_("VM.get_VCPUs_policy");
511 return session->ok;
512 }
515 bool
516 xen_vm_get_vcpus_params(xen_session *session, char **result, xen_vm vm)
517 {
518 abstract_value param_values[] =
519 {
520 { .type = &abstract_type_string,
521 .u.string_val = vm }
522 };
524 abstract_type result_type = abstract_type_string;
526 *result = NULL;
527 XEN_CALL_("VM.get_VCPUs_params");
528 return session->ok;
529 }
532 bool
533 xen_vm_get_vcpus_number(xen_session *session, int64_t *result, xen_vm vm)
534 {
535 abstract_value param_values[] =
536 {
537 { .type = &abstract_type_string,
538 .u.string_val = vm }
539 };
541 abstract_type result_type = abstract_type_int;
543 XEN_CALL_("VM.get_VCPUs_number");
544 return session->ok;
545 }
548 bool
549 xen_vm_get_vcpus_utilisation(xen_session *session, xen_int_float_map **result, xen_vm vm)
550 {
551 abstract_value param_values[] =
552 {
553 { .type = &abstract_type_string,
554 .u.string_val = vm }
555 };
557 abstract_type result_type = abstract_type_int_float_map;
559 *result = NULL;
560 XEN_CALL_("VM.get_VCPUs_utilisation");
561 return session->ok;
562 }
565 bool
566 xen_vm_get_vcpus_features_required(xen_session *session, struct xen_cpu_feature_set **result, xen_vm vm)
567 {
568 abstract_value param_values[] =
569 {
570 { .type = &abstract_type_string,
571 .u.string_val = vm }
572 };
574 abstract_type result_type = xen_cpu_feature_set_abstract_type_;
576 *result = NULL;
577 XEN_CALL_("VM.get_VCPUs_features_required");
578 return session->ok;
579 }
582 bool
583 xen_vm_get_vcpus_features_can_use(xen_session *session, struct xen_cpu_feature_set **result, xen_vm vm)
584 {
585 abstract_value param_values[] =
586 {
587 { .type = &abstract_type_string,
588 .u.string_val = vm }
589 };
591 abstract_type result_type = xen_cpu_feature_set_abstract_type_;
593 *result = NULL;
594 XEN_CALL_("VM.get_VCPUs_features_can_use");
595 return session->ok;
596 }
599 bool
600 xen_vm_get_vcpus_features_force_on(xen_session *session, struct xen_cpu_feature_set **result, xen_vm vm)
601 {
602 abstract_value param_values[] =
603 {
604 { .type = &abstract_type_string,
605 .u.string_val = vm }
606 };
608 abstract_type result_type = xen_cpu_feature_set_abstract_type_;
610 *result = NULL;
611 XEN_CALL_("VM.get_VCPUs_features_force_on");
612 return session->ok;
613 }
616 bool
617 xen_vm_get_vcpus_features_force_off(xen_session *session, struct xen_cpu_feature_set **result, xen_vm vm)
618 {
619 abstract_value param_values[] =
620 {
621 { .type = &abstract_type_string,
622 .u.string_val = vm }
623 };
625 abstract_type result_type = xen_cpu_feature_set_abstract_type_;
627 *result = NULL;
628 XEN_CALL_("VM.get_VCPUs_features_force_off");
629 return session->ok;
630 }
633 bool
634 xen_vm_get_actions_after_shutdown(xen_session *session, enum xen_on_normal_exit *result, xen_vm vm)
635 {
636 abstract_value param_values[] =
637 {
638 { .type = &abstract_type_string,
639 .u.string_val = vm }
640 };
642 abstract_type result_type = xen_on_normal_exit_abstract_type_;
643 char *result_str = NULL;
644 XEN_CALL_("VM.get_actions_after_shutdown");
645 *result = xen_on_normal_exit_from_string(session, result_str);
646 return session->ok;
647 }
650 bool
651 xen_vm_get_actions_after_reboot(xen_session *session, enum xen_on_normal_exit *result, xen_vm vm)
652 {
653 abstract_value param_values[] =
654 {
655 { .type = &abstract_type_string,
656 .u.string_val = vm }
657 };
659 abstract_type result_type = xen_on_normal_exit_abstract_type_;
660 char *result_str = NULL;
661 XEN_CALL_("VM.get_actions_after_reboot");
662 *result = xen_on_normal_exit_from_string(session, result_str);
663 return session->ok;
664 }
667 bool
668 xen_vm_get_actions_after_suspend(xen_session *session, enum xen_on_normal_exit *result, xen_vm vm)
669 {
670 abstract_value param_values[] =
671 {
672 { .type = &abstract_type_string,
673 .u.string_val = vm }
674 };
676 abstract_type result_type = xen_on_normal_exit_abstract_type_;
677 char *result_str = NULL;
678 XEN_CALL_("VM.get_actions_after_suspend");
679 *result = xen_on_normal_exit_from_string(session, result_str);
680 return session->ok;
681 }
684 bool
685 xen_vm_get_actions_after_crash(xen_session *session, enum xen_on_crash_behaviour *result, xen_vm vm)
686 {
687 abstract_value param_values[] =
688 {
689 { .type = &abstract_type_string,
690 .u.string_val = vm }
691 };
693 abstract_type result_type = xen_on_crash_behaviour_abstract_type_;
694 char *result_str = NULL;
695 XEN_CALL_("VM.get_actions_after_crash");
696 *result = xen_on_crash_behaviour_from_string(session, result_str);
697 return session->ok;
698 }
701 bool
702 xen_vm_get_consoles(xen_session *session, struct xen_console_set **result, xen_vm vm)
703 {
704 abstract_value param_values[] =
705 {
706 { .type = &abstract_type_string,
707 .u.string_val = vm }
708 };
710 abstract_type result_type = abstract_type_string_set;
712 *result = NULL;
713 XEN_CALL_("VM.get_consoles");
714 return session->ok;
715 }
718 bool
719 xen_vm_get_vifs(xen_session *session, struct xen_vif_set **result, xen_vm vm)
720 {
721 abstract_value param_values[] =
722 {
723 { .type = &abstract_type_string,
724 .u.string_val = vm }
725 };
727 abstract_type result_type = abstract_type_string_set;
729 *result = NULL;
730 XEN_CALL_("VM.get_VIFs");
731 return session->ok;
732 }
735 bool
736 xen_vm_get_vbds(xen_session *session, struct xen_vbd_set **result, xen_vm vm)
737 {
738 abstract_value param_values[] =
739 {
740 { .type = &abstract_type_string,
741 .u.string_val = vm }
742 };
744 abstract_type result_type = abstract_type_string_set;
746 *result = NULL;
747 XEN_CALL_("VM.get_VBDs");
748 return session->ok;
749 }
752 bool
753 xen_vm_get_vtpms(xen_session *session, struct xen_vtpm_set **result, xen_vm vm)
754 {
755 abstract_value param_values[] =
756 {
757 { .type = &abstract_type_string,
758 .u.string_val = vm }
759 };
761 abstract_type result_type = abstract_type_string_set;
763 *result = NULL;
764 XEN_CALL_("VM.get_VTPMs");
765 return session->ok;
766 }
769 bool
770 xen_vm_get_bios_boot(xen_session *session, char **result, xen_vm vm)
771 {
772 abstract_value param_values[] =
773 {
774 { .type = &abstract_type_string,
775 .u.string_val = vm }
776 };
778 abstract_type result_type = abstract_type_string;
780 *result = NULL;
781 XEN_CALL_("VM.get_bios_boot");
782 return session->ok;
783 }
786 bool
787 xen_vm_get_platform_std_vga(xen_session *session, bool *result, xen_vm vm)
788 {
789 abstract_value param_values[] =
790 {
791 { .type = &abstract_type_string,
792 .u.string_val = vm }
793 };
795 abstract_type result_type = abstract_type_bool;
797 XEN_CALL_("VM.get_platform_std_VGA");
798 return session->ok;
799 }
802 bool
803 xen_vm_get_platform_serial(xen_session *session, char **result, xen_vm vm)
804 {
805 abstract_value param_values[] =
806 {
807 { .type = &abstract_type_string,
808 .u.string_val = vm }
809 };
811 abstract_type result_type = abstract_type_string;
813 *result = NULL;
814 XEN_CALL_("VM.get_platform_serial");
815 return session->ok;
816 }
819 bool
820 xen_vm_get_platform_localtime(xen_session *session, bool *result, xen_vm vm)
821 {
822 abstract_value param_values[] =
823 {
824 { .type = &abstract_type_string,
825 .u.string_val = vm }
826 };
828 abstract_type result_type = abstract_type_bool;
830 XEN_CALL_("VM.get_platform_localtime");
831 return session->ok;
832 }
835 bool
836 xen_vm_get_platform_clock_offset(xen_session *session, bool *result, xen_vm vm)
837 {
838 abstract_value param_values[] =
839 {
840 { .type = &abstract_type_string,
841 .u.string_val = vm }
842 };
844 abstract_type result_type = abstract_type_bool;
846 XEN_CALL_("VM.get_platform_clock_offset");
847 return session->ok;
848 }
851 bool
852 xen_vm_get_platform_enable_audio(xen_session *session, bool *result, xen_vm vm)
853 {
854 abstract_value param_values[] =
855 {
856 { .type = &abstract_type_string,
857 .u.string_val = vm }
858 };
860 abstract_type result_type = abstract_type_bool;
862 XEN_CALL_("VM.get_platform_enable_audio");
863 return session->ok;
864 }
867 bool
868 xen_vm_get_builder(xen_session *session, char **result, xen_vm vm)
869 {
870 abstract_value param_values[] =
871 {
872 { .type = &abstract_type_string,
873 .u.string_val = vm }
874 };
876 abstract_type result_type = abstract_type_string;
878 *result = NULL;
879 XEN_CALL_("VM.get_builder");
880 return session->ok;
881 }
884 bool
885 xen_vm_get_boot_method(xen_session *session, enum xen_boot_type *result, xen_vm vm)
886 {
887 abstract_value param_values[] =
888 {
889 { .type = &abstract_type_string,
890 .u.string_val = vm }
891 };
893 abstract_type result_type = xen_boot_type_abstract_type_;
894 char *result_str = NULL;
895 XEN_CALL_("VM.get_boot_method");
896 *result = xen_boot_type_from_string(session, result_str);
897 return session->ok;
898 }
901 bool
902 xen_vm_get_kernel_kernel(xen_session *session, char **result, xen_vm vm)
903 {
904 abstract_value param_values[] =
905 {
906 { .type = &abstract_type_string,
907 .u.string_val = vm }
908 };
910 abstract_type result_type = abstract_type_string;
912 *result = NULL;
913 XEN_CALL_("VM.get_kernel_kernel");
914 return session->ok;
915 }
918 bool
919 xen_vm_get_kernel_initrd(xen_session *session, char **result, xen_vm vm)
920 {
921 abstract_value param_values[] =
922 {
923 { .type = &abstract_type_string,
924 .u.string_val = vm }
925 };
927 abstract_type result_type = abstract_type_string;
929 *result = NULL;
930 XEN_CALL_("VM.get_kernel_initrd");
931 return session->ok;
932 }
935 bool
936 xen_vm_get_kernel_args(xen_session *session, char **result, xen_vm vm)
937 {
938 abstract_value param_values[] =
939 {
940 { .type = &abstract_type_string,
941 .u.string_val = vm }
942 };
944 abstract_type result_type = abstract_type_string;
946 *result = NULL;
947 XEN_CALL_("VM.get_kernel_args");
948 return session->ok;
949 }
952 bool
953 xen_vm_get_grub_cmdline(xen_session *session, char **result, xen_vm vm)
954 {
955 abstract_value param_values[] =
956 {
957 { .type = &abstract_type_string,
958 .u.string_val = vm }
959 };
961 abstract_type result_type = abstract_type_string;
963 *result = NULL;
964 XEN_CALL_("VM.get_grub_cmdline");
965 return session->ok;
966 }
969 bool
970 xen_vm_get_pci_bus(xen_session *session, char **result, xen_vm vm)
971 {
972 abstract_value param_values[] =
973 {
974 { .type = &abstract_type_string,
975 .u.string_val = vm }
976 };
978 abstract_type result_type = abstract_type_string;
980 *result = NULL;
981 XEN_CALL_("VM.get_PCI_bus");
982 return session->ok;
983 }
986 bool
987 xen_vm_get_tools_version(xen_session *session, xen_string_string_map **result, xen_vm vm)
988 {
989 abstract_value param_values[] =
990 {
991 { .type = &abstract_type_string,
992 .u.string_val = vm }
993 };
995 abstract_type result_type = abstract_type_string_string_map;
997 *result = NULL;
998 XEN_CALL_("VM.get_tools_version");
999 return session->ok;
1003 bool
1004 xen_vm_get_otherconfig(xen_session *session, xen_string_string_map **result, xen_vm vm)
1006 abstract_value param_values[] =
1008 { .type = &abstract_type_string,
1009 .u.string_val = vm }
1010 };
1012 abstract_type result_type = abstract_type_string_string_map;
1014 *result = NULL;
1015 XEN_CALL_("VM.get_otherConfig");
1016 return session->ok;
1020 bool
1021 xen_vm_set_name_label(xen_session *session, xen_vm vm, char *label)
1023 abstract_value param_values[] =
1025 { .type = &abstract_type_string,
1026 .u.string_val = vm },
1027 { .type = &abstract_type_string,
1028 .u.string_val = label }
1029 };
1031 xen_call_(session, "VM.set_name_label", param_values, 2, NULL, NULL);
1032 return session->ok;
1036 bool
1037 xen_vm_set_name_description(xen_session *session, xen_vm vm, char *description)
1039 abstract_value param_values[] =
1041 { .type = &abstract_type_string,
1042 .u.string_val = vm },
1043 { .type = &abstract_type_string,
1044 .u.string_val = description }
1045 };
1047 xen_call_(session, "VM.set_name_description", param_values, 2, NULL, NULL);
1048 return session->ok;
1052 bool
1053 xen_vm_set_user_version(xen_session *session, xen_vm vm, int64_t user_version)
1055 abstract_value param_values[] =
1057 { .type = &abstract_type_string,
1058 .u.string_val = vm },
1059 { .type = &abstract_type_int,
1060 .u.int_val = user_version }
1061 };
1063 xen_call_(session, "VM.set_user_version", param_values, 2, NULL, NULL);
1064 return session->ok;
1068 bool
1069 xen_vm_set_is_a_template(xen_session *session, xen_vm vm, bool is_a_template)
1071 abstract_value param_values[] =
1073 { .type = &abstract_type_string,
1074 .u.string_val = vm },
1075 { .type = &abstract_type_bool,
1076 .u.bool_val = is_a_template }
1077 };
1079 xen_call_(session, "VM.set_is_a_template", param_values, 2, NULL, NULL);
1080 return session->ok;
1084 bool
1085 xen_vm_set_memory_dynamic_max(xen_session *session, xen_vm vm, int64_t dynamic_max)
1087 abstract_value param_values[] =
1089 { .type = &abstract_type_string,
1090 .u.string_val = vm },
1091 { .type = &abstract_type_int,
1092 .u.int_val = dynamic_max }
1093 };
1095 xen_call_(session, "VM.set_memory_dynamic_max", param_values, 2, NULL, NULL);
1096 return session->ok;
1100 bool
1101 xen_vm_set_memory_dynamic_min(xen_session *session, xen_vm vm, int64_t dynamic_min)
1103 abstract_value param_values[] =
1105 { .type = &abstract_type_string,
1106 .u.string_val = vm },
1107 { .type = &abstract_type_int,
1108 .u.int_val = dynamic_min }
1109 };
1111 xen_call_(session, "VM.set_memory_dynamic_min", param_values, 2, NULL, NULL);
1112 return session->ok;
1116 bool
1117 xen_vm_set_vcpus_policy(xen_session *session, xen_vm vm, char *policy)
1119 abstract_value param_values[] =
1121 { .type = &abstract_type_string,
1122 .u.string_val = vm },
1123 { .type = &abstract_type_string,
1124 .u.string_val = policy }
1125 };
1127 xen_call_(session, "VM.set_VCPUs_policy", param_values, 2, NULL, NULL);
1128 return session->ok;
1132 bool
1133 xen_vm_set_vcpus_params(xen_session *session, xen_vm vm, char *params)
1135 abstract_value param_values[] =
1137 { .type = &abstract_type_string,
1138 .u.string_val = vm },
1139 { .type = &abstract_type_string,
1140 .u.string_val = params }
1141 };
1143 xen_call_(session, "VM.set_VCPUs_params", param_values, 2, NULL, NULL);
1144 return session->ok;
1148 bool
1149 xen_vm_set_vcpus_features_force_on(xen_session *session, xen_vm vm, struct xen_cpu_feature_set *force_on)
1151 abstract_value param_values[] =
1153 { .type = &abstract_type_string,
1154 .u.string_val = vm },
1155 { .type = &xen_cpu_feature_set_abstract_type_,
1156 .u.set_val = (arbitrary_set *)force_on }
1157 };
1159 xen_call_(session, "VM.set_VCPUs_features_force_on", param_values, 2, NULL, NULL);
1160 return session->ok;
1164 bool
1165 xen_vm_set_vcpus_features_force_off(xen_session *session, xen_vm vm, struct xen_cpu_feature_set *force_off)
1167 abstract_value param_values[] =
1169 { .type = &abstract_type_string,
1170 .u.string_val = vm },
1171 { .type = &xen_cpu_feature_set_abstract_type_,
1172 .u.set_val = (arbitrary_set *)force_off }
1173 };
1175 xen_call_(session, "VM.set_VCPUs_features_force_off", param_values, 2, NULL, NULL);
1176 return session->ok;
1180 bool
1181 xen_vm_set_actions_after_shutdown(xen_session *session, xen_vm vm, enum xen_on_normal_exit after_shutdown)
1183 abstract_value param_values[] =
1185 { .type = &abstract_type_string,
1186 .u.string_val = vm },
1187 { .type = &xen_on_normal_exit_abstract_type_,
1188 .u.string_val = xen_on_normal_exit_to_string(after_shutdown) }
1189 };
1191 xen_call_(session, "VM.set_actions_after_shutdown", param_values, 2, NULL, NULL);
1192 return session->ok;
1196 bool
1197 xen_vm_set_actions_after_reboot(xen_session *session, xen_vm vm, enum xen_on_normal_exit after_reboot)
1199 abstract_value param_values[] =
1201 { .type = &abstract_type_string,
1202 .u.string_val = vm },
1203 { .type = &xen_on_normal_exit_abstract_type_,
1204 .u.string_val = xen_on_normal_exit_to_string(after_reboot) }
1205 };
1207 xen_call_(session, "VM.set_actions_after_reboot", param_values, 2, NULL, NULL);
1208 return session->ok;
1212 bool
1213 xen_vm_set_actions_after_suspend(xen_session *session, xen_vm vm, enum xen_on_normal_exit after_suspend)
1215 abstract_value param_values[] =
1217 { .type = &abstract_type_string,
1218 .u.string_val = vm },
1219 { .type = &xen_on_normal_exit_abstract_type_,
1220 .u.string_val = xen_on_normal_exit_to_string(after_suspend) }
1221 };
1223 xen_call_(session, "VM.set_actions_after_suspend", param_values, 2, NULL, NULL);
1224 return session->ok;
1228 bool
1229 xen_vm_set_actions_after_crash(xen_session *session, xen_vm vm, enum xen_on_crash_behaviour after_crash)
1231 abstract_value param_values[] =
1233 { .type = &abstract_type_string,
1234 .u.string_val = vm },
1235 { .type = &xen_on_crash_behaviour_abstract_type_,
1236 .u.string_val = xen_on_crash_behaviour_to_string(after_crash) }
1237 };
1239 xen_call_(session, "VM.set_actions_after_crash", param_values, 2, NULL, NULL);
1240 return session->ok;
1244 bool
1245 xen_vm_set_bios_boot(xen_session *session, xen_vm vm, char *boot)
1247 abstract_value param_values[] =
1249 { .type = &abstract_type_string,
1250 .u.string_val = vm },
1251 { .type = &abstract_type_string,
1252 .u.string_val = boot }
1253 };
1255 xen_call_(session, "VM.set_bios_boot", param_values, 2, NULL, NULL);
1256 return session->ok;
1260 bool
1261 xen_vm_set_platform_std_vga(xen_session *session, xen_vm vm, bool std_vga)
1263 abstract_value param_values[] =
1265 { .type = &abstract_type_string,
1266 .u.string_val = vm },
1267 { .type = &abstract_type_bool,
1268 .u.bool_val = std_vga }
1269 };
1271 xen_call_(session, "VM.set_platform_std_vga", param_values, 2, NULL, NULL);
1272 return session->ok;
1276 bool
1277 xen_vm_set_platform_serial(xen_session *session, xen_vm vm, char *serial)
1279 abstract_value param_values[] =
1281 { .type = &abstract_type_string,
1282 .u.string_val = vm },
1283 { .type = &abstract_type_string,
1284 .u.string_val = serial }
1285 };
1287 xen_call_(session, "VM.set_platform_serial", param_values, 2, NULL, NULL);
1288 return session->ok;
1292 bool
1293 xen_vm_set_platform_localtime(xen_session *session, xen_vm vm, bool localtime)
1295 abstract_value param_values[] =
1297 { .type = &abstract_type_string,
1298 .u.string_val = vm },
1299 { .type = &abstract_type_bool,
1300 .u.bool_val = localtime }
1301 };
1303 xen_call_(session, "VM.set_platform_localtime", param_values, 2, NULL, NULL);
1304 return session->ok;
1308 bool
1309 xen_vm_set_platform_clock_offset(xen_session *session, xen_vm vm, bool clock_offset)
1311 abstract_value param_values[] =
1313 { .type = &abstract_type_string,
1314 .u.string_val = vm },
1315 { .type = &abstract_type_bool,
1316 .u.bool_val = clock_offset }
1317 };
1319 xen_call_(session, "VM.set_platform_clock_offset", param_values, 2, NULL, NULL);
1320 return session->ok;
1324 bool
1325 xen_vm_set_platform_enable_audio(xen_session *session, xen_vm vm, bool enable_audio)
1327 abstract_value param_values[] =
1329 { .type = &abstract_type_string,
1330 .u.string_val = vm },
1331 { .type = &abstract_type_bool,
1332 .u.bool_val = enable_audio }
1333 };
1335 xen_call_(session, "VM.set_platform_enable_audio", param_values, 2, NULL, NULL);
1336 return session->ok;
1340 bool
1341 xen_vm_set_builder(xen_session *session, xen_vm vm, char *builder)
1343 abstract_value param_values[] =
1345 { .type = &abstract_type_string,
1346 .u.string_val = vm },
1347 { .type = &abstract_type_string,
1348 .u.string_val = builder }
1349 };
1351 xen_call_(session, "VM.set_builder", param_values, 2, NULL, NULL);
1352 return session->ok;
1356 bool
1357 xen_vm_set_boot_method(xen_session *session, xen_vm vm, enum xen_boot_type boot_method)
1359 abstract_value param_values[] =
1361 { .type = &abstract_type_string,
1362 .u.string_val = vm },
1363 { .type = &xen_boot_type_abstract_type_,
1364 .u.string_val = xen_boot_type_to_string(boot_method) }
1365 };
1367 xen_call_(session, "VM.set_boot_method", param_values, 2, NULL, NULL);
1368 return session->ok;
1372 bool
1373 xen_vm_set_kernel_kernel(xen_session *session, xen_vm vm, char *kernel)
1375 abstract_value param_values[] =
1377 { .type = &abstract_type_string,
1378 .u.string_val = vm },
1379 { .type = &abstract_type_string,
1380 .u.string_val = kernel }
1381 };
1383 xen_call_(session, "VM.set_kernel_kernel", param_values, 2, NULL, NULL);
1384 return session->ok;
1388 bool
1389 xen_vm_set_kernel_initrd(xen_session *session, xen_vm vm, char *initrd)
1391 abstract_value param_values[] =
1393 { .type = &abstract_type_string,
1394 .u.string_val = vm },
1395 { .type = &abstract_type_string,
1396 .u.string_val = initrd }
1397 };
1399 xen_call_(session, "VM.set_kernel_initrd", param_values, 2, NULL, NULL);
1400 return session->ok;
1404 bool
1405 xen_vm_set_kernel_args(xen_session *session, xen_vm vm, char *args)
1407 abstract_value param_values[] =
1409 { .type = &abstract_type_string,
1410 .u.string_val = vm },
1411 { .type = &abstract_type_string,
1412 .u.string_val = args }
1413 };
1415 xen_call_(session, "VM.set_kernel_args", param_values, 2, NULL, NULL);
1416 return session->ok;
1420 bool
1421 xen_vm_set_grub_cmdline(xen_session *session, xen_vm vm, char *cmdline)
1423 abstract_value param_values[] =
1425 { .type = &abstract_type_string,
1426 .u.string_val = vm },
1427 { .type = &abstract_type_string,
1428 .u.string_val = cmdline }
1429 };
1431 xen_call_(session, "VM.set_grub_cmdline", param_values, 2, NULL, NULL);
1432 return session->ok;
1436 bool
1437 xen_vm_set_otherconfig(xen_session *session, xen_vm vm, xen_string_string_map *otherconfig)
1439 abstract_value param_values[] =
1441 { .type = &abstract_type_string,
1442 .u.string_val = vm },
1443 { .type = &abstract_type_string_string_map,
1444 .u.set_val = (arbitrary_set *)otherconfig }
1445 };
1447 xen_call_(session, "VM.set_otherconfig", param_values, 2, NULL, NULL);
1448 return session->ok;
1452 bool
1453 xen_vm_clone(xen_session *session, xen_vm *result, xen_vm vm, char *new_name)
1455 abstract_value param_values[] =
1457 { .type = &abstract_type_string,
1458 .u.string_val = vm },
1459 { .type = &abstract_type_string,
1460 .u.string_val = new_name }
1461 };
1463 abstract_type result_type = abstract_type_string;
1465 *result = NULL;
1466 XEN_CALL_("VM.clone");
1467 return session->ok;
1471 bool
1472 xen_vm_start(xen_session *session, xen_vm vm, bool start_paused)
1474 abstract_value param_values[] =
1476 { .type = &abstract_type_string,
1477 .u.string_val = vm },
1478 { .type = &abstract_type_bool,
1479 .u.bool_val = start_paused }
1480 };
1482 xen_call_(session, "VM.start", param_values, 2, NULL, NULL);
1483 return session->ok;
1487 bool
1488 xen_vm_pause(xen_session *session, xen_vm vm)
1490 abstract_value param_values[] =
1492 { .type = &abstract_type_string,
1493 .u.string_val = vm }
1494 };
1496 xen_call_(session, "VM.pause", param_values, 1, NULL, NULL);
1497 return session->ok;
1501 bool
1502 xen_vm_unpause(xen_session *session, xen_vm vm)
1504 abstract_value param_values[] =
1506 { .type = &abstract_type_string,
1507 .u.string_val = vm }
1508 };
1510 xen_call_(session, "VM.unpause", param_values, 1, NULL, NULL);
1511 return session->ok;
1515 bool
1516 xen_vm_clean_shutdown(xen_session *session, xen_vm vm)
1518 abstract_value param_values[] =
1520 { .type = &abstract_type_string,
1521 .u.string_val = vm }
1522 };
1524 xen_call_(session, "VM.clean_shutdown", param_values, 1, NULL, NULL);
1525 return session->ok;
1529 bool
1530 xen_vm_clean_reboot(xen_session *session, xen_vm vm)
1532 abstract_value param_values[] =
1534 { .type = &abstract_type_string,
1535 .u.string_val = vm }
1536 };
1538 xen_call_(session, "VM.clean_reboot", param_values, 1, NULL, NULL);
1539 return session->ok;
1543 bool
1544 xen_vm_hard_shutdown(xen_session *session, xen_vm vm)
1546 abstract_value param_values[] =
1548 { .type = &abstract_type_string,
1549 .u.string_val = vm }
1550 };
1552 xen_call_(session, "VM.hard_shutdown", param_values, 1, NULL, NULL);
1553 return session->ok;
1557 bool
1558 xen_vm_hard_reboot(xen_session *session, xen_vm vm)
1560 abstract_value param_values[] =
1562 { .type = &abstract_type_string,
1563 .u.string_val = vm }
1564 };
1566 xen_call_(session, "VM.hard_reboot", param_values, 1, NULL, NULL);
1567 return session->ok;
1571 bool
1572 xen_vm_suspend(xen_session *session, xen_vm vm)
1574 abstract_value param_values[] =
1576 { .type = &abstract_type_string,
1577 .u.string_val = vm }
1578 };
1580 xen_call_(session, "VM.suspend", param_values, 1, NULL, NULL);
1581 return session->ok;
1585 bool
1586 xen_vm_resume(xen_session *session, xen_vm vm, bool start_paused)
1588 abstract_value param_values[] =
1590 { .type = &abstract_type_string,
1591 .u.string_val = vm },
1592 { .type = &abstract_type_bool,
1593 .u.bool_val = start_paused }
1594 };
1596 xen_call_(session, "VM.resume", param_values, 2, NULL, NULL);
1597 return session->ok;
1601 bool
1602 xen_vm_get_all(xen_session *session, struct xen_vm_set **result)
1605 abstract_type result_type = abstract_type_string_set;
1607 *result = NULL;
1608 xen_call_(session, "VM.get_all", NULL, 0, &result_type, result);
1609 return session->ok;
1613 bool
1614 xen_vm_get_uuid(xen_session *session, char **result, xen_vm vm)
1616 *result = session->ok ? xen_strdup_((char *)vm) : NULL;
1617 return session->ok;