ia64/xen-unstable

view tools/libxen/include/xen_vdi.h @ 12166:de31d79add5e

Implement VDI.resize message.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Thu Oct 26 15:57:29 2006 +0100 (2006-10-26)
parents c75716820107
children 0db0c19d3386
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_sr_decl.h"
24 #include "xen_vbd_decl.h"
25 #include "xen_vdi_decl.h"
26 #include "xen_vdi_type.h"
29 /*
30 * The VDI class.
31 *
32 * A virtual disk image.
33 */
36 /**
37 * Free the given xen_vdi. The given handle must have been allocated
38 * by this library.
39 */
40 extern void
41 xen_vdi_free(xen_vdi vdi);
44 typedef struct xen_vdi_set
45 {
46 size_t size;
47 xen_vdi *contents[];
48 } xen_vdi_set;
50 /**
51 * Allocate a xen_vdi_set of the given size.
52 */
53 extern xen_vdi_set *
54 xen_vdi_set_alloc(size_t size);
56 /**
57 * Free the given xen_vdi_set. The given set must have been allocated
58 * by this library.
59 */
60 extern void
61 xen_vdi_set_free(xen_vdi_set *set);
64 typedef struct xen_vdi_record
65 {
66 xen_vdi handle;
67 char *uuid;
68 char *name_label;
69 char *name_description;
70 struct xen_sr_record_opt *sr;
71 struct xen_vbd_record_opt_set *vbds;
72 uint64_t virtual_size;
73 uint64_t physical_utilisation;
74 uint64_t sector_size;
75 enum xen_vdi_type type;
76 struct xen_vdi_record_opt *parent;
77 struct xen_vdi_record_opt_set *children;
78 bool sharable;
79 bool read_only;
80 } xen_vdi_record;
82 /**
83 * Allocate a xen_vdi_record.
84 */
85 extern xen_vdi_record *
86 xen_vdi_record_alloc(void);
88 /**
89 * Free the given xen_vdi_record, and all referenced values. The given
90 * record must have been allocated by this library.
91 */
92 extern void
93 xen_vdi_record_free(xen_vdi_record *record);
96 typedef struct xen_vdi_record_opt
97 {
98 bool is_record;
99 union
100 {
101 xen_vdi handle;
102 xen_vdi_record *record;
103 } u;
104 } xen_vdi_record_opt;
106 /**
107 * Allocate a xen_vdi_record_opt.
108 */
109 extern xen_vdi_record_opt *
110 xen_vdi_record_opt_alloc(void);
112 /**
113 * Free the given xen_vdi_record_opt, and all referenced values. The
114 * given record_opt must have been allocated by this library.
115 */
116 extern void
117 xen_vdi_record_opt_free(xen_vdi_record_opt *record_opt);
120 typedef struct xen_vdi_record_set
121 {
122 size_t size;
123 xen_vdi_record *contents[];
124 } xen_vdi_record_set;
126 /**
127 * Allocate a xen_vdi_record_set of the given size.
128 */
129 extern xen_vdi_record_set *
130 xen_vdi_record_set_alloc(size_t size);
132 /**
133 * Free the given xen_vdi_record_set, and all referenced values. The
134 * given set must have been allocated by this library.
135 */
136 extern void
137 xen_vdi_record_set_free(xen_vdi_record_set *set);
141 typedef struct xen_vdi_record_opt_set
142 {
143 size_t size;
144 xen_vdi_record_opt *contents[];
145 } xen_vdi_record_opt_set;
147 /**
148 * Allocate a xen_vdi_record_opt_set of the given size.
149 */
150 extern xen_vdi_record_opt_set *
151 xen_vdi_record_opt_set_alloc(size_t size);
153 /**
154 * Free the given xen_vdi_record_opt_set, and all referenced values.
155 * The given set must have been allocated by this library.
156 */
157 extern void
158 xen_vdi_record_opt_set_free(xen_vdi_record_opt_set *set);
161 /**
162 * Get the current state of the given VDI. !!!
163 */
164 extern bool
165 xen_vdi_get_record(xen_session *session, xen_vdi_record **result, xen_vdi vdi);
168 /**
169 * Get a reference to the object with the specified UUID. !!!
170 */
171 extern bool
172 xen_vdi_get_by_uuid(xen_session *session, xen_vdi *result, char *uuid);
175 /**
176 * Create a new VDI instance, and return its handle.
177 */
178 extern bool
179 xen_vdi_create(xen_session *session, xen_vdi *result, xen_vdi_record *record);
182 /**
183 * Get a reference to the object with the specified label.
184 */
185 extern bool
186 xen_vdi_get_by_name_label(xen_session *session, xen_vdi *result, char *label);
189 /**
190 * Get the uuid field of the given VDI.
191 */
192 extern bool
193 xen_vdi_get_uuid(xen_session *session, char **result, xen_vdi vdi);
196 /**
197 * Get the name/label field of the given VDI.
198 */
199 extern bool
200 xen_vdi_get_name_label(xen_session *session, char **result, xen_vdi vdi);
203 /**
204 * Get the name/description field of the given VDI.
205 */
206 extern bool
207 xen_vdi_get_name_description(xen_session *session, char **result, xen_vdi vdi);
210 /**
211 * Get the SR field of the given VDI.
212 */
213 extern bool
214 xen_vdi_get_sr(xen_session *session, xen_sr *result, xen_vdi vdi);
217 /**
218 * Get the VBDs field of the given VDI.
219 */
220 extern bool
221 xen_vdi_get_vbds(xen_session *session, xen_vbd *result, xen_vdi vdi);
224 /**
225 * Get the virtual_size field of the given VDI.
226 */
227 extern bool
228 xen_vdi_get_virtual_size(xen_session *session, uint64_t *result, xen_vdi vdi);
231 /**
232 * Get the physical_utilisation field of the given VDI.
233 */
234 extern bool
235 xen_vdi_get_physical_utilisation(xen_session *session, uint64_t *result, xen_vdi vdi);
238 /**
239 * Get the sector_size field of the given VDI.
240 */
241 extern bool
242 xen_vdi_get_sector_size(xen_session *session, uint64_t *result, xen_vdi vdi);
245 /**
246 * Get the type field of the given VDI.
247 */
248 extern bool
249 xen_vdi_get_type(xen_session *session, enum xen_vdi_type *result, xen_vdi vdi);
252 /**
253 * Get the parent field of the given VDI.
254 */
255 extern bool
256 xen_vdi_get_parent(xen_session *session, xen_vdi *result, xen_vdi vdi);
259 /**
260 * Get the children field of the given VDI.
261 */
262 extern bool
263 xen_vdi_get_children(xen_session *session, xen_vdi *result, xen_vdi vdi);
266 /**
267 * Get the sharable field of the given VDI.
268 */
269 extern bool
270 xen_vdi_get_sharable(xen_session *session, bool *result, xen_vdi vdi);
273 /**
274 * Get the read_only field of the given VDI.
275 */
276 extern bool
277 xen_vdi_get_read_only(xen_session *session, bool *result, xen_vdi vdi);
280 /**
281 * Set the name/label field of the given VDI.
282 */
283 extern bool
284 xen_vdi_set_name_label(xen_session *session, xen_vdi xen_vdi, char *label);
287 /**
288 * Set the name/description field of the given VDI.
289 */
290 extern bool
291 xen_vdi_set_name_description(xen_session *session, xen_vdi xen_vdi, char *description);
294 /**
295 * Set the SR field of the given VDI.
296 */
297 extern bool
298 xen_vdi_set_sr(xen_session *session, xen_vdi xen_vdi, xen_sr sr);
301 /**
302 * Set the virtual_size field of the given VDI.
303 */
304 extern bool
305 xen_vdi_set_virtual_size(xen_session *session, xen_vdi xen_vdi, uint64_t virtual_size);
308 /**
309 * Set the sharable field of the given VDI.
310 */
311 extern bool
312 xen_vdi_set_sharable(xen_session *session, xen_vdi xen_vdi, bool sharable);
315 /**
316 * Set the read_only field of the given VDI.
317 */
318 extern bool
319 xen_vdi_set_read_only(xen_session *session, xen_vdi xen_vdi, bool read_only);
322 /**
323 * Take an exact copy of the VDI; the snapshot lives in the same
324 * Storage Repository as its parent.
325 */
326 extern bool
327 xen_vdi_snapshot(xen_session *session, xen_vdi *result, xen_vdi vdi);
330 /**
331 * Resize the vdi to the size.
332 */
333 extern bool
334 xen_vdi_resize(xen_session *session, xen_vdi vdi, uint64_t size);
337 #endif