ia64/xen-unstable

view tools/libxen/src/xen_console.c @ 14044:988b90c6b4f3

Added Console.other_config to the docs (Xend already has this).

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Tue Feb 20 19:38:24 2007 +0000 (2007-02-20)
parents be35eed950da
children 42dd9055ee1f
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_common.h"
24 #include "xen_console.h"
25 #include "xen_console_protocol_internal.h"
26 #include "xen_internal.h"
27 #include "xen_string_string_map.h"
28 #include "xen_vm.h"
31 XEN_FREE(xen_console)
32 XEN_SET_ALLOC_FREE(xen_console)
33 XEN_ALLOC(xen_console_record)
34 XEN_SET_ALLOC_FREE(xen_console_record)
35 XEN_ALLOC(xen_console_record_opt)
36 XEN_RECORD_OPT_FREE(xen_console)
37 XEN_SET_ALLOC_FREE(xen_console_record_opt)
40 static const struct_member xen_console_record_struct_members[] =
41 {
42 { .key = "uuid",
43 .type = &abstract_type_string,
44 .offset = offsetof(xen_console_record, uuid) },
45 { .key = "protocol",
46 .type = &xen_console_protocol_abstract_type_,
47 .offset = offsetof(xen_console_record, protocol) },
48 { .key = "location",
49 .type = &abstract_type_string,
50 .offset = offsetof(xen_console_record, location) },
51 { .key = "VM",
52 .type = &abstract_type_ref,
53 .offset = offsetof(xen_console_record, vm) },
54 { .key = "other_config",
55 .type = &abstract_type_string_string_map,
56 .offset = offsetof(xen_console_record, other_config) }
57 };
59 const abstract_type xen_console_record_abstract_type_ =
60 {
61 .typename = STRUCT,
62 .struct_size = sizeof(xen_console_record),
63 .member_count =
64 sizeof(xen_console_record_struct_members) / sizeof(struct_member),
65 .members = xen_console_record_struct_members
66 };
69 void
70 xen_console_record_free(xen_console_record *record)
71 {
72 if (record == NULL)
73 {
74 return;
75 }
76 free(record->handle);
77 free(record->uuid);
78 free(record->location);
79 xen_vm_record_opt_free(record->vm);
80 xen_string_string_map_free(record->other_config);
81 free(record);
82 }
85 bool
86 xen_console_get_record(xen_session *session, xen_console_record **result, xen_console console)
87 {
88 abstract_value param_values[] =
89 {
90 { .type = &abstract_type_string,
91 .u.string_val = console }
92 };
94 abstract_type result_type = xen_console_record_abstract_type_;
96 *result = NULL;
97 XEN_CALL_("console.get_record");
99 if (session->ok)
100 {
101 (*result)->handle = xen_strdup_((*result)->uuid);
102 }
104 return session->ok;
105 }
108 bool
109 xen_console_get_by_uuid(xen_session *session, xen_console *result, char *uuid)
110 {
111 abstract_value param_values[] =
112 {
113 { .type = &abstract_type_string,
114 .u.string_val = uuid }
115 };
117 abstract_type result_type = abstract_type_string;
119 *result = NULL;
120 XEN_CALL_("console.get_by_uuid");
121 return session->ok;
122 }
125 bool
126 xen_console_create(xen_session *session, xen_console *result, xen_console_record *record)
127 {
128 abstract_value param_values[] =
129 {
130 { .type = &xen_console_record_abstract_type_,
131 .u.struct_val = record }
132 };
134 abstract_type result_type = abstract_type_string;
136 *result = NULL;
137 XEN_CALL_("console.create");
138 return session->ok;
139 }
142 bool
143 xen_console_destroy(xen_session *session, xen_console console)
144 {
145 abstract_value param_values[] =
146 {
147 { .type = &abstract_type_string,
148 .u.string_val = console }
149 };
151 xen_call_(session, "console.destroy", param_values, 1, NULL, NULL);
152 return session->ok;
153 }
156 bool
157 xen_console_get_protocol(xen_session *session, enum xen_console_protocol *result, xen_console console)
158 {
159 abstract_value param_values[] =
160 {
161 { .type = &abstract_type_string,
162 .u.string_val = console }
163 };
165 abstract_type result_type = xen_console_protocol_abstract_type_;
166 XEN_CALL_("console.get_protocol");
167 return session->ok;
168 }
171 bool
172 xen_console_get_location(xen_session *session, char **result, xen_console console)
173 {
174 abstract_value param_values[] =
175 {
176 { .type = &abstract_type_string,
177 .u.string_val = console }
178 };
180 abstract_type result_type = abstract_type_string;
182 *result = NULL;
183 XEN_CALL_("console.get_location");
184 return session->ok;
185 }
188 bool
189 xen_console_get_vm(xen_session *session, xen_vm *result, xen_console console)
190 {
191 abstract_value param_values[] =
192 {
193 { .type = &abstract_type_string,
194 .u.string_val = console }
195 };
197 abstract_type result_type = abstract_type_string;
199 *result = NULL;
200 XEN_CALL_("console.get_VM");
201 return session->ok;
202 }
205 bool
206 xen_console_get_other_config(xen_session *session, xen_string_string_map **result, xen_console console)
207 {
208 abstract_value param_values[] =
209 {
210 { .type = &abstract_type_string,
211 .u.string_val = console }
212 };
214 abstract_type result_type = abstract_type_string_string_map;
216 *result = NULL;
217 XEN_CALL_("console.get_other_config");
218 return session->ok;
219 }
222 bool
223 xen_console_set_other_config(xen_session *session, xen_console console, xen_string_string_map *other_config)
224 {
225 abstract_value param_values[] =
226 {
227 { .type = &abstract_type_string,
228 .u.string_val = console },
229 { .type = &abstract_type_string_string_map,
230 .u.set_val = (arbitrary_set *)other_config }
231 };
233 xen_call_(session, "console.set_other_config", param_values, 2, NULL, NULL);
234 return session->ok;
235 }
238 bool
239 xen_console_add_to_other_config(xen_session *session, xen_console console, char *key, char *value)
240 {
241 abstract_value param_values[] =
242 {
243 { .type = &abstract_type_string,
244 .u.string_val = console },
245 { .type = &abstract_type_string,
246 .u.string_val = key },
247 { .type = &abstract_type_string,
248 .u.string_val = value }
249 };
251 xen_call_(session, "console.add_to_other_config", param_values, 3, NULL, NULL);
252 return session->ok;
253 }
256 bool
257 xen_console_remove_from_other_config(xen_session *session, xen_console console, char *key)
258 {
259 abstract_value param_values[] =
260 {
261 { .type = &abstract_type_string,
262 .u.string_val = console },
263 { .type = &abstract_type_string,
264 .u.string_val = key }
265 };
267 xen_call_(session, "console.remove_from_other_config", param_values, 2, NULL, NULL);
268 return session->ok;
269 }
272 bool
273 xen_console_get_uuid(xen_session *session, char **result, xen_console console)
274 {
275 *result = session->ok ? xen_strdup_((char *)console) : NULL;
276 return session->ok;
277 }