ia64/xen-unstable

view tools/libxen/src/xen_console.c @ 14043:be35eed950da

Rename Console.uri to location. Xend already uses the latter.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Tue Feb 20 19:23:28 2007 +0000 (2007-02-20)
parents ea12d26877a4
children 988b90c6b4f3
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_vm.h"
30 XEN_FREE(xen_console)
31 XEN_SET_ALLOC_FREE(xen_console)
32 XEN_ALLOC(xen_console_record)
33 XEN_SET_ALLOC_FREE(xen_console_record)
34 XEN_ALLOC(xen_console_record_opt)
35 XEN_RECORD_OPT_FREE(xen_console)
36 XEN_SET_ALLOC_FREE(xen_console_record_opt)
39 static const struct_member xen_console_record_struct_members[] =
40 {
41 { .key = "uuid",
42 .type = &abstract_type_string,
43 .offset = offsetof(xen_console_record, uuid) },
44 { .key = "protocol",
45 .type = &xen_console_protocol_abstract_type_,
46 .offset = offsetof(xen_console_record, protocol) },
47 { .key = "location",
48 .type = &abstract_type_string,
49 .offset = offsetof(xen_console_record, location) },
50 { .key = "VM",
51 .type = &abstract_type_ref,
52 .offset = offsetof(xen_console_record, vm) }
53 };
55 const abstract_type xen_console_record_abstract_type_ =
56 {
57 .typename = STRUCT,
58 .struct_size = sizeof(xen_console_record),
59 .member_count =
60 sizeof(xen_console_record_struct_members) / sizeof(struct_member),
61 .members = xen_console_record_struct_members
62 };
65 void
66 xen_console_record_free(xen_console_record *record)
67 {
68 if (record == NULL)
69 {
70 return;
71 }
72 free(record->handle);
73 free(record->uuid);
74 free(record->location);
75 xen_vm_record_opt_free(record->vm);
76 free(record);
77 }
80 bool
81 xen_console_get_record(xen_session *session, xen_console_record **result, xen_console console)
82 {
83 abstract_value param_values[] =
84 {
85 { .type = &abstract_type_string,
86 .u.string_val = console }
87 };
89 abstract_type result_type = xen_console_record_abstract_type_;
91 *result = NULL;
92 XEN_CALL_("console.get_record");
94 if (session->ok)
95 {
96 (*result)->handle = xen_strdup_((*result)->uuid);
97 }
99 return session->ok;
100 }
103 bool
104 xen_console_get_by_uuid(xen_session *session, xen_console *result, char *uuid)
105 {
106 abstract_value param_values[] =
107 {
108 { .type = &abstract_type_string,
109 .u.string_val = uuid }
110 };
112 abstract_type result_type = abstract_type_string;
114 *result = NULL;
115 XEN_CALL_("console.get_by_uuid");
116 return session->ok;
117 }
120 bool
121 xen_console_create(xen_session *session, xen_console *result, xen_console_record *record)
122 {
123 abstract_value param_values[] =
124 {
125 { .type = &xen_console_record_abstract_type_,
126 .u.struct_val = record }
127 };
129 abstract_type result_type = abstract_type_string;
131 *result = NULL;
132 XEN_CALL_("console.create");
133 return session->ok;
134 }
137 bool
138 xen_console_destroy(xen_session *session, xen_console console)
139 {
140 abstract_value param_values[] =
141 {
142 { .type = &abstract_type_string,
143 .u.string_val = console }
144 };
146 xen_call_(session, "console.destroy", param_values, 1, NULL, NULL);
147 return session->ok;
148 }
151 bool
152 xen_console_get_protocol(xen_session *session, enum xen_console_protocol *result, xen_console console)
153 {
154 abstract_value param_values[] =
155 {
156 { .type = &abstract_type_string,
157 .u.string_val = console }
158 };
160 abstract_type result_type = xen_console_protocol_abstract_type_;
161 XEN_CALL_("console.get_protocol");
162 return session->ok;
163 }
166 bool
167 xen_console_get_location(xen_session *session, char **result, xen_console console)
168 {
169 abstract_value param_values[] =
170 {
171 { .type = &abstract_type_string,
172 .u.string_val = console }
173 };
175 abstract_type result_type = abstract_type_string;
177 *result = NULL;
178 XEN_CALL_("console.get_location");
179 return session->ok;
180 }
183 bool
184 xen_console_get_vm(xen_session *session, xen_vm *result, xen_console console)
185 {
186 abstract_value param_values[] =
187 {
188 { .type = &abstract_type_string,
189 .u.string_val = console }
190 };
192 abstract_type result_type = abstract_type_string;
194 *result = NULL;
195 XEN_CALL_("console.get_VM");
196 return session->ok;
197 }
200 bool
201 xen_console_get_uuid(xen_session *session, char **result, xen_console console)
202 {
203 *result = session->ok ? xen_strdup_((char *)console) : NULL;
204 return session->ok;
205 }