ia64/xen-unstable

view tools/libxen/include/xen_vdi.h @ 14045:7819d9332fba

Split the VBD I/O statistics out into a VBD_metrics class. Document the
VBD.type field, and add it to the C bindings (this was already in Xend).

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Tue Feb 20 21:28:19 2007 +0000 (2007-02-20)
parents beb0b36de156
children 42dd9055ee1f
line source
1 /*
2 * Copyright (c) 2006, 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_VDI_H
20 #define XEN_VDI_H
22 #include "xen_common.h"
23 #include "xen_crashdump_decl.h"
24 #include "xen_sr_decl.h"
25 #include "xen_vbd_decl.h"
26 #include "xen_vdi_decl.h"
27 #include "xen_vdi_type.h"
30 /*
31 * The VDI class.
32 *
33 * A virtual disk image.
34 */
37 /**
38 * Free the given xen_vdi. The given handle must have been allocated
39 * by this library.
40 */
41 extern void
42 xen_vdi_free(xen_vdi vdi);
45 typedef struct xen_vdi_set
46 {
47 size_t size;
48 xen_vdi *contents[];
49 } xen_vdi_set;
51 /**
52 * Allocate a xen_vdi_set of the given size.
53 */
54 extern xen_vdi_set *
55 xen_vdi_set_alloc(size_t size);
57 /**
58 * Free the given xen_vdi_set. The given set must have been allocated
59 * by this library.
60 */
61 extern void
62 xen_vdi_set_free(xen_vdi_set *set);
65 typedef struct xen_vdi_record
66 {
67 xen_vdi handle;
68 char *uuid;
69 char *name_label;
70 char *name_description;
71 struct xen_sr_record_opt *sr;
72 struct xen_vbd_record_opt_set *vbds;
73 struct xen_crashdump_record_opt_set *crash_dumps;
74 int64_t virtual_size;
75 int64_t physical_utilisation;
76 int64_t sector_size;
77 char *location;
78 enum xen_vdi_type type;
79 bool sharable;
80 bool read_only;
81 } xen_vdi_record;
83 /**
84 * Allocate a xen_vdi_record.
85 */
86 extern xen_vdi_record *
87 xen_vdi_record_alloc(void);
89 /**
90 * Free the given xen_vdi_record, and all referenced values. The given
91 * record must have been allocated by this library.
92 */
93 extern void
94 xen_vdi_record_free(xen_vdi_record *record);
97 typedef struct xen_vdi_record_opt
98 {
99 bool is_record;
100 union
101 {
102 xen_vdi handle;
103 xen_vdi_record *record;
104 } u;
105 } xen_vdi_record_opt;
107 /**
108 * Allocate a xen_vdi_record_opt.
109 */
110 extern xen_vdi_record_opt *
111 xen_vdi_record_opt_alloc(void);
113 /**
114 * Free the given xen_vdi_record_opt, and all referenced values. The
115 * given record_opt must have been allocated by this library.
116 */
117 extern void
118 xen_vdi_record_opt_free(xen_vdi_record_opt *record_opt);
121 typedef struct xen_vdi_record_set
122 {
123 size_t size;
124 xen_vdi_record *contents[];
125 } xen_vdi_record_set;
127 /**
128 * Allocate a xen_vdi_record_set of the given size.
129 */
130 extern xen_vdi_record_set *
131 xen_vdi_record_set_alloc(size_t size);
133 /**
134 * Free the given xen_vdi_record_set, and all referenced values. The
135 * given set must have been allocated by this library.
136 */
137 extern void
138 xen_vdi_record_set_free(xen_vdi_record_set *set);
142 typedef struct xen_vdi_record_opt_set
143 {
144 size_t size;
145 xen_vdi_record_opt *contents[];
146 } xen_vdi_record_opt_set;
148 /**
149 * Allocate a xen_vdi_record_opt_set of the given size.
150 */
151 extern xen_vdi_record_opt_set *
152 xen_vdi_record_opt_set_alloc(size_t size);
154 /**
155 * Free the given xen_vdi_record_opt_set, and all referenced values.
156 * The given set must have been allocated by this library.
157 */
158 extern void
159 xen_vdi_record_opt_set_free(xen_vdi_record_opt_set *set);
162 /**
163 * Get a record containing the current state of the given VDI.
164 */
165 extern bool
166 xen_vdi_get_record(xen_session *session, xen_vdi_record **result, xen_vdi vdi);
169 /**
170 * Get a reference to the VDI instance with the specified UUID.
171 */
172 extern bool
173 xen_vdi_get_by_uuid(xen_session *session, xen_vdi *result, char *uuid);
176 /**
177 * Create a new VDI instance, and return its handle.
178 */
179 extern bool
180 xen_vdi_create(xen_session *session, xen_vdi *result, xen_vdi_record *record);
183 /**
184 * Destroy the specified VDI instance.
185 */
186 extern bool
187 xen_vdi_destroy(xen_session *session, xen_vdi vdi);
190 /**
191 * Get all the VDI instances with the given label.
192 */
193 extern bool
194 xen_vdi_get_by_name_label(xen_session *session, struct xen_vdi_set **result, char *label);
197 /**
198 * Get the uuid field of the given VDI.
199 */
200 extern bool
201 xen_vdi_get_uuid(xen_session *session, char **result, xen_vdi vdi);
204 /**
205 * Get the name/label field of the given VDI.
206 */
207 extern bool
208 xen_vdi_get_name_label(xen_session *session, char **result, xen_vdi vdi);
211 /**
212 * Get the name/description field of the given VDI.
213 */
214 extern bool
215 xen_vdi_get_name_description(xen_session *session, char **result, xen_vdi vdi);
218 /**
219 * Get the SR field of the given VDI.
220 */
221 extern bool
222 xen_vdi_get_sr(xen_session *session, xen_sr *result, xen_vdi vdi);
225 /**
226 * Get the VBDs field of the given VDI.
227 */
228 extern bool
229 xen_vdi_get_vbds(xen_session *session, struct xen_vbd_set **result, xen_vdi vdi);
232 /**
233 * Get the crash_dumps field of the given VDI.
234 */
235 extern bool
236 xen_vdi_get_crash_dumps(xen_session *session, struct xen_crashdump_set **result, xen_vdi vdi);
239 /**
240 * Get the virtual_size field of the given VDI.
241 */
242 extern bool
243 xen_vdi_get_virtual_size(xen_session *session, int64_t *result, xen_vdi vdi);
246 /**
247 * Get the physical_utilisation field of the given VDI.
248 */
249 extern bool
250 xen_vdi_get_physical_utilisation(xen_session *session, int64_t *result, xen_vdi vdi);
253 /**
254 * Get the sector_size field of the given VDI.
255 */
256 extern bool
257 xen_vdi_get_sector_size(xen_session *session, int64_t *result, xen_vdi vdi);
260 /**
261 * Get the type field of the given VDI.
262 */
263 extern bool
264 xen_vdi_get_type(xen_session *session, enum xen_vdi_type *result, xen_vdi vdi);
267 /**
268 * Get the sharable field of the given VDI.
269 */
270 extern bool
271 xen_vdi_get_sharable(xen_session *session, bool *result, xen_vdi vdi);
274 /**
275 * Get the read_only field of the given VDI.
276 */
277 extern bool
278 xen_vdi_get_read_only(xen_session *session, bool *result, xen_vdi vdi);
281 /**
282 * Set the name/label field of the given VDI.
283 */
284 extern bool
285 xen_vdi_set_name_label(xen_session *session, xen_vdi vdi, char *label);
288 /**
289 * Set the name/description field of the given VDI.
290 */
291 extern bool
292 xen_vdi_set_name_description(xen_session *session, xen_vdi vdi, char *description);
295 /**
296 * Set the SR field of the given VDI.
297 */
298 extern bool
299 xen_vdi_set_sr(xen_session *session, xen_vdi vdi, xen_sr sr);
302 /**
303 * Set the virtual_size field of the given VDI.
304 */
305 extern bool
306 xen_vdi_set_virtual_size(xen_session *session, xen_vdi vdi, int64_t virtual_size);
309 /**
310 * Set the sharable field of the given VDI.
311 */
312 extern bool
313 xen_vdi_set_sharable(xen_session *session, xen_vdi vdi, bool sharable);
316 /**
317 * Set the read_only field of the given VDI.
318 */
319 extern bool
320 xen_vdi_set_read_only(xen_session *session, xen_vdi vdi, bool read_only);
323 /**
324 * Take an exact copy of the VDI; the snapshot lives in the same
325 * Storage Repository as its parent.
326 */
327 extern bool
328 xen_vdi_snapshot(xen_session *session, xen_vdi *result, xen_vdi vdi);
331 /**
332 * Resize the vdi to the size.
333 */
334 extern bool
335 xen_vdi_resize(xen_session *session, xen_vdi vdi, int64_t size);
338 #endif