2
* Copyright (c) 2006-2007, XenSource Inc.
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.
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.
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
23
#include "xen_internal.h"
24
#include <xen/api/xen_common.h>
25
#include <xen/api/xen_host.h>
26
#include <xen/api/xen_host_cpu.h>
27
#include <xen/api/xen_host_metrics.h>
28
#include <xen/api/xen_pbd.h>
29
#include <xen/api/xen_pif.h>
30
#include <xen/api/xen_sr.h>
31
#include <xen/api/xen_string_string_map.h>
32
#include <xen/api/xen_vm.h>
36
XEN_SET_ALLOC_FREE(xen_host)
37
XEN_ALLOC(xen_host_record)
38
XEN_SET_ALLOC_FREE(xen_host_record)
39
XEN_ALLOC(xen_host_record_opt)
40
XEN_RECORD_OPT_FREE(xen_host)
41
XEN_SET_ALLOC_FREE(xen_host_record_opt)
44
static const struct_member xen_host_record_struct_members[] =
47
.type = &abstract_type_string,
48
.offset = offsetof(xen_host_record, uuid) },
49
{ .key = "name_label",
50
.type = &abstract_type_string,
51
.offset = offsetof(xen_host_record, name_label) },
52
{ .key = "name_description",
53
.type = &abstract_type_string,
54
.offset = offsetof(xen_host_record, name_description) },
55
{ .key = "API_version_major",
56
.type = &abstract_type_int,
57
.offset = offsetof(xen_host_record, api_version_major) },
58
{ .key = "API_version_minor",
59
.type = &abstract_type_int,
60
.offset = offsetof(xen_host_record, api_version_minor) },
61
{ .key = "API_version_vendor",
62
.type = &abstract_type_string,
63
.offset = offsetof(xen_host_record, api_version_vendor) },
64
{ .key = "API_version_vendor_implementation",
65
.type = &abstract_type_string_string_map,
66
.offset = offsetof(xen_host_record, api_version_vendor_implementation) },
68
.type = &abstract_type_bool,
69
.offset = offsetof(xen_host_record, enabled) },
70
{ .key = "software_version",
71
.type = &abstract_type_string_string_map,
72
.offset = offsetof(xen_host_record, software_version) },
73
{ .key = "other_config",
74
.type = &abstract_type_string_string_map,
75
.offset = offsetof(xen_host_record, other_config) },
76
{ .key = "capabilities",
77
.type = &abstract_type_string_set,
78
.offset = offsetof(xen_host_record, capabilities) },
79
{ .key = "cpu_configuration",
80
.type = &abstract_type_string_string_map,
81
.offset = offsetof(xen_host_record, cpu_configuration) },
82
{ .key = "sched_policy",
83
.type = &abstract_type_string,
84
.offset = offsetof(xen_host_record, sched_policy) },
85
{ .key = "supported_bootloaders",
86
.type = &abstract_type_string_set,
87
.offset = offsetof(xen_host_record, supported_bootloaders) },
88
{ .key = "resident_VMs",
89
.type = &abstract_type_ref_set,
90
.offset = offsetof(xen_host_record, resident_vms) },
92
.type = &abstract_type_string_string_map,
93
.offset = offsetof(xen_host_record, logging) },
95
.type = &abstract_type_ref_set,
96
.offset = offsetof(xen_host_record, pifs) },
97
{ .key = "suspend_image_sr",
98
.type = &abstract_type_ref,
99
.offset = offsetof(xen_host_record, suspend_image_sr) },
100
{ .key = "crash_dump_sr",
101
.type = &abstract_type_ref,
102
.offset = offsetof(xen_host_record, crash_dump_sr) },
104
.type = &abstract_type_ref_set,
105
.offset = offsetof(xen_host_record, pbds) },
106
{ .key = "host_CPUs",
107
.type = &abstract_type_ref_set,
108
.offset = offsetof(xen_host_record, host_cpus) },
110
.type = &abstract_type_ref,
111
.offset = offsetof(xen_host_record, metrics) }
114
const abstract_type xen_host_record_abstract_type_ =
117
.struct_size = sizeof(xen_host_record),
119
sizeof(xen_host_record_struct_members) / sizeof(struct_member),
120
.members = xen_host_record_struct_members
125
xen_host_record_free(xen_host_record *record)
131
free(record->handle);
133
free(record->name_label);
134
free(record->name_description);
135
free(record->api_version_vendor);
136
xen_string_string_map_free(record->api_version_vendor_implementation);
137
xen_string_string_map_free(record->software_version);
138
xen_string_string_map_free(record->other_config);
139
xen_string_set_free(record->capabilities);
140
xen_string_string_map_free(record->cpu_configuration);
141
free(record->sched_policy);
142
xen_string_set_free(record->supported_bootloaders);
143
xen_vm_record_opt_set_free(record->resident_vms);
144
xen_string_string_map_free(record->logging);
145
xen_pif_record_opt_set_free(record->pifs);
146
xen_sr_record_opt_free(record->suspend_image_sr);
147
xen_sr_record_opt_free(record->crash_dump_sr);
148
xen_pbd_record_opt_set_free(record->pbds);
149
xen_host_cpu_record_opt_set_free(record->host_cpus);
150
xen_host_metrics_record_opt_free(record->metrics);
156
xen_host_get_record(xen_session *session, xen_host_record **result, xen_host host)
158
abstract_value param_values[] =
160
{ .type = &abstract_type_string,
161
.u.string_val = host }
164
abstract_type result_type = xen_host_record_abstract_type_;
167
XEN_CALL_("host.get_record");
171
(*result)->handle = xen_strdup_((*result)->uuid);
179
xen_host_get_by_uuid(xen_session *session, xen_host *result, char *uuid)
181
abstract_value param_values[] =
183
{ .type = &abstract_type_string,
184
.u.string_val = uuid }
187
abstract_type result_type = abstract_type_string;
190
XEN_CALL_("host.get_by_uuid");
196
xen_host_get_by_name_label(xen_session *session, struct xen_host_set **result, char *label)
198
abstract_value param_values[] =
200
{ .type = &abstract_type_string,
201
.u.string_val = label }
204
abstract_type result_type = abstract_type_string_set;
207
XEN_CALL_("host.get_by_name_label");
213
xen_host_get_name_label(xen_session *session, char **result, xen_host host)
215
abstract_value param_values[] =
217
{ .type = &abstract_type_string,
218
.u.string_val = host }
221
abstract_type result_type = abstract_type_string;
224
XEN_CALL_("host.get_name_label");
230
xen_host_get_name_description(xen_session *session, char **result, xen_host host)
232
abstract_value param_values[] =
234
{ .type = &abstract_type_string,
235
.u.string_val = host }
238
abstract_type result_type = abstract_type_string;
241
XEN_CALL_("host.get_name_description");
247
xen_host_get_api_version_major(xen_session *session, int64_t *result, xen_host host)
249
abstract_value param_values[] =
251
{ .type = &abstract_type_string,
252
.u.string_val = host }
255
abstract_type result_type = abstract_type_int;
257
XEN_CALL_("host.get_API_version_major");
263
xen_host_get_api_version_minor(xen_session *session, int64_t *result, xen_host host)
265
abstract_value param_values[] =
267
{ .type = &abstract_type_string,
268
.u.string_val = host }
271
abstract_type result_type = abstract_type_int;
273
XEN_CALL_("host.get_API_version_minor");
279
xen_host_get_api_version_vendor(xen_session *session, char **result, xen_host host)
281
abstract_value param_values[] =
283
{ .type = &abstract_type_string,
284
.u.string_val = host }
287
abstract_type result_type = abstract_type_string;
290
XEN_CALL_("host.get_API_version_vendor");
296
xen_host_get_api_version_vendor_implementation(xen_session *session, xen_string_string_map **result, xen_host host)
298
abstract_value param_values[] =
300
{ .type = &abstract_type_string,
301
.u.string_val = host }
304
abstract_type result_type = abstract_type_string_string_map;
307
XEN_CALL_("host.get_API_version_vendor_implementation");
313
xen_host_get_enabled(xen_session *session, bool *result, xen_host host)
315
abstract_value param_values[] =
317
{ .type = &abstract_type_string,
318
.u.string_val = host }
321
abstract_type result_type = abstract_type_bool;
323
XEN_CALL_("host.get_enabled");
329
xen_host_get_software_version(xen_session *session, xen_string_string_map **result, xen_host host)
331
abstract_value param_values[] =
333
{ .type = &abstract_type_string,
334
.u.string_val = host }
337
abstract_type result_type = abstract_type_string_string_map;
340
XEN_CALL_("host.get_software_version");
346
xen_host_get_other_config(xen_session *session, xen_string_string_map **result, xen_host host)
348
abstract_value param_values[] =
350
{ .type = &abstract_type_string,
351
.u.string_val = host }
354
abstract_type result_type = abstract_type_string_string_map;
357
XEN_CALL_("host.get_other_config");
363
xen_host_get_capabilities(xen_session *session, struct xen_string_set **result, xen_host host)
365
abstract_value param_values[] =
367
{ .type = &abstract_type_string,
368
.u.string_val = host }
371
abstract_type result_type = abstract_type_string_set;
374
XEN_CALL_("host.get_capabilities");
380
xen_host_get_cpu_configuration(xen_session *session, xen_string_string_map **result, xen_host host)
382
abstract_value param_values[] =
384
{ .type = &abstract_type_string,
385
.u.string_val = host }
388
abstract_type result_type = abstract_type_string_string_map;
391
XEN_CALL_("host.get_cpu_configuration");
397
xen_host_get_sched_policy(xen_session *session, char **result, xen_host host)
399
abstract_value param_values[] =
401
{ .type = &abstract_type_string,
402
.u.string_val = host }
405
abstract_type result_type = abstract_type_string;
408
XEN_CALL_("host.get_sched_policy");
414
xen_host_get_supported_bootloaders(xen_session *session, struct xen_string_set **result, xen_host host)
416
abstract_value param_values[] =
418
{ .type = &abstract_type_string,
419
.u.string_val = host }
422
abstract_type result_type = abstract_type_string_set;
425
XEN_CALL_("host.get_supported_bootloaders");
431
xen_host_get_resident_vms(xen_session *session, struct xen_vm_set **result, xen_host host)
433
abstract_value param_values[] =
435
{ .type = &abstract_type_string,
436
.u.string_val = host }
439
abstract_type result_type = abstract_type_string_set;
442
XEN_CALL_("host.get_resident_VMs");
448
xen_host_get_logging(xen_session *session, xen_string_string_map **result, xen_host host)
450
abstract_value param_values[] =
452
{ .type = &abstract_type_string,
453
.u.string_val = host }
456
abstract_type result_type = abstract_type_string_string_map;
459
XEN_CALL_("host.get_logging");
465
xen_host_get_pifs(xen_session *session, struct xen_pif_set **result, xen_host host)
467
abstract_value param_values[] =
469
{ .type = &abstract_type_string,
470
.u.string_val = host }
473
abstract_type result_type = abstract_type_string_set;
476
XEN_CALL_("host.get_PIFs");
482
xen_host_get_suspend_image_sr(xen_session *session, xen_sr *result, xen_host host)
484
abstract_value param_values[] =
486
{ .type = &abstract_type_string,
487
.u.string_val = host }
490
abstract_type result_type = abstract_type_string;
493
XEN_CALL_("host.get_suspend_image_sr");
499
xen_host_get_crash_dump_sr(xen_session *session, xen_sr *result, xen_host host)
501
abstract_value param_values[] =
503
{ .type = &abstract_type_string,
504
.u.string_val = host }
507
abstract_type result_type = abstract_type_string;
510
XEN_CALL_("host.get_crash_dump_sr");
516
xen_host_get_pbds(xen_session *session, struct xen_pbd_set **result, xen_host host)
518
abstract_value param_values[] =
520
{ .type = &abstract_type_string,
521
.u.string_val = host }
524
abstract_type result_type = abstract_type_string_set;
527
XEN_CALL_("host.get_PBDs");
533
xen_host_get_host_cpus(xen_session *session, struct xen_host_cpu_set **result, xen_host host)
535
abstract_value param_values[] =
537
{ .type = &abstract_type_string,
538
.u.string_val = host }
541
abstract_type result_type = abstract_type_string_set;
544
XEN_CALL_("host.get_host_CPUs");
550
xen_host_get_metrics(xen_session *session, xen_host_metrics *result, xen_host host)
552
abstract_value param_values[] =
554
{ .type = &abstract_type_string,
555
.u.string_val = host }
558
abstract_type result_type = abstract_type_string;
561
XEN_CALL_("host.get_metrics");
567
xen_host_set_name_label(xen_session *session, xen_host host, char *label)
569
abstract_value param_values[] =
571
{ .type = &abstract_type_string,
572
.u.string_val = host },
573
{ .type = &abstract_type_string,
574
.u.string_val = label }
577
xen_call_(session, "host.set_name_label", param_values, 2, NULL, NULL);
583
xen_host_set_name_description(xen_session *session, xen_host host, char *description)
585
abstract_value param_values[] =
587
{ .type = &abstract_type_string,
588
.u.string_val = host },
589
{ .type = &abstract_type_string,
590
.u.string_val = description }
593
xen_call_(session, "host.set_name_description", param_values, 2, NULL, NULL);
599
xen_host_set_other_config(xen_session *session, xen_host host, xen_string_string_map *other_config)
601
abstract_value param_values[] =
603
{ .type = &abstract_type_string,
604
.u.string_val = host },
605
{ .type = &abstract_type_string_string_map,
606
.u.set_val = (arbitrary_set *)other_config }
609
xen_call_(session, "host.set_other_config", param_values, 2, NULL, NULL);
615
xen_host_add_to_other_config(xen_session *session, xen_host host, char *key, char *value)
617
abstract_value param_values[] =
619
{ .type = &abstract_type_string,
620
.u.string_val = host },
621
{ .type = &abstract_type_string,
622
.u.string_val = key },
623
{ .type = &abstract_type_string,
624
.u.string_val = value }
627
xen_call_(session, "host.add_to_other_config", param_values, 3, NULL, NULL);
633
xen_host_remove_from_other_config(xen_session *session, xen_host host, char *key)
635
abstract_value param_values[] =
637
{ .type = &abstract_type_string,
638
.u.string_val = host },
639
{ .type = &abstract_type_string,
640
.u.string_val = key }
643
xen_call_(session, "host.remove_from_other_config", param_values, 2, NULL, NULL);
649
xen_host_set_logging(xen_session *session, xen_host host, xen_string_string_map *logging)
651
abstract_value param_values[] =
653
{ .type = &abstract_type_string,
654
.u.string_val = host },
655
{ .type = &abstract_type_string_string_map,
656
.u.set_val = (arbitrary_set *)logging }
659
xen_call_(session, "host.set_logging", param_values, 2, NULL, NULL);
665
xen_host_add_to_logging(xen_session *session, xen_host host, char *key, char *value)
667
abstract_value param_values[] =
669
{ .type = &abstract_type_string,
670
.u.string_val = host },
671
{ .type = &abstract_type_string,
672
.u.string_val = key },
673
{ .type = &abstract_type_string,
674
.u.string_val = value }
677
xen_call_(session, "host.add_to_logging", param_values, 3, NULL, NULL);
683
xen_host_remove_from_logging(xen_session *session, xen_host host, char *key)
685
abstract_value param_values[] =
687
{ .type = &abstract_type_string,
688
.u.string_val = host },
689
{ .type = &abstract_type_string,
690
.u.string_val = key }
693
xen_call_(session, "host.remove_from_logging", param_values, 2, NULL, NULL);
699
xen_host_set_suspend_image_sr(xen_session *session, xen_host host, xen_sr suspend_image_sr)
701
abstract_value param_values[] =
703
{ .type = &abstract_type_string,
704
.u.string_val = host },
705
{ .type = &abstract_type_string,
706
.u.string_val = suspend_image_sr }
709
xen_call_(session, "host.set_suspend_image_sr", param_values, 2, NULL, NULL);
715
xen_host_set_crash_dump_sr(xen_session *session, xen_host host, xen_sr crash_dump_sr)
717
abstract_value param_values[] =
719
{ .type = &abstract_type_string,
720
.u.string_val = host },
721
{ .type = &abstract_type_string,
722
.u.string_val = crash_dump_sr }
725
xen_call_(session, "host.set_crash_dump_sr", param_values, 2, NULL, NULL);
731
xen_host_disable(xen_session *session, xen_host host)
733
abstract_value param_values[] =
735
{ .type = &abstract_type_string,
736
.u.string_val = host }
739
xen_call_(session, "host.disable", param_values, 1, NULL, NULL);
745
xen_host_enable(xen_session *session, xen_host host)
747
abstract_value param_values[] =
749
{ .type = &abstract_type_string,
750
.u.string_val = host }
753
xen_call_(session, "host.enable", param_values, 1, NULL, NULL);
759
xen_host_shutdown(xen_session *session, xen_host host)
761
abstract_value param_values[] =
763
{ .type = &abstract_type_string,
764
.u.string_val = host }
767
xen_call_(session, "host.shutdown", param_values, 1, NULL, NULL);
773
xen_host_reboot(xen_session *session, xen_host host)
775
abstract_value param_values[] =
777
{ .type = &abstract_type_string,
778
.u.string_val = host }
781
xen_call_(session, "host.reboot", param_values, 1, NULL, NULL);
787
xen_host_dmesg(xen_session *session, char **result, xen_host host)
789
abstract_value param_values[] =
791
{ .type = &abstract_type_string,
792
.u.string_val = host }
795
abstract_type result_type = abstract_type_string;
798
XEN_CALL_("host.dmesg");
804
xen_host_dmesg_clear(xen_session *session, char **result, xen_host host)
806
abstract_value param_values[] =
808
{ .type = &abstract_type_string,
809
.u.string_val = host }
812
abstract_type result_type = abstract_type_string;
815
XEN_CALL_("host.dmesg_clear");
821
xen_host_get_log(xen_session *session, char **result, xen_host host)
823
abstract_value param_values[] =
825
{ .type = &abstract_type_string,
826
.u.string_val = host }
829
abstract_type result_type = abstract_type_string;
832
XEN_CALL_("host.get_log");
838
xen_host_send_debug_keys(xen_session *session, xen_host host, char *keys)
840
abstract_value param_values[] =
842
{ .type = &abstract_type_string,
843
.u.string_val = host },
844
{ .type = &abstract_type_string,
845
.u.string_val = keys }
848
xen_call_(session, "host.send_debug_keys", param_values, 2, NULL, NULL);
854
xen_host_list_methods(xen_session *session, struct xen_string_set **result)
857
abstract_type result_type = abstract_type_string_set;
860
xen_call_(session, "host.list_methods", NULL, 0, &result_type, result);
866
xen_host_get_all(xen_session *session, struct xen_host_set **result)
869
abstract_type result_type = abstract_type_string_set;
872
xen_call_(session, "host.get_all", NULL, 0, &result_type, result);
878
xen_host_get_uuid(xen_session *session, char **result, xen_host host)
880
abstract_value param_values[] =
882
{ .type = &abstract_type_string,
883
.u.string_val = host }
886
abstract_type result_type = abstract_type_string;
889
XEN_CALL_("host.get_uuid");