ia64/xen-unstable

view tools/libxen/include/xen_vbd.h @ 14116:fd7f23e44b11

Added VBD. and VIF.qos_supported_algorithms fields, with C bindings, Xend
implementation to follow.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Wed Feb 21 23:03:00 2007 +0000 (2007-02-21)
parents bab07bed5c0a
children cfd23ac1b32a
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 */
19 #ifndef XEN_VBD_H
20 #define XEN_VBD_H
22 #include "xen_common.h"
23 #include "xen_string_set.h"
24 #include "xen_string_string_map.h"
25 #include "xen_vbd_decl.h"
26 #include "xen_vbd_metrics_decl.h"
27 #include "xen_vbd_mode.h"
28 #include "xen_vbd_type.h"
29 #include "xen_vdi_decl.h"
30 #include "xen_vm_decl.h"
33 /*
34 * The VBD class.
35 *
36 * A virtual block device.
37 */
40 /**
41 * Free the given xen_vbd. The given handle must have been allocated
42 * by this library.
43 */
44 extern void
45 xen_vbd_free(xen_vbd vbd);
48 typedef struct xen_vbd_set
49 {
50 size_t size;
51 xen_vbd *contents[];
52 } xen_vbd_set;
54 /**
55 * Allocate a xen_vbd_set of the given size.
56 */
57 extern xen_vbd_set *
58 xen_vbd_set_alloc(size_t size);
60 /**
61 * Free the given xen_vbd_set. The given set must have been allocated
62 * by this library.
63 */
64 extern void
65 xen_vbd_set_free(xen_vbd_set *set);
68 typedef struct xen_vbd_record
69 {
70 xen_vbd handle;
71 char *uuid;
72 struct xen_vm_record_opt *vm;
73 struct xen_vdi_record_opt *vdi;
74 char *device;
75 char *image;
76 bool bootable;
77 enum xen_vbd_mode mode;
78 enum xen_vbd_type type;
79 char *qos_algorithm_type;
80 xen_string_string_map *qos_algorithm_params;
81 struct xen_string_set *qos_supported_algorithms;
82 struct xen_vbd_metrics_record_opt *metrics;
83 } xen_vbd_record;
85 /**
86 * Allocate a xen_vbd_record.
87 */
88 extern xen_vbd_record *
89 xen_vbd_record_alloc(void);
91 /**
92 * Free the given xen_vbd_record, and all referenced values. The given
93 * record must have been allocated by this library.
94 */
95 extern void
96 xen_vbd_record_free(xen_vbd_record *record);
99 typedef struct xen_vbd_record_opt
100 {
101 bool is_record;
102 union
103 {
104 xen_vbd handle;
105 xen_vbd_record *record;
106 } u;
107 } xen_vbd_record_opt;
109 /**
110 * Allocate a xen_vbd_record_opt.
111 */
112 extern xen_vbd_record_opt *
113 xen_vbd_record_opt_alloc(void);
115 /**
116 * Free the given xen_vbd_record_opt, and all referenced values. The
117 * given record_opt must have been allocated by this library.
118 */
119 extern void
120 xen_vbd_record_opt_free(xen_vbd_record_opt *record_opt);
123 typedef struct xen_vbd_record_set
124 {
125 size_t size;
126 xen_vbd_record *contents[];
127 } xen_vbd_record_set;
129 /**
130 * Allocate a xen_vbd_record_set of the given size.
131 */
132 extern xen_vbd_record_set *
133 xen_vbd_record_set_alloc(size_t size);
135 /**
136 * Free the given xen_vbd_record_set, and all referenced values. The
137 * given set must have been allocated by this library.
138 */
139 extern void
140 xen_vbd_record_set_free(xen_vbd_record_set *set);
144 typedef struct xen_vbd_record_opt_set
145 {
146 size_t size;
147 xen_vbd_record_opt *contents[];
148 } xen_vbd_record_opt_set;
150 /**
151 * Allocate a xen_vbd_record_opt_set of the given size.
152 */
153 extern xen_vbd_record_opt_set *
154 xen_vbd_record_opt_set_alloc(size_t size);
156 /**
157 * Free the given xen_vbd_record_opt_set, and all referenced values.
158 * The given set must have been allocated by this library.
159 */
160 extern void
161 xen_vbd_record_opt_set_free(xen_vbd_record_opt_set *set);
164 /**
165 * Get a record containing the current state of the given VBD.
166 */
167 extern bool
168 xen_vbd_get_record(xen_session *session, xen_vbd_record **result, xen_vbd vbd);
171 /**
172 * Get a reference to the VBD instance with the specified UUID.
173 */
174 extern bool
175 xen_vbd_get_by_uuid(xen_session *session, xen_vbd *result, char *uuid);
178 /**
179 * Create a new VBD instance, and return its handle.
180 */
181 extern bool
182 xen_vbd_create(xen_session *session, xen_vbd *result, xen_vbd_record *record);
185 /**
186 * Destroy the specified VBD instance.
187 */
188 extern bool
189 xen_vbd_destroy(xen_session *session, xen_vbd vbd);
192 /**
193 * Get the uuid field of the given VBD.
194 */
195 extern bool
196 xen_vbd_get_uuid(xen_session *session, char **result, xen_vbd vbd);
199 /**
200 * Get the VM field of the given VBD.
201 */
202 extern bool
203 xen_vbd_get_vm(xen_session *session, xen_vm *result, xen_vbd vbd);
206 /**
207 * Get the VDI field of the given VBD.
208 */
209 extern bool
210 xen_vbd_get_vdi(xen_session *session, xen_vdi *result, xen_vbd vbd);
213 /**
214 * Get the device field of the given VBD.
215 */
216 extern bool
217 xen_vbd_get_device(xen_session *session, char **result, xen_vbd vbd);
220 /**
221 * Get the bootable field of the given VBD.
222 */
223 extern bool
224 xen_vbd_get_bootable(xen_session *session, bool *result, xen_vbd vbd);
227 /**
228 * Get the mode field of the given VBD.
229 */
230 extern bool
231 xen_vbd_get_mode(xen_session *session, enum xen_vbd_mode *result, xen_vbd vbd);
234 /**
235 * Get the type field of the given VBD.
236 */
237 extern bool
238 xen_vbd_get_type(xen_session *session, enum xen_vbd_type *result, xen_vbd vbd);
241 /**
242 * Get the qos/algorithm_type field of the given VBD.
243 */
244 extern bool
245 xen_vbd_get_qos_algorithm_type(xen_session *session, char **result, xen_vbd vbd);
248 /**
249 * Get the qos/algorithm_params field of the given VBD.
250 */
251 extern bool
252 xen_vbd_get_qos_algorithm_params(xen_session *session, xen_string_string_map **result, xen_vbd vbd);
255 /**
256 * Get the qos/supported_algorithms field of the given VBD.
257 */
258 extern bool
259 xen_vbd_get_qos_supported_algorithms(xen_session *session, struct xen_string_set **result, xen_vbd vbd);
262 /**
263 * Get the metrics field of the given VBD.
264 */
265 extern bool
266 xen_vbd_get_metrics(xen_session *session, xen_vbd_metrics *result, xen_vbd vbd);
269 /**
270 * Set the device field of the given VBD.
271 */
272 extern bool
273 xen_vbd_set_device(xen_session *session, xen_vbd vbd, char *device);
276 /**
277 * Set the bootable field of the given VBD.
278 */
279 extern bool
280 xen_vbd_set_bootable(xen_session *session, xen_vbd vbd, bool bootable);
283 /**
284 * Set the mode field of the given VBD.
285 */
286 extern bool
287 xen_vbd_set_mode(xen_session *session, xen_vbd vbd, enum xen_vbd_mode mode);
290 /**
291 * Set the type field of the given VBD.
292 */
293 extern bool
294 xen_vbd_set_type(xen_session *session, xen_vbd vbd, enum xen_vbd_type type);
297 /**
298 * Set the qos/algorithm_type field of the given VBD.
299 */
300 extern bool
301 xen_vbd_set_qos_algorithm_type(xen_session *session, xen_vbd vbd, char *algorithm_type);
304 /**
305 * Set the qos/algorithm_params field of the given VBD.
306 */
307 extern bool
308 xen_vbd_set_qos_algorithm_params(xen_session *session, xen_vbd vbd, xen_string_string_map *algorithm_params);
311 /**
312 * Add the given key-value pair to the qos/algorithm_params field of
313 * the given VBD.
314 */
315 extern bool
316 xen_vbd_add_to_qos_algorithm_params(xen_session *session, xen_vbd vbd, char *key, char *value);
319 /**
320 * Remove the given key and its corresponding value from the
321 * qos/algorithm_params field of the given VBD. If the key is not in that
322 * Map, then do nothing.
323 */
324 extern bool
325 xen_vbd_remove_from_qos_algorithm_params(xen_session *session, xen_vbd vbd, char *key);
328 /**
329 * Change the media in the device for CDROM-like devices only. For
330 * other devices, detach the VBD and attach a new one
331 */
332 extern bool
333 xen_vbd_media_change(xen_session *session, xen_vbd vbd, xen_vdi vdi);
336 #endif