debuggers.hg

view tools/libxen/src/xen_host_cpu.c @ 0:7d21f7218375

Exact replica of unstable on 051908 + README-this
author Mukesh Rathor
date Mon May 19 15:34:57 2008 -0700 (2008-05-19)
parents
children
line source
1 /*
2 * Copyright (c) 2006-2007, XenSource Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
20 #include <stddef.h>
21 #include <stdlib.h>
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>
29 XEN_FREE(xen_host_cpu)
30 XEN_SET_ALLOC_FREE(xen_host_cpu)
31 XEN_ALLOC(xen_host_cpu_record)
32 XEN_SET_ALLOC_FREE(xen_host_cpu_record)
33 XEN_ALLOC(xen_host_cpu_record_opt)
34 XEN_RECORD_OPT_FREE(xen_host_cpu)
35 XEN_SET_ALLOC_FREE(xen_host_cpu_record_opt)
38 static const struct_member xen_host_cpu_record_struct_members[] =
39 {
40 { .key = "uuid",
41 .type = &abstract_type_string,
42 .offset = offsetof(xen_host_cpu_record, uuid) },
43 { .key = "host",
44 .type = &abstract_type_ref,
45 .offset = offsetof(xen_host_cpu_record, host) },
46 { .key = "number",
47 .type = &abstract_type_int,
48 .offset = offsetof(xen_host_cpu_record, number) },
49 { .key = "vendor",
50 .type = &abstract_type_string,
51 .offset = offsetof(xen_host_cpu_record, vendor) },
52 { .key = "speed",
53 .type = &abstract_type_int,
54 .offset = offsetof(xen_host_cpu_record, speed) },
55 { .key = "modelname",
56 .type = &abstract_type_string,
57 .offset = offsetof(xen_host_cpu_record, modelname) },
58 { .key = "stepping",
59 .type = &abstract_type_string,
60 .offset = offsetof(xen_host_cpu_record, stepping) },
61 { .key = "flags",
62 .type = &abstract_type_string,
63 .offset = offsetof(xen_host_cpu_record, flags) },
64 { .key = "features",
65 .type = &abstract_type_string,
66 .offset = offsetof(xen_host_cpu_record, features) },
67 { .key = "utilisation",
68 .type = &abstract_type_float,
69 .offset = offsetof(xen_host_cpu_record, utilisation) }
70 };
72 const abstract_type xen_host_cpu_record_abstract_type_ =
73 {
74 .typename = STRUCT,
75 .struct_size = sizeof(xen_host_cpu_record),
76 .member_count =
77 sizeof(xen_host_cpu_record_struct_members) / sizeof(struct_member),
78 .members = xen_host_cpu_record_struct_members
79 };
82 void
83 xen_host_cpu_record_free(xen_host_cpu_record *record)
84 {
85 if (record == NULL)
86 {
87 return;
88 }
89 free(record->handle);
90 free(record->uuid);
91 xen_host_record_opt_free(record->host);
92 free(record->vendor);
93 free(record->modelname);
94 free(record->stepping);
95 free(record->flags);
96 free(record->features);
97 free(record);
98 }
101 bool
102 xen_host_cpu_get_record(xen_session *session, xen_host_cpu_record **result, xen_host_cpu host_cpu)
103 {
104 abstract_value param_values[] =
105 {
106 { .type = &abstract_type_string,
107 .u.string_val = host_cpu }
108 };
110 abstract_type result_type = xen_host_cpu_record_abstract_type_;
112 *result = NULL;
113 XEN_CALL_("host_cpu.get_record");
115 if (session->ok)
116 {
117 (*result)->handle = xen_strdup_((*result)->uuid);
118 }
120 return session->ok;
121 }
124 bool
125 xen_host_cpu_get_by_uuid(xen_session *session, xen_host_cpu *result, char *uuid)
126 {
127 abstract_value param_values[] =
128 {
129 { .type = &abstract_type_string,
130 .u.string_val = uuid }
131 };
133 abstract_type result_type = abstract_type_string;
135 *result = NULL;
136 XEN_CALL_("host_cpu.get_by_uuid");
137 return session->ok;
138 }
141 bool
142 xen_host_cpu_get_host(xen_session *session, xen_host *result, xen_host_cpu host_cpu)
143 {
144 abstract_value param_values[] =
145 {
146 { .type = &abstract_type_string,
147 .u.string_val = host_cpu }
148 };
150 abstract_type result_type = abstract_type_string;
152 *result = NULL;
153 XEN_CALL_("host_cpu.get_host");
154 return session->ok;
155 }
158 bool
159 xen_host_cpu_get_number(xen_session *session, int64_t *result, xen_host_cpu host_cpu)
160 {
161 abstract_value param_values[] =
162 {
163 { .type = &abstract_type_string,
164 .u.string_val = host_cpu }
165 };
167 abstract_type result_type = abstract_type_int;
169 XEN_CALL_("host_cpu.get_number");
170 return session->ok;
171 }
174 bool
175 xen_host_cpu_get_vendor(xen_session *session, char **result, xen_host_cpu host_cpu)
176 {
177 abstract_value param_values[] =
178 {
179 { .type = &abstract_type_string,
180 .u.string_val = host_cpu }
181 };
183 abstract_type result_type = abstract_type_string;
185 *result = NULL;
186 XEN_CALL_("host_cpu.get_vendor");
187 return session->ok;
188 }
191 bool
192 xen_host_cpu_get_speed(xen_session *session, int64_t *result, xen_host_cpu host_cpu)
193 {
194 abstract_value param_values[] =
195 {
196 { .type = &abstract_type_string,
197 .u.string_val = host_cpu }
198 };
200 abstract_type result_type = abstract_type_int;
202 XEN_CALL_("host_cpu.get_speed");
203 return session->ok;
204 }
207 bool
208 xen_host_cpu_get_modelname(xen_session *session, char **result, xen_host_cpu host_cpu)
209 {
210 abstract_value param_values[] =
211 {
212 { .type = &abstract_type_string,
213 .u.string_val = host_cpu }
214 };
216 abstract_type result_type = abstract_type_string;
218 *result = NULL;
219 XEN_CALL_("host_cpu.get_modelname");
220 return session->ok;
221 }
224 bool
225 xen_host_cpu_get_stepping(xen_session *session, char **result, xen_host_cpu host_cpu)
226 {
227 abstract_value param_values[] =
228 {
229 { .type = &abstract_type_string,
230 .u.string_val = host_cpu }
231 };
233 abstract_type result_type = abstract_type_string;
235 *result = NULL;
236 XEN_CALL_("host_cpu.get_stepping");
237 return session->ok;
238 }
241 bool
242 xen_host_cpu_get_flags(xen_session *session, char **result, xen_host_cpu host_cpu)
243 {
244 abstract_value param_values[] =
245 {
246 { .type = &abstract_type_string,
247 .u.string_val = host_cpu }
248 };
250 abstract_type result_type = abstract_type_string;
252 *result = NULL;
253 XEN_CALL_("host_cpu.get_flags");
254 return session->ok;
255 }
258 bool
259 xen_host_cpu_get_features(xen_session *session, char **result, xen_host_cpu host_cpu)
260 {
261 abstract_value param_values[] =
262 {
263 { .type = &abstract_type_string,
264 .u.string_val = host_cpu }
265 };
267 abstract_type result_type = abstract_type_string;
269 *result = NULL;
270 XEN_CALL_("host_cpu.get_features");
271 return session->ok;
272 }
275 bool
276 xen_host_cpu_get_utilisation(xen_session *session, double *result, xen_host_cpu host_cpu)
277 {
278 abstract_value param_values[] =
279 {
280 { .type = &abstract_type_string,
281 .u.string_val = host_cpu }
282 };
284 abstract_type result_type = abstract_type_float;
286 XEN_CALL_("host_cpu.get_utilisation");
287 return session->ok;
288 }
291 bool
292 xen_host_cpu_get_all(xen_session *session, struct xen_host_cpu_set **result)
293 {
295 abstract_type result_type = abstract_type_string_set;
297 *result = NULL;
298 xen_call_(session, "host_cpu.get_all", NULL, 0, &result_type, result);
299 return session->ok;
300 }
303 bool
304 xen_host_cpu_get_uuid(xen_session *session, char **result, xen_host_cpu host_cpu)
305 {
306 abstract_value param_values[] =
307 {
308 { .type = &abstract_type_string,
309 .u.string_val = host_cpu }
310 };
312 abstract_type result_type = abstract_type_string;
314 *result = NULL;
315 XEN_CALL_("host_cpu.get_uuid");
316 return session->ok;
317 }