ia64/xen-unstable

view tools/libxen/src/xen_xspolicy.c @ 15862:1474db8058b2

[libxen] Compilation fix.

On a clean system where no prior dev. version of libxen was installed,
the compilation fails due to a wrong include. This fixes it.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
author kfraser@localhost.localdomain
date Mon Sep 10 13:59:46 2007 +0100 (2007-09-10)
parents f01cb504cf28
children 433f6a6a862a
line source
1 /*
2 * Copyright (c) 2007, IBM Corp.
3 * Copyright (c) 2007, XenSource Inc.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
21 #include <stddef.h>
22 #include <stdlib.h>
24 #include "xen_internal.h"
25 #include "xen/api/xen_common.h"
26 #include "xen/api/xen_xspolicy.h"
29 XEN_FREE(xen_xspolicy)
30 XEN_SET_ALLOC_FREE(xen_xspolicy)
31 XEN_RECORD_OPT_FREE(xen_xspolicy)
33 static const struct_member xen_xspolicy_record_struct_members[] =
34 {
35 { .key = "uuid",
36 .type = &abstract_type_string,
37 .offset = offsetof(xen_xspolicy_record, uuid) },
38 { .key = "flags",
39 .type = &abstract_type_int,
40 .offset = offsetof(xen_xspolicy_record, flags) },
41 { .key = "repr",
42 .type = &abstract_type_string,
43 .offset = offsetof(xen_xspolicy_record, repr) },
44 { .key = "type",
45 .type = &abstract_type_int,
46 .offset = offsetof(xen_xspolicy_record, type) },
47 };
49 const abstract_type xen_xspolicy_record_abstract_type_ =
50 {
51 .typename = STRUCT,
52 .struct_size = sizeof(xen_xspolicy_record),
53 .member_count =
54 sizeof(xen_xspolicy_record_struct_members) / sizeof(struct_member),
55 .members = xen_xspolicy_record_struct_members
56 };
59 static const struct_member xen_xs_policystate_struct_members[] =
60 {
61 { .key = "xs_ref",
62 .type = &abstract_type_ref,
63 .offset = offsetof(xen_xs_policystate, xs_ref) },
64 { .key = "xserr",
65 .type = &abstract_type_int,
66 .offset = offsetof(xen_xs_policystate, xserr) },
67 { .key = "repr",
68 .type = &abstract_type_string,
69 .offset = offsetof(xen_xs_policystate, repr) },
70 { .key = "type",
71 .type = &abstract_type_int,
72 .offset = offsetof(xen_xs_policystate, type) },
73 { .key = "flags",
74 .type = &abstract_type_int,
75 .offset = offsetof(xen_xs_policystate, flags) },
76 { .key = "version",
77 .type = &abstract_type_string,
78 .offset = offsetof(xen_xs_policystate, version) },
79 { .key = "errors",
80 .type = &abstract_type_string,
81 .offset = offsetof(xen_xs_policystate, errors) },
82 };
84 const abstract_type xen_xs_policystate_abstract_type_ =
85 {
86 .typename = STRUCT,
87 .struct_size = sizeof(xen_xs_policystate),
88 .member_count =
89 sizeof(xen_xs_policystate_struct_members) /
90 sizeof(struct_member),
91 .members = xen_xs_policystate_struct_members,
92 };
97 void
98 xen_xs_policystate_free(xen_xs_policystate *state)
99 {
100 if (state == NULL)
101 {
102 return;
103 }
104 xen_xspolicy_record_opt_free(state->xs_ref);
105 free(state->repr);
106 free(state->errors);
107 free(state->version);
108 free(state);
109 }
112 void
113 xen_xspolicy_record_free(xen_xspolicy_record *record)
114 {
115 if (record == NULL)
116 {
117 return;
118 }
119 free(record->handle);
120 free(record->uuid);
121 free(record->repr);
122 free(record);
123 }
126 bool
127 xen_xspolicy_get_record(xen_session *session, xen_xspolicy_record **result,
128 xen_xspolicy xspolicy)
129 {
130 abstract_value param_values[] =
131 {
132 { .type = &abstract_type_string,
133 .u.string_val = xspolicy }
134 };
136 abstract_type result_type = xen_xspolicy_record_abstract_type_;
138 *result = NULL;
139 XEN_CALL_("XSPolicy.get_record");
141 if (session->ok)
142 {
143 (*result)->handle = xen_strdup_((*result)->uuid);
144 }
146 return session->ok;
147 }
150 bool
151 xen_xspolicy_get_uuid(xen_session *session, char **result,
152 xen_xspolicy xspolicy)
153 {
154 abstract_value param_values[] =
155 {
156 { .type = &abstract_type_string,
157 .u.string_val = xspolicy }
158 };
160 abstract_type result_type = abstract_type_string;
162 *result = NULL;
163 XEN_CALL_("XSPolicy.get_uuid");
164 return session->ok;
165 }
168 bool
169 xen_xspolicy_get_by_uuid(xen_session *session, xen_xspolicy *result,
170 char *uuid)
171 {
172 abstract_value param_values[] =
173 {
174 { .type = &abstract_type_string,
175 .u.string_val = uuid }
176 };
178 abstract_type result_type = abstract_type_string;
180 *result = NULL;
181 XEN_CALL_("XSPolicy.get_by_uuid");
182 return session->ok;
183 }
186 bool
187 xen_xspolicy_get_xstype(xen_session *session, xs_type *result)
188 {
189 abstract_value param_values[] =
190 {
191 };
193 abstract_type result_type = abstract_type_int;
195 *result = 0;
196 XEN_CALL_("XSPolicy.get_xstype");
197 return session->ok;
198 }
201 bool
202 xen_xspolicy_set_xspolicy(xen_session *session, xen_xs_policystate **result,
203 xs_type type, char *repr,
204 xs_instantiationflags flags,
205 bool overwrite)
206 {
207 abstract_value param_values[] =
208 {
209 { .type = &abstract_type_int,
210 .u.int_val = type },
211 { .type = &abstract_type_string,
212 .u.string_val = repr },
213 { .type = &abstract_type_int,
214 .u.int_val = flags },
215 { .type = &abstract_type_bool,
216 .u.bool_val = overwrite }
217 };
219 abstract_type result_type = xen_xs_policystate_abstract_type_;
221 *result = NULL;
222 XEN_CALL_("XSPolicy.set_xspolicy");
223 return session->ok;
224 }
227 bool
228 xen_xspolicy_get_xspolicy(xen_session *session, xen_xs_policystate **result)
229 {
230 abstract_value param_values[] =
231 {
232 };
234 abstract_type result_type = xen_xs_policystate_abstract_type_;
236 *result = NULL;
237 XEN_CALL_("XSPolicy.get_xspolicy");
238 return session->ok;
239 }
242 bool
243 xen_xspolicy_get_labeled_resources(xen_session *session,
244 xen_string_string_map **result)
245 {
246 abstract_value param_values[] =
247 {
248 };
250 abstract_type result_type = abstract_type_string_string_map;
252 *result = NULL;
253 XEN_CALL_("XSPolicy.get_labeled_resources");
254 return session->ok;
255 }
258 bool
259 xen_xspolicy_set_resource_label(xen_session *session,
260 char *resource, char *label,
261 char *oldlabel)
262 {
263 abstract_value param_values[] =
264 {
265 { .type = &abstract_type_string,
266 .u.string_val = resource },
267 { .type = &abstract_type_string,
268 .u.string_val = label },
269 { .type = &abstract_type_string,
270 .u.string_val = oldlabel },
271 };
273 xen_call_(session, "XSPolicy.set_resource_label", param_values, 3,
274 NULL, NULL);
275 return session->ok;
276 }
279 bool
280 xen_xspolicy_get_resource_label(xen_session *session, char **result,
281 char *resource)
282 {
283 abstract_value param_values[] =
284 {
285 { .type = &abstract_type_string,
286 .u.string_val = resource },
287 };
289 abstract_type result_type = abstract_type_string;
290 XEN_CALL_("XSPolicy.get_resource_label");
291 return session->ok;
292 }
295 bool
296 xen_xspolicy_rm_xsbootpolicy(xen_session *session)
297 {
298 abstract_value param_values[] =
299 {
300 };
302 xen_call_(session, "XSPolicy.rm_xsbootpolicy", param_values, 0,
303 NULL, NULL);
304 return session->ok;
305 }
308 bool
309 xen_xspolicy_activate_xspolicy(xen_session *session,
310 xs_instantiationflags *result,
311 xen_xspolicy xspolicy,
312 xs_instantiationflags flags)
313 {
314 abstract_value param_values[] =
315 {
316 { .type = &abstract_type_string,
317 .u.string_val = xspolicy },
318 { .type = &abstract_type_int,
319 .u.int_val = flags },
320 };
322 abstract_type result_type = abstract_type_int;
324 *result = 0;
325 XEN_CALL_("XSPolicy.activate_xspolicy");
326 return session->ok;
327 }