ia64/xen-unstable

view tools/libxen/src/xen_vm.c @ 13056:54eee6fabbee

Fix VM.get_power_state API. On the xend side an integer representation of the power state was being returned instead of a string representation as specified by the XenAPI spec.

On the c-bindings side the marshalling code converts the string representation to an enum value. A subsequent attempt to convert the enum from a string to an enum was causing a seg fault.

Signed-off-by: Jim Fehlig <jfehlig@novell.com>
author jfehlig@jfehlig2.provo.novell.com
date Wed Dec 13 18:06:48 2006 -0700 (2006-12-13)
parents 0ee4e33b4401
children ea12d26877a4
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_common.h"
24 #include "xen_console.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 = "auto_power_on",
70 .type = &abstract_type_bool,
71 .offset = offsetof(xen_vm_record, auto_power_on) },
72 { .key = "resident_on",
73 .type = &abstract_type_ref,
74 .offset = offsetof(xen_vm_record, resident_on) },
75 { .key = "memory_static_max",
76 .type = &abstract_type_int,
77 .offset = offsetof(xen_vm_record, memory_static_max) },
78 { .key = "memory_dynamic_max",
79 .type = &abstract_type_int,
80 .offset = offsetof(xen_vm_record, memory_dynamic_max) },
81 { .key = "memory_actual",
82 .type = &abstract_type_int,
83 .offset = offsetof(xen_vm_record, memory_actual) },
84 { .key = "memory_dynamic_min",
85 .type = &abstract_type_int,
86 .offset = offsetof(xen_vm_record, memory_dynamic_min) },
87 { .key = "memory_static_min",
88 .type = &abstract_type_int,
89 .offset = offsetof(xen_vm_record, memory_static_min) },
90 { .key = "VCPUs_policy",
91 .type = &abstract_type_string,
92 .offset = offsetof(xen_vm_record, vcpus_policy) },
93 { .key = "VCPUs_params",
94 .type = &abstract_type_string,
95 .offset = offsetof(xen_vm_record, vcpus_params) },
96 { .key = "VCPUs_number",
97 .type = &abstract_type_int,
98 .offset = offsetof(xen_vm_record, vcpus_number) },
99 { .key = "VCPUs_utilisation",
100 .type = &abstract_type_int_float_map,
101 .offset = offsetof(xen_vm_record, vcpus_utilisation) },
102 { .key = "VCPUs_features_required",
103 .type = &xen_cpu_feature_set_abstract_type_,
104 .offset = offsetof(xen_vm_record, vcpus_features_required) },
105 { .key = "VCPUs_features_can_use",
106 .type = &xen_cpu_feature_set_abstract_type_,
107 .offset = offsetof(xen_vm_record, vcpus_features_can_use) },
108 { .key = "VCPUs_features_force_on",
109 .type = &xen_cpu_feature_set_abstract_type_,
110 .offset = offsetof(xen_vm_record, vcpus_features_force_on) },
111 { .key = "VCPUs_features_force_off",
112 .type = &xen_cpu_feature_set_abstract_type_,
113 .offset = offsetof(xen_vm_record, vcpus_features_force_off) },
114 { .key = "actions_after_shutdown",
115 .type = &xen_on_normal_exit_abstract_type_,
116 .offset = offsetof(xen_vm_record, actions_after_shutdown) },
117 { .key = "actions_after_reboot",
118 .type = &xen_on_normal_exit_abstract_type_,
119 .offset = offsetof(xen_vm_record, actions_after_reboot) },
120 { .key = "actions_after_suspend",
121 .type = &xen_on_normal_exit_abstract_type_,
122 .offset = offsetof(xen_vm_record, actions_after_suspend) },
123 { .key = "actions_after_crash",
124 .type = &xen_on_crash_behaviour_abstract_type_,
125 .offset = offsetof(xen_vm_record, actions_after_crash) },
126 { .key = "consoles",
127 .type = &abstract_type_ref_set,
128 .offset = offsetof(xen_vm_record, consoles) },
129 { .key = "VIFs",
130 .type = &abstract_type_ref_set,
131 .offset = offsetof(xen_vm_record, vifs) },
132 { .key = "VBDs",
133 .type = &abstract_type_ref_set,
134 .offset = offsetof(xen_vm_record, vbds) },
135 { .key = "VTPMs",
136 .type = &abstract_type_ref_set,
137 .offset = offsetof(xen_vm_record, vtpms) },
138 { .key = "PV_bootloader",
139 .type = &abstract_type_string,
140 .offset = offsetof(xen_vm_record, pv_bootloader) },
141 { .key = "PV_kernel",
142 .type = &abstract_type_string,
143 .offset = offsetof(xen_vm_record, pv_kernel) },
144 { .key = "PV_ramdisk",
145 .type = &abstract_type_string,
146 .offset = offsetof(xen_vm_record, pv_ramdisk) },
147 { .key = "PV_args",
148 .type = &abstract_type_string,
149 .offset = offsetof(xen_vm_record, pv_args) },
150 { .key = "PV_bootloader_args",
151 .type = &abstract_type_string,
152 .offset = offsetof(xen_vm_record, pv_bootloader_args) },
153 { .key = "HVM_boot",
154 .type = &abstract_type_string,
155 .offset = offsetof(xen_vm_record, hvm_boot) },
156 { .key = "platform_std_VGA",
157 .type = &abstract_type_bool,
158 .offset = offsetof(xen_vm_record, platform_std_vga) },
159 { .key = "platform_serial",
160 .type = &abstract_type_string,
161 .offset = offsetof(xen_vm_record, platform_serial) },
162 { .key = "platform_localtime",
163 .type = &abstract_type_bool,
164 .offset = offsetof(xen_vm_record, platform_localtime) },
165 { .key = "platform_clock_offset",
166 .type = &abstract_type_bool,
167 .offset = offsetof(xen_vm_record, platform_clock_offset) },
168 { .key = "platform_enable_audio",
169 .type = &abstract_type_bool,
170 .offset = offsetof(xen_vm_record, platform_enable_audio) },
171 { .key = "PCI_bus",
172 .type = &abstract_type_string,
173 .offset = offsetof(xen_vm_record, pci_bus) },
174 { .key = "tools_version",
175 .type = &abstract_type_string_string_map,
176 .offset = offsetof(xen_vm_record, tools_version) },
177 { .key = "otherConfig",
178 .type = &abstract_type_string_string_map,
179 .offset = offsetof(xen_vm_record, otherconfig) }
180 };
182 const abstract_type xen_vm_record_abstract_type_ =
183 {
184 .typename = STRUCT,
185 .struct_size = sizeof(xen_vm_record),
186 .member_count =
187 sizeof(xen_vm_record_struct_members) / sizeof(struct_member),
188 .members = xen_vm_record_struct_members
189 };
192 void
193 xen_vm_record_free(xen_vm_record *record)
194 {
195 if (record == NULL)
196 {
197 return;
198 }
199 free(record->handle);
200 free(record->uuid);
201 free(record->name_label);
202 free(record->name_description);
203 xen_host_record_opt_free(record->resident_on);
204 free(record->vcpus_policy);
205 free(record->vcpus_params);
206 xen_int_float_map_free(record->vcpus_utilisation);
207 xen_cpu_feature_set_free(record->vcpus_features_required);
208 xen_cpu_feature_set_free(record->vcpus_features_can_use);
209 xen_cpu_feature_set_free(record->vcpus_features_force_on);
210 xen_cpu_feature_set_free(record->vcpus_features_force_off);
211 xen_console_record_opt_set_free(record->consoles);
212 xen_vif_record_opt_set_free(record->vifs);
213 xen_vbd_record_opt_set_free(record->vbds);
214 xen_vtpm_record_opt_set_free(record->vtpms);
215 free(record->pv_bootloader);
216 free(record->pv_kernel);
217 free(record->pv_ramdisk);
218 free(record->pv_args);
219 free(record->pv_bootloader_args);
220 free(record->hvm_boot);
221 free(record->platform_serial);
222 free(record->pci_bus);
223 xen_string_string_map_free(record->tools_version);
224 xen_string_string_map_free(record->otherconfig);
225 free(record);
226 }
229 bool
230 xen_vm_get_record(xen_session *session, xen_vm_record **result, xen_vm vm)
231 {
232 abstract_value param_values[] =
233 {
234 { .type = &abstract_type_string,
235 .u.string_val = vm }
236 };
238 abstract_type result_type = xen_vm_record_abstract_type_;
240 *result = NULL;
241 XEN_CALL_("VM.get_record");
243 if (session->ok)
244 {
245 (*result)->handle = xen_strdup_((*result)->uuid);
246 }
248 return session->ok;
249 }
252 bool
253 xen_vm_get_by_uuid(xen_session *session, xen_vm *result, char *uuid)
254 {
255 abstract_value param_values[] =
256 {
257 { .type = &abstract_type_string,
258 .u.string_val = uuid }
259 };
261 abstract_type result_type = abstract_type_string;
263 *result = NULL;
264 XEN_CALL_("VM.get_by_uuid");
265 return session->ok;
266 }
269 bool
270 xen_vm_create(xen_session *session, xen_vm *result, xen_vm_record *record)
271 {
272 abstract_value param_values[] =
273 {
274 { .type = &xen_vm_record_abstract_type_,
275 .u.struct_val = record }
276 };
278 abstract_type result_type = abstract_type_string;
280 *result = NULL;
281 XEN_CALL_("VM.create");
282 return session->ok;
283 }
286 bool
287 xen_vm_destroy(xen_session *session, xen_vm vm)
288 {
289 abstract_value param_values[] =
290 {
291 { .type = &abstract_type_string,
292 .u.string_val = vm }
293 };
295 xen_call_(session, "VM.destroy", param_values, 1, NULL, NULL);
296 return session->ok;
297 }
300 bool
301 xen_vm_get_by_name_label(xen_session *session, struct xen_vm_set **result, char *label)
302 {
303 abstract_value param_values[] =
304 {
305 { .type = &abstract_type_string,
306 .u.string_val = label }
307 };
309 abstract_type result_type = abstract_type_string_set;
311 *result = NULL;
312 XEN_CALL_("VM.get_by_name_label");
313 return session->ok;
314 }
317 bool
318 xen_vm_get_power_state(xen_session *session, enum xen_vm_power_state *result, xen_vm vm)
319 {
320 abstract_value param_values[] =
321 {
322 { .type = &abstract_type_string,
323 .u.string_val = vm }
324 };
326 abstract_type result_type = xen_vm_power_state_abstract_type_;
327 XEN_CALL_("VM.get_power_state");
328 return session->ok;
329 }
332 bool
333 xen_vm_get_name_label(xen_session *session, char **result, xen_vm vm)
334 {
335 abstract_value param_values[] =
336 {
337 { .type = &abstract_type_string,
338 .u.string_val = vm }
339 };
341 abstract_type result_type = abstract_type_string;
343 *result = NULL;
344 XEN_CALL_("VM.get_name_label");
345 return session->ok;
346 }
349 bool
350 xen_vm_get_name_description(xen_session *session, char **result, xen_vm vm)
351 {
352 abstract_value param_values[] =
353 {
354 { .type = &abstract_type_string,
355 .u.string_val = vm }
356 };
358 abstract_type result_type = abstract_type_string;
360 *result = NULL;
361 XEN_CALL_("VM.get_name_description");
362 return session->ok;
363 }
366 bool
367 xen_vm_get_user_version(xen_session *session, int64_t *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_int;
377 XEN_CALL_("VM.get_user_version");
378 return session->ok;
379 }
382 bool
383 xen_vm_get_is_a_template(xen_session *session, bool *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_bool;
393 XEN_CALL_("VM.get_is_a_template");
394 return session->ok;
395 }
398 bool
399 xen_vm_get_auto_power_on(xen_session *session, bool *result, xen_vm vm)
400 {
401 abstract_value param_values[] =
402 {
403 { .type = &abstract_type_string,
404 .u.string_val = vm }
405 };
407 abstract_type result_type = abstract_type_bool;
409 XEN_CALL_("VM.get_auto_power_on");
410 return session->ok;
411 }
414 bool
415 xen_vm_get_resident_on(xen_session *session, xen_host *result, xen_vm vm)
416 {
417 abstract_value param_values[] =
418 {
419 { .type = &abstract_type_string,
420 .u.string_val = vm }
421 };
423 abstract_type result_type = abstract_type_string;
425 *result = NULL;
426 XEN_CALL_("VM.get_resident_on");
427 return session->ok;
428 }
431 bool
432 xen_vm_get_memory_static_max(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_static_max");
443 return session->ok;
444 }
447 bool
448 xen_vm_get_memory_dynamic_max(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_max");
459 return session->ok;
460 }
463 bool
464 xen_vm_get_memory_actual(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_actual");
475 return session->ok;
476 }
479 bool
480 xen_vm_get_memory_dynamic_min(xen_session *session, int64_t *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_int;
490 XEN_CALL_("VM.get_memory_dynamic_min");
491 return session->ok;
492 }
495 bool
496 xen_vm_get_memory_static_min(xen_session *session, int64_t *result, xen_vm vm)
497 {
498 abstract_value param_values[] =
499 {
500 { .type = &abstract_type_string,
501 .u.string_val = vm }
502 };
504 abstract_type result_type = abstract_type_int;
506 XEN_CALL_("VM.get_memory_static_min");
507 return session->ok;
508 }
511 bool
512 xen_vm_get_vcpus_policy(xen_session *session, char **result, xen_vm vm)
513 {
514 abstract_value param_values[] =
515 {
516 { .type = &abstract_type_string,
517 .u.string_val = vm }
518 };
520 abstract_type result_type = abstract_type_string;
522 *result = NULL;
523 XEN_CALL_("VM.get_VCPUs_policy");
524 return session->ok;
525 }
528 bool
529 xen_vm_get_vcpus_params(xen_session *session, char **result, xen_vm vm)
530 {
531 abstract_value param_values[] =
532 {
533 { .type = &abstract_type_string,
534 .u.string_val = vm }
535 };
537 abstract_type result_type = abstract_type_string;
539 *result = NULL;
540 XEN_CALL_("VM.get_VCPUs_params");
541 return session->ok;
542 }
545 bool
546 xen_vm_get_vcpus_number(xen_session *session, int64_t *result, xen_vm vm)
547 {
548 abstract_value param_values[] =
549 {
550 { .type = &abstract_type_string,
551 .u.string_val = vm }
552 };
554 abstract_type result_type = abstract_type_int;
556 XEN_CALL_("VM.get_VCPUs_number");
557 return session->ok;
558 }
561 bool
562 xen_vm_get_vcpus_utilisation(xen_session *session, xen_int_float_map **result, xen_vm vm)
563 {
564 abstract_value param_values[] =
565 {
566 { .type = &abstract_type_string,
567 .u.string_val = vm }
568 };
570 abstract_type result_type = abstract_type_int_float_map;
572 *result = NULL;
573 XEN_CALL_("VM.get_VCPUs_utilisation");
574 return session->ok;
575 }
578 bool
579 xen_vm_get_vcpus_features_required(xen_session *session, struct xen_cpu_feature_set **result, xen_vm vm)
580 {
581 abstract_value param_values[] =
582 {
583 { .type = &abstract_type_string,
584 .u.string_val = vm }
585 };
587 abstract_type result_type = xen_cpu_feature_set_abstract_type_;
589 *result = NULL;
590 XEN_CALL_("VM.get_VCPUs_features_required");
591 return session->ok;
592 }
595 bool
596 xen_vm_get_vcpus_features_can_use(xen_session *session, struct xen_cpu_feature_set **result, xen_vm vm)
597 {
598 abstract_value param_values[] =
599 {
600 { .type = &abstract_type_string,
601 .u.string_val = vm }
602 };
604 abstract_type result_type = xen_cpu_feature_set_abstract_type_;
606 *result = NULL;
607 XEN_CALL_("VM.get_VCPUs_features_can_use");
608 return session->ok;
609 }
612 bool
613 xen_vm_get_vcpus_features_force_on(xen_session *session, struct xen_cpu_feature_set **result, xen_vm vm)
614 {
615 abstract_value param_values[] =
616 {
617 { .type = &abstract_type_string,
618 .u.string_val = vm }
619 };
621 abstract_type result_type = xen_cpu_feature_set_abstract_type_;
623 *result = NULL;
624 XEN_CALL_("VM.get_VCPUs_features_force_on");
625 return session->ok;
626 }
629 bool
630 xen_vm_get_vcpus_features_force_off(xen_session *session, struct xen_cpu_feature_set **result, xen_vm vm)
631 {
632 abstract_value param_values[] =
633 {
634 { .type = &abstract_type_string,
635 .u.string_val = vm }
636 };
638 abstract_type result_type = xen_cpu_feature_set_abstract_type_;
640 *result = NULL;
641 XEN_CALL_("VM.get_VCPUs_features_force_off");
642 return session->ok;
643 }
646 bool
647 xen_vm_get_actions_after_shutdown(xen_session *session, enum xen_on_normal_exit *result, xen_vm vm)
648 {
649 abstract_value param_values[] =
650 {
651 { .type = &abstract_type_string,
652 .u.string_val = vm }
653 };
655 abstract_type result_type = xen_on_normal_exit_abstract_type_;
656 char *result_str = NULL;
657 XEN_CALL_("VM.get_actions_after_shutdown");
658 *result = xen_on_normal_exit_from_string(session, result_str);
659 return session->ok;
660 }
663 bool
664 xen_vm_get_actions_after_reboot(xen_session *session, enum xen_on_normal_exit *result, xen_vm vm)
665 {
666 abstract_value param_values[] =
667 {
668 { .type = &abstract_type_string,
669 .u.string_val = vm }
670 };
672 abstract_type result_type = xen_on_normal_exit_abstract_type_;
673 char *result_str = NULL;
674 XEN_CALL_("VM.get_actions_after_reboot");
675 *result = xen_on_normal_exit_from_string(session, result_str);
676 return session->ok;
677 }
680 bool
681 xen_vm_get_actions_after_suspend(xen_session *session, enum xen_on_normal_exit *result, xen_vm vm)
682 {
683 abstract_value param_values[] =
684 {
685 { .type = &abstract_type_string,
686 .u.string_val = vm }
687 };
689 abstract_type result_type = xen_on_normal_exit_abstract_type_;
690 char *result_str = NULL;
691 XEN_CALL_("VM.get_actions_after_suspend");
692 *result = xen_on_normal_exit_from_string(session, result_str);
693 return session->ok;
694 }
697 bool
698 xen_vm_get_actions_after_crash(xen_session *session, enum xen_on_crash_behaviour *result, xen_vm vm)
699 {
700 abstract_value param_values[] =
701 {
702 { .type = &abstract_type_string,
703 .u.string_val = vm }
704 };
706 abstract_type result_type = xen_on_crash_behaviour_abstract_type_;
707 char *result_str = NULL;
708 XEN_CALL_("VM.get_actions_after_crash");
709 *result = xen_on_crash_behaviour_from_string(session, result_str);
710 return session->ok;
711 }
714 bool
715 xen_vm_get_consoles(xen_session *session, struct xen_console_set **result, xen_vm vm)
716 {
717 abstract_value param_values[] =
718 {
719 { .type = &abstract_type_string,
720 .u.string_val = vm }
721 };
723 abstract_type result_type = abstract_type_string_set;
725 *result = NULL;
726 XEN_CALL_("VM.get_consoles");
727 return session->ok;
728 }
731 bool
732 xen_vm_get_vifs(xen_session *session, struct xen_vif_set **result, xen_vm vm)
733 {
734 abstract_value param_values[] =
735 {
736 { .type = &abstract_type_string,
737 .u.string_val = vm }
738 };
740 abstract_type result_type = abstract_type_string_set;
742 *result = NULL;
743 XEN_CALL_("VM.get_VIFs");
744 return session->ok;
745 }
748 bool
749 xen_vm_get_vbds(xen_session *session, struct xen_vbd_set **result, xen_vm vm)
750 {
751 abstract_value param_values[] =
752 {
753 { .type = &abstract_type_string,
754 .u.string_val = vm }
755 };
757 abstract_type result_type = abstract_type_string_set;
759 *result = NULL;
760 XEN_CALL_("VM.get_VBDs");
761 return session->ok;
762 }
765 bool
766 xen_vm_get_vtpms(xen_session *session, struct xen_vtpm_set **result, xen_vm vm)
767 {
768 abstract_value param_values[] =
769 {
770 { .type = &abstract_type_string,
771 .u.string_val = vm }
772 };
774 abstract_type result_type = abstract_type_string_set;
776 *result = NULL;
777 XEN_CALL_("VM.get_VTPMs");
778 return session->ok;
779 }
782 bool
783 xen_vm_get_pv_bootloader(xen_session *session, char **result, xen_vm vm)
784 {
785 abstract_value param_values[] =
786 {
787 { .type = &abstract_type_string,
788 .u.string_val = vm }
789 };
791 abstract_type result_type = abstract_type_string;
793 *result = NULL;
794 XEN_CALL_("VM.get_PV_bootloader");
795 return session->ok;
796 }
799 bool
800 xen_vm_get_pv_kernel(xen_session *session, char **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_string;
810 *result = NULL;
811 XEN_CALL_("VM.get_PV_kernel");
812 return session->ok;
813 }
816 bool
817 xen_vm_get_pv_ramdisk(xen_session *session, char **result, xen_vm vm)
818 {
819 abstract_value param_values[] =
820 {
821 { .type = &abstract_type_string,
822 .u.string_val = vm }
823 };
825 abstract_type result_type = abstract_type_string;
827 *result = NULL;
828 XEN_CALL_("VM.get_PV_ramdisk");
829 return session->ok;
830 }
833 bool
834 xen_vm_get_pv_args(xen_session *session, char **result, xen_vm vm)
835 {
836 abstract_value param_values[] =
837 {
838 { .type = &abstract_type_string,
839 .u.string_val = vm }
840 };
842 abstract_type result_type = abstract_type_string;
844 *result = NULL;
845 XEN_CALL_("VM.get_PV_args");
846 return session->ok;
847 }
850 bool
851 xen_vm_get_pv_bootloader_args(xen_session *session, char **result, xen_vm vm)
852 {
853 abstract_value param_values[] =
854 {
855 { .type = &abstract_type_string,
856 .u.string_val = vm }
857 };
859 abstract_type result_type = abstract_type_string;
861 *result = NULL;
862 XEN_CALL_("VM.get_PV_bootloader_args");
863 return session->ok;
864 }
867 bool
868 xen_vm_get_hvm_boot(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_HVM_boot");
880 return session->ok;
881 }
884 bool
885 xen_vm_get_platform_std_vga(xen_session *session, bool *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 = abstract_type_bool;
895 XEN_CALL_("VM.get_platform_std_VGA");
896 return session->ok;
897 }
900 bool
901 xen_vm_get_platform_serial(xen_session *session, char **result, xen_vm vm)
902 {
903 abstract_value param_values[] =
904 {
905 { .type = &abstract_type_string,
906 .u.string_val = vm }
907 };
909 abstract_type result_type = abstract_type_string;
911 *result = NULL;
912 XEN_CALL_("VM.get_platform_serial");
913 return session->ok;
914 }
917 bool
918 xen_vm_get_platform_localtime(xen_session *session, bool *result, xen_vm vm)
919 {
920 abstract_value param_values[] =
921 {
922 { .type = &abstract_type_string,
923 .u.string_val = vm }
924 };
926 abstract_type result_type = abstract_type_bool;
928 XEN_CALL_("VM.get_platform_localtime");
929 return session->ok;
930 }
933 bool
934 xen_vm_get_platform_clock_offset(xen_session *session, bool *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_bool;
944 XEN_CALL_("VM.get_platform_clock_offset");
945 return session->ok;
946 }
949 bool
950 xen_vm_get_platform_enable_audio(xen_session *session, bool *result, xen_vm vm)
951 {
952 abstract_value param_values[] =
953 {
954 { .type = &abstract_type_string,
955 .u.string_val = vm }
956 };
958 abstract_type result_type = abstract_type_bool;
960 XEN_CALL_("VM.get_platform_enable_audio");
961 return session->ok;
962 }
965 bool
966 xen_vm_get_pci_bus(xen_session *session, char **result, xen_vm vm)
967 {
968 abstract_value param_values[] =
969 {
970 { .type = &abstract_type_string,
971 .u.string_val = vm }
972 };
974 abstract_type result_type = abstract_type_string;
976 *result = NULL;
977 XEN_CALL_("VM.get_PCI_bus");
978 return session->ok;
979 }
982 bool
983 xen_vm_get_tools_version(xen_session *session, xen_string_string_map **result, xen_vm vm)
984 {
985 abstract_value param_values[] =
986 {
987 { .type = &abstract_type_string,
988 .u.string_val = vm }
989 };
991 abstract_type result_type = abstract_type_string_string_map;
993 *result = NULL;
994 XEN_CALL_("VM.get_tools_version");
995 return session->ok;
996 }
999 bool
1000 xen_vm_get_otherconfig(xen_session *session, xen_string_string_map **result, xen_vm vm)
1002 abstract_value param_values[] =
1004 { .type = &abstract_type_string,
1005 .u.string_val = vm }
1006 };
1008 abstract_type result_type = abstract_type_string_string_map;
1010 *result = NULL;
1011 XEN_CALL_("VM.get_otherConfig");
1012 return session->ok;
1016 bool
1017 xen_vm_set_name_label(xen_session *session, xen_vm vm, char *label)
1019 abstract_value param_values[] =
1021 { .type = &abstract_type_string,
1022 .u.string_val = vm },
1023 { .type = &abstract_type_string,
1024 .u.string_val = label }
1025 };
1027 xen_call_(session, "VM.set_name_label", param_values, 2, NULL, NULL);
1028 return session->ok;
1032 bool
1033 xen_vm_set_name_description(xen_session *session, xen_vm vm, char *description)
1035 abstract_value param_values[] =
1037 { .type = &abstract_type_string,
1038 .u.string_val = vm },
1039 { .type = &abstract_type_string,
1040 .u.string_val = description }
1041 };
1043 xen_call_(session, "VM.set_name_description", param_values, 2, NULL, NULL);
1044 return session->ok;
1048 bool
1049 xen_vm_set_user_version(xen_session *session, xen_vm vm, int64_t user_version)
1051 abstract_value param_values[] =
1053 { .type = &abstract_type_string,
1054 .u.string_val = vm },
1055 { .type = &abstract_type_int,
1056 .u.int_val = user_version }
1057 };
1059 xen_call_(session, "VM.set_user_version", param_values, 2, NULL, NULL);
1060 return session->ok;
1064 bool
1065 xen_vm_set_is_a_template(xen_session *session, xen_vm vm, bool is_a_template)
1067 abstract_value param_values[] =
1069 { .type = &abstract_type_string,
1070 .u.string_val = vm },
1071 { .type = &abstract_type_bool,
1072 .u.bool_val = is_a_template }
1073 };
1075 xen_call_(session, "VM.set_is_a_template", param_values, 2, NULL, NULL);
1076 return session->ok;
1080 bool
1081 xen_vm_set_auto_power_on(xen_session *session, xen_vm vm, bool auto_power_on)
1083 abstract_value param_values[] =
1085 { .type = &abstract_type_string,
1086 .u.string_val = vm },
1087 { .type = &abstract_type_bool,
1088 .u.bool_val = auto_power_on }
1089 };
1091 xen_call_(session, "VM.set_auto_power_on", param_values, 2, NULL, NULL);
1092 return session->ok;
1096 bool
1097 xen_vm_set_memory_dynamic_max(xen_session *session, xen_vm vm, int64_t dynamic_max)
1099 abstract_value param_values[] =
1101 { .type = &abstract_type_string,
1102 .u.string_val = vm },
1103 { .type = &abstract_type_int,
1104 .u.int_val = dynamic_max }
1105 };
1107 xen_call_(session, "VM.set_memory_dynamic_max", param_values, 2, NULL, NULL);
1108 return session->ok;
1112 bool
1113 xen_vm_set_memory_dynamic_min(xen_session *session, xen_vm vm, int64_t dynamic_min)
1115 abstract_value param_values[] =
1117 { .type = &abstract_type_string,
1118 .u.string_val = vm },
1119 { .type = &abstract_type_int,
1120 .u.int_val = dynamic_min }
1121 };
1123 xen_call_(session, "VM.set_memory_dynamic_min", param_values, 2, NULL, NULL);
1124 return session->ok;
1128 bool
1129 xen_vm_set_vcpus_policy(xen_session *session, xen_vm vm, char *policy)
1131 abstract_value param_values[] =
1133 { .type = &abstract_type_string,
1134 .u.string_val = vm },
1135 { .type = &abstract_type_string,
1136 .u.string_val = policy }
1137 };
1139 xen_call_(session, "VM.set_VCPUs_policy", param_values, 2, NULL, NULL);
1140 return session->ok;
1144 bool
1145 xen_vm_set_vcpus_params(xen_session *session, xen_vm vm, char *params)
1147 abstract_value param_values[] =
1149 { .type = &abstract_type_string,
1150 .u.string_val = vm },
1151 { .type = &abstract_type_string,
1152 .u.string_val = params }
1153 };
1155 xen_call_(session, "VM.set_VCPUs_params", param_values, 2, NULL, NULL);
1156 return session->ok;
1160 bool
1161 xen_vm_set_vcpus_number(xen_session *session, xen_vm vm, int64_t number)
1163 abstract_value param_values[] =
1165 { .type = &abstract_type_string,
1166 .u.string_val = vm },
1167 { .type = &abstract_type_int,
1168 .u.int_val = number }
1169 };
1171 xen_call_(session, "VM.set_VCPUs_number", param_values, 2, NULL, NULL);
1172 return session->ok;
1176 bool
1177 xen_vm_set_vcpus_features_force_on(xen_session *session, xen_vm vm, struct xen_cpu_feature_set *force_on)
1179 abstract_value param_values[] =
1181 { .type = &abstract_type_string,
1182 .u.string_val = vm },
1183 { .type = &xen_cpu_feature_set_abstract_type_,
1184 .u.set_val = (arbitrary_set *)force_on }
1185 };
1187 xen_call_(session, "VM.set_VCPUs_features_force_on", param_values, 2, NULL, NULL);
1188 return session->ok;
1192 bool
1193 xen_vm_add_vcpus_features_force_on(xen_session *session, xen_vm vm, enum xen_cpu_feature value)
1195 abstract_value param_values[] =
1197 { .type = &abstract_type_string,
1198 .u.string_val = vm },
1199 { .type = &xen_cpu_feature_abstract_type_,
1200 .u.string_val = xen_cpu_feature_to_string(value) }
1201 };
1203 xen_call_(session, "VM.add_VCPUs_features_force_on", param_values, 2, NULL, NULL);
1204 return session->ok;
1208 bool
1209 xen_vm_remove_vcpus_features_force_on(xen_session *session, xen_vm vm, enum xen_cpu_feature value)
1211 abstract_value param_values[] =
1213 { .type = &abstract_type_string,
1214 .u.string_val = vm },
1215 { .type = &xen_cpu_feature_abstract_type_,
1216 .u.string_val = xen_cpu_feature_to_string(value) }
1217 };
1219 xen_call_(session, "VM.remove_VCPUs_features_force_on", param_values, 2, NULL, NULL);
1220 return session->ok;
1224 bool
1225 xen_vm_set_vcpus_features_force_off(xen_session *session, xen_vm vm, struct xen_cpu_feature_set *force_off)
1227 abstract_value param_values[] =
1229 { .type = &abstract_type_string,
1230 .u.string_val = vm },
1231 { .type = &xen_cpu_feature_set_abstract_type_,
1232 .u.set_val = (arbitrary_set *)force_off }
1233 };
1235 xen_call_(session, "VM.set_VCPUs_features_force_off", param_values, 2, NULL, NULL);
1236 return session->ok;
1240 bool
1241 xen_vm_add_vcpus_features_force_off(xen_session *session, xen_vm vm, enum xen_cpu_feature value)
1243 abstract_value param_values[] =
1245 { .type = &abstract_type_string,
1246 .u.string_val = vm },
1247 { .type = &xen_cpu_feature_abstract_type_,
1248 .u.string_val = xen_cpu_feature_to_string(value) }
1249 };
1251 xen_call_(session, "VM.add_VCPUs_features_force_off", param_values, 2, NULL, NULL);
1252 return session->ok;
1256 bool
1257 xen_vm_remove_vcpus_features_force_off(xen_session *session, xen_vm vm, enum xen_cpu_feature value)
1259 abstract_value param_values[] =
1261 { .type = &abstract_type_string,
1262 .u.string_val = vm },
1263 { .type = &xen_cpu_feature_abstract_type_,
1264 .u.string_val = xen_cpu_feature_to_string(value) }
1265 };
1267 xen_call_(session, "VM.remove_VCPUs_features_force_off", param_values, 2, NULL, NULL);
1268 return session->ok;
1272 bool
1273 xen_vm_set_actions_after_shutdown(xen_session *session, xen_vm vm, enum xen_on_normal_exit after_shutdown)
1275 abstract_value param_values[] =
1277 { .type = &abstract_type_string,
1278 .u.string_val = vm },
1279 { .type = &xen_on_normal_exit_abstract_type_,
1280 .u.string_val = xen_on_normal_exit_to_string(after_shutdown) }
1281 };
1283 xen_call_(session, "VM.set_actions_after_shutdown", param_values, 2, NULL, NULL);
1284 return session->ok;
1288 bool
1289 xen_vm_set_actions_after_reboot(xen_session *session, xen_vm vm, enum xen_on_normal_exit after_reboot)
1291 abstract_value param_values[] =
1293 { .type = &abstract_type_string,
1294 .u.string_val = vm },
1295 { .type = &xen_on_normal_exit_abstract_type_,
1296 .u.string_val = xen_on_normal_exit_to_string(after_reboot) }
1297 };
1299 xen_call_(session, "VM.set_actions_after_reboot", param_values, 2, NULL, NULL);
1300 return session->ok;
1304 bool
1305 xen_vm_set_actions_after_suspend(xen_session *session, xen_vm vm, enum xen_on_normal_exit after_suspend)
1307 abstract_value param_values[] =
1309 { .type = &abstract_type_string,
1310 .u.string_val = vm },
1311 { .type = &xen_on_normal_exit_abstract_type_,
1312 .u.string_val = xen_on_normal_exit_to_string(after_suspend) }
1313 };
1315 xen_call_(session, "VM.set_actions_after_suspend", param_values, 2, NULL, NULL);
1316 return session->ok;
1320 bool
1321 xen_vm_set_actions_after_crash(xen_session *session, xen_vm vm, enum xen_on_crash_behaviour after_crash)
1323 abstract_value param_values[] =
1325 { .type = &abstract_type_string,
1326 .u.string_val = vm },
1327 { .type = &xen_on_crash_behaviour_abstract_type_,
1328 .u.string_val = xen_on_crash_behaviour_to_string(after_crash) }
1329 };
1331 xen_call_(session, "VM.set_actions_after_crash", param_values, 2, NULL, NULL);
1332 return session->ok;
1336 bool
1337 xen_vm_set_pv_bootloader(xen_session *session, xen_vm vm, char *bootloader)
1339 abstract_value param_values[] =
1341 { .type = &abstract_type_string,
1342 .u.string_val = vm },
1343 { .type = &abstract_type_string,
1344 .u.string_val = bootloader }
1345 };
1347 xen_call_(session, "VM.set_PV_bootloader", param_values, 2, NULL, NULL);
1348 return session->ok;
1352 bool
1353 xen_vm_set_pv_kernel(xen_session *session, xen_vm vm, char *kernel)
1355 abstract_value param_values[] =
1357 { .type = &abstract_type_string,
1358 .u.string_val = vm },
1359 { .type = &abstract_type_string,
1360 .u.string_val = kernel }
1361 };
1363 xen_call_(session, "VM.set_PV_kernel", param_values, 2, NULL, NULL);
1364 return session->ok;
1368 bool
1369 xen_vm_set_pv_ramdisk(xen_session *session, xen_vm vm, char *ramdisk)
1371 abstract_value param_values[] =
1373 { .type = &abstract_type_string,
1374 .u.string_val = vm },
1375 { .type = &abstract_type_string,
1376 .u.string_val = ramdisk }
1377 };
1379 xen_call_(session, "VM.set_PV_ramdisk", param_values, 2, NULL, NULL);
1380 return session->ok;
1384 bool
1385 xen_vm_set_pv_args(xen_session *session, xen_vm vm, char *args)
1387 abstract_value param_values[] =
1389 { .type = &abstract_type_string,
1390 .u.string_val = vm },
1391 { .type = &abstract_type_string,
1392 .u.string_val = args }
1393 };
1395 xen_call_(session, "VM.set_PV_args", param_values, 2, NULL, NULL);
1396 return session->ok;
1400 bool
1401 xen_vm_set_pv_bootloader_args(xen_session *session, xen_vm vm, char *bootloader_args)
1403 abstract_value param_values[] =
1405 { .type = &abstract_type_string,
1406 .u.string_val = vm },
1407 { .type = &abstract_type_string,
1408 .u.string_val = bootloader_args }
1409 };
1411 xen_call_(session, "VM.set_PV_bootloader_args", param_values, 2, NULL, NULL);
1412 return session->ok;
1416 bool
1417 xen_vm_set_hvm_boot(xen_session *session, xen_vm vm, char *boot)
1419 abstract_value param_values[] =
1421 { .type = &abstract_type_string,
1422 .u.string_val = vm },
1423 { .type = &abstract_type_string,
1424 .u.string_val = boot }
1425 };
1427 xen_call_(session, "VM.set_HVM_boot", param_values, 2, NULL, NULL);
1428 return session->ok;
1432 bool
1433 xen_vm_set_platform_std_vga(xen_session *session, xen_vm vm, bool std_vga)
1435 abstract_value param_values[] =
1437 { .type = &abstract_type_string,
1438 .u.string_val = vm },
1439 { .type = &abstract_type_bool,
1440 .u.bool_val = std_vga }
1441 };
1443 xen_call_(session, "VM.set_platform_std_VGA", param_values, 2, NULL, NULL);
1444 return session->ok;
1448 bool
1449 xen_vm_set_platform_serial(xen_session *session, xen_vm vm, char *serial)
1451 abstract_value param_values[] =
1453 { .type = &abstract_type_string,
1454 .u.string_val = vm },
1455 { .type = &abstract_type_string,
1456 .u.string_val = serial }
1457 };
1459 xen_call_(session, "VM.set_platform_serial", param_values, 2, NULL, NULL);
1460 return session->ok;
1464 bool
1465 xen_vm_set_platform_localtime(xen_session *session, xen_vm vm, bool localtime)
1467 abstract_value param_values[] =
1469 { .type = &abstract_type_string,
1470 .u.string_val = vm },
1471 { .type = &abstract_type_bool,
1472 .u.bool_val = localtime }
1473 };
1475 xen_call_(session, "VM.set_platform_localtime", param_values, 2, NULL, NULL);
1476 return session->ok;
1480 bool
1481 xen_vm_set_platform_clock_offset(xen_session *session, xen_vm vm, bool clock_offset)
1483 abstract_value param_values[] =
1485 { .type = &abstract_type_string,
1486 .u.string_val = vm },
1487 { .type = &abstract_type_bool,
1488 .u.bool_val = clock_offset }
1489 };
1491 xen_call_(session, "VM.set_platform_clock_offset", param_values, 2, NULL, NULL);
1492 return session->ok;
1496 bool
1497 xen_vm_set_platform_enable_audio(xen_session *session, xen_vm vm, bool enable_audio)
1499 abstract_value param_values[] =
1501 { .type = &abstract_type_string,
1502 .u.string_val = vm },
1503 { .type = &abstract_type_bool,
1504 .u.bool_val = enable_audio }
1505 };
1507 xen_call_(session, "VM.set_platform_enable_audio", param_values, 2, NULL, NULL);
1508 return session->ok;
1512 bool
1513 xen_vm_set_otherconfig(xen_session *session, xen_vm vm, xen_string_string_map *otherconfig)
1515 abstract_value param_values[] =
1517 { .type = &abstract_type_string,
1518 .u.string_val = vm },
1519 { .type = &abstract_type_string_string_map,
1520 .u.set_val = (arbitrary_set *)otherconfig }
1521 };
1523 xen_call_(session, "VM.set_otherConfig", param_values, 2, NULL, NULL);
1524 return session->ok;
1528 bool
1529 xen_vm_clone(xen_session *session, xen_vm *result, xen_vm vm, char *new_name)
1531 abstract_value param_values[] =
1533 { .type = &abstract_type_string,
1534 .u.string_val = vm },
1535 { .type = &abstract_type_string,
1536 .u.string_val = new_name }
1537 };
1539 abstract_type result_type = abstract_type_string;
1541 *result = NULL;
1542 XEN_CALL_("VM.clone");
1543 return session->ok;
1547 bool
1548 xen_vm_start(xen_session *session, xen_vm vm, bool start_paused)
1550 abstract_value param_values[] =
1552 { .type = &abstract_type_string,
1553 .u.string_val = vm },
1554 { .type = &abstract_type_bool,
1555 .u.bool_val = start_paused }
1556 };
1558 xen_call_(session, "VM.start", param_values, 2, NULL, NULL);
1559 return session->ok;
1563 bool
1564 xen_vm_pause(xen_session *session, xen_vm vm)
1566 abstract_value param_values[] =
1568 { .type = &abstract_type_string,
1569 .u.string_val = vm }
1570 };
1572 xen_call_(session, "VM.pause", param_values, 1, NULL, NULL);
1573 return session->ok;
1577 bool
1578 xen_vm_unpause(xen_session *session, xen_vm vm)
1580 abstract_value param_values[] =
1582 { .type = &abstract_type_string,
1583 .u.string_val = vm }
1584 };
1586 xen_call_(session, "VM.unpause", param_values, 1, NULL, NULL);
1587 return session->ok;
1591 bool
1592 xen_vm_clean_shutdown(xen_session *session, xen_vm vm)
1594 abstract_value param_values[] =
1596 { .type = &abstract_type_string,
1597 .u.string_val = vm }
1598 };
1600 xen_call_(session, "VM.clean_shutdown", param_values, 1, NULL, NULL);
1601 return session->ok;
1605 bool
1606 xen_vm_clean_reboot(xen_session *session, xen_vm vm)
1608 abstract_value param_values[] =
1610 { .type = &abstract_type_string,
1611 .u.string_val = vm }
1612 };
1614 xen_call_(session, "VM.clean_reboot", param_values, 1, NULL, NULL);
1615 return session->ok;
1619 bool
1620 xen_vm_hard_shutdown(xen_session *session, xen_vm vm)
1622 abstract_value param_values[] =
1624 { .type = &abstract_type_string,
1625 .u.string_val = vm }
1626 };
1628 xen_call_(session, "VM.hard_shutdown", param_values, 1, NULL, NULL);
1629 return session->ok;
1633 bool
1634 xen_vm_hard_reboot(xen_session *session, xen_vm vm)
1636 abstract_value param_values[] =
1638 { .type = &abstract_type_string,
1639 .u.string_val = vm }
1640 };
1642 xen_call_(session, "VM.hard_reboot", param_values, 1, NULL, NULL);
1643 return session->ok;
1647 bool
1648 xen_vm_suspend(xen_session *session, xen_vm vm)
1650 abstract_value param_values[] =
1652 { .type = &abstract_type_string,
1653 .u.string_val = vm }
1654 };
1656 xen_call_(session, "VM.suspend", param_values, 1, NULL, NULL);
1657 return session->ok;
1661 bool
1662 xen_vm_resume(xen_session *session, xen_vm vm, bool start_paused)
1664 abstract_value param_values[] =
1666 { .type = &abstract_type_string,
1667 .u.string_val = vm },
1668 { .type = &abstract_type_bool,
1669 .u.bool_val = start_paused }
1670 };
1672 xen_call_(session, "VM.resume", param_values, 2, NULL, NULL);
1673 return session->ok;
1677 bool
1678 xen_vm_get_all(xen_session *session, struct xen_vm_set **result)
1681 abstract_type result_type = abstract_type_string_set;
1683 *result = NULL;
1684 xen_call_(session, "VM.get_all", NULL, 0, &result_type, result);
1685 return session->ok;
1689 bool
1690 xen_vm_get_uuid(xen_session *session, char **result, xen_vm vm)
1692 *result = session->ok ? xen_strdup_((char *)vm) : NULL;
1693 return session->ok;