debuggers.hg

view tools/libxen/src/xen_vm_guest_metrics.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_string_string_map.h>
26 #include <xen/api/xen_vm_guest_metrics.h>
29 XEN_FREE(xen_vm_guest_metrics)
30 XEN_SET_ALLOC_FREE(xen_vm_guest_metrics)
31 XEN_ALLOC(xen_vm_guest_metrics_record)
32 XEN_SET_ALLOC_FREE(xen_vm_guest_metrics_record)
33 XEN_ALLOC(xen_vm_guest_metrics_record_opt)
34 XEN_RECORD_OPT_FREE(xen_vm_guest_metrics)
35 XEN_SET_ALLOC_FREE(xen_vm_guest_metrics_record_opt)
38 static const struct_member xen_vm_guest_metrics_record_struct_members[] =
39 {
40 { .key = "uuid",
41 .type = &abstract_type_string,
42 .offset = offsetof(xen_vm_guest_metrics_record, uuid) },
43 { .key = "os_version",
44 .type = &abstract_type_string_string_map,
45 .offset = offsetof(xen_vm_guest_metrics_record, os_version) },
46 { .key = "PV_drivers_version",
47 .type = &abstract_type_string_string_map,
48 .offset = offsetof(xen_vm_guest_metrics_record, pv_drivers_version) },
49 { .key = "memory",
50 .type = &abstract_type_string_string_map,
51 .offset = offsetof(xen_vm_guest_metrics_record, memory) },
52 { .key = "disks",
53 .type = &abstract_type_string_string_map,
54 .offset = offsetof(xen_vm_guest_metrics_record, disks) },
55 { .key = "networks",
56 .type = &abstract_type_string_string_map,
57 .offset = offsetof(xen_vm_guest_metrics_record, networks) },
58 { .key = "other",
59 .type = &abstract_type_string_string_map,
60 .offset = offsetof(xen_vm_guest_metrics_record, other) },
61 { .key = "last_updated",
62 .type = &abstract_type_datetime,
63 .offset = offsetof(xen_vm_guest_metrics_record, last_updated) }
64 };
66 const abstract_type xen_vm_guest_metrics_record_abstract_type_ =
67 {
68 .typename = STRUCT,
69 .struct_size = sizeof(xen_vm_guest_metrics_record),
70 .member_count =
71 sizeof(xen_vm_guest_metrics_record_struct_members) / sizeof(struct_member),
72 .members = xen_vm_guest_metrics_record_struct_members
73 };
76 void
77 xen_vm_guest_metrics_record_free(xen_vm_guest_metrics_record *record)
78 {
79 if (record == NULL)
80 {
81 return;
82 }
83 free(record->handle);
84 free(record->uuid);
85 xen_string_string_map_free(record->os_version);
86 xen_string_string_map_free(record->pv_drivers_version);
87 xen_string_string_map_free(record->memory);
88 xen_string_string_map_free(record->disks);
89 xen_string_string_map_free(record->networks);
90 xen_string_string_map_free(record->other);
91 free(record);
92 }
95 bool
96 xen_vm_guest_metrics_get_record(xen_session *session, xen_vm_guest_metrics_record **result, xen_vm_guest_metrics vm_guest_metrics)
97 {
98 abstract_value param_values[] =
99 {
100 { .type = &abstract_type_string,
101 .u.string_val = vm_guest_metrics }
102 };
104 abstract_type result_type = xen_vm_guest_metrics_record_abstract_type_;
106 *result = NULL;
107 XEN_CALL_("VM_guest_metrics.get_record");
109 if (session->ok)
110 {
111 (*result)->handle = xen_strdup_((*result)->uuid);
112 }
114 return session->ok;
115 }
118 bool
119 xen_vm_guest_metrics_get_by_uuid(xen_session *session, xen_vm_guest_metrics *result, char *uuid)
120 {
121 abstract_value param_values[] =
122 {
123 { .type = &abstract_type_string,
124 .u.string_val = uuid }
125 };
127 abstract_type result_type = abstract_type_string;
129 *result = NULL;
130 XEN_CALL_("VM_guest_metrics.get_by_uuid");
131 return session->ok;
132 }
135 bool
136 xen_vm_guest_metrics_get_os_version(xen_session *session, xen_string_string_map **result, xen_vm_guest_metrics vm_guest_metrics)
137 {
138 abstract_value param_values[] =
139 {
140 { .type = &abstract_type_string,
141 .u.string_val = vm_guest_metrics }
142 };
144 abstract_type result_type = abstract_type_string_string_map;
146 *result = NULL;
147 XEN_CALL_("VM_guest_metrics.get_os_version");
148 return session->ok;
149 }
152 bool
153 xen_vm_guest_metrics_get_pv_drivers_version(xen_session *session, xen_string_string_map **result, xen_vm_guest_metrics vm_guest_metrics)
154 {
155 abstract_value param_values[] =
156 {
157 { .type = &abstract_type_string,
158 .u.string_val = vm_guest_metrics }
159 };
161 abstract_type result_type = abstract_type_string_string_map;
163 *result = NULL;
164 XEN_CALL_("VM_guest_metrics.get_PV_drivers_version");
165 return session->ok;
166 }
169 bool
170 xen_vm_guest_metrics_get_memory(xen_session *session, xen_string_string_map **result, xen_vm_guest_metrics vm_guest_metrics)
171 {
172 abstract_value param_values[] =
173 {
174 { .type = &abstract_type_string,
175 .u.string_val = vm_guest_metrics }
176 };
178 abstract_type result_type = abstract_type_string_string_map;
180 *result = NULL;
181 XEN_CALL_("VM_guest_metrics.get_memory");
182 return session->ok;
183 }
186 bool
187 xen_vm_guest_metrics_get_disks(xen_session *session, xen_string_string_map **result, xen_vm_guest_metrics vm_guest_metrics)
188 {
189 abstract_value param_values[] =
190 {
191 { .type = &abstract_type_string,
192 .u.string_val = vm_guest_metrics }
193 };
195 abstract_type result_type = abstract_type_string_string_map;
197 *result = NULL;
198 XEN_CALL_("VM_guest_metrics.get_disks");
199 return session->ok;
200 }
203 bool
204 xen_vm_guest_metrics_get_networks(xen_session *session, xen_string_string_map **result, xen_vm_guest_metrics vm_guest_metrics)
205 {
206 abstract_value param_values[] =
207 {
208 { .type = &abstract_type_string,
209 .u.string_val = vm_guest_metrics }
210 };
212 abstract_type result_type = abstract_type_string_string_map;
214 *result = NULL;
215 XEN_CALL_("VM_guest_metrics.get_networks");
216 return session->ok;
217 }
220 bool
221 xen_vm_guest_metrics_get_other(xen_session *session, xen_string_string_map **result, xen_vm_guest_metrics vm_guest_metrics)
222 {
223 abstract_value param_values[] =
224 {
225 { .type = &abstract_type_string,
226 .u.string_val = vm_guest_metrics }
227 };
229 abstract_type result_type = abstract_type_string_string_map;
231 *result = NULL;
232 XEN_CALL_("VM_guest_metrics.get_other");
233 return session->ok;
234 }
237 bool
238 xen_vm_guest_metrics_get_last_updated(xen_session *session, time_t *result, xen_vm_guest_metrics vm_guest_metrics)
239 {
240 abstract_value param_values[] =
241 {
242 { .type = &abstract_type_string,
243 .u.string_val = vm_guest_metrics }
244 };
246 abstract_type result_type = abstract_type_datetime;
248 XEN_CALL_("VM_guest_metrics.get_last_updated");
249 return session->ok;
250 }
253 bool
254 xen_vm_guest_metrics_get_all(xen_session *session, struct xen_vm_guest_metrics_set **result)
255 {
257 abstract_type result_type = abstract_type_string_set;
259 *result = NULL;
260 xen_call_(session, "VM_guest_metrics.get_all", NULL, 0, &result_type, result);
261 return session->ok;
262 }
265 bool
266 xen_vm_guest_metrics_get_uuid(xen_session *session, char **result, xen_vm_guest_metrics vm_guest_metrics)
267 {
268 abstract_value param_values[] =
269 {
270 { .type = &abstract_type_string,
271 .u.string_val = vm_guest_metrics }
272 };
274 abstract_type result_type = abstract_type_string;
276 *result = NULL;
277 XEN_CALL_("VM_guest_metrics.get_uuid");
278 return session->ok;
279 }