ia64/xen-unstable

view tools/libxen/include/xen_vbd.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 0a422c8c3144
children bab07bed5c0a
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_vbd_decl.h"
24 #include "xen_vbd_metrics_decl.h"
25 #include "xen_vbd_mode.h"
26 #include "xen_vbd_type.h"
27 #include "xen_vdi_decl.h"
28 #include "xen_vm_decl.h"
31 /*
32 * The VBD class.
33 *
34 * A virtual block device.
35 */
38 /**
39 * Free the given xen_vbd. The given handle must have been allocated
40 * by this library.
41 */
42 extern void
43 xen_vbd_free(xen_vbd vbd);
46 typedef struct xen_vbd_set
47 {
48 size_t size;
49 xen_vbd *contents[];
50 } xen_vbd_set;
52 /**
53 * Allocate a xen_vbd_set of the given size.
54 */
55 extern xen_vbd_set *
56 xen_vbd_set_alloc(size_t size);
58 /**
59 * Free the given xen_vbd_set. The given set must have been allocated
60 * by this library.
61 */
62 extern void
63 xen_vbd_set_free(xen_vbd_set *set);
66 typedef struct xen_vbd_record
67 {
68 xen_vbd handle;
69 char *uuid;
70 struct xen_vm_record_opt *vm;
71 struct xen_vdi_record_opt *vdi;
72 char *device;
73 char *image;
74 bool bootable;
75 enum xen_vbd_mode mode;
76 enum xen_vbd_type type;
77 struct xen_vbd_metrics_record_opt *metrics;
78 } xen_vbd_record;
80 /**
81 * Allocate a xen_vbd_record.
82 */
83 extern xen_vbd_record *
84 xen_vbd_record_alloc(void);
86 /**
87 * Free the given xen_vbd_record, and all referenced values. The given
88 * record must have been allocated by this library.
89 */
90 extern void
91 xen_vbd_record_free(xen_vbd_record *record);
94 typedef struct xen_vbd_record_opt
95 {
96 bool is_record;
97 union
98 {
99 xen_vbd handle;
100 xen_vbd_record *record;
101 } u;
102 } xen_vbd_record_opt;
104 /**
105 * Allocate a xen_vbd_record_opt.
106 */
107 extern xen_vbd_record_opt *
108 xen_vbd_record_opt_alloc(void);
110 /**
111 * Free the given xen_vbd_record_opt, and all referenced values. The
112 * given record_opt must have been allocated by this library.
113 */
114 extern void
115 xen_vbd_record_opt_free(xen_vbd_record_opt *record_opt);
118 typedef struct xen_vbd_record_set
119 {
120 size_t size;
121 xen_vbd_record *contents[];
122 } xen_vbd_record_set;
124 /**
125 * Allocate a xen_vbd_record_set of the given size.
126 */
127 extern xen_vbd_record_set *
128 xen_vbd_record_set_alloc(size_t size);
130 /**
131 * Free the given xen_vbd_record_set, and all referenced values. The
132 * given set must have been allocated by this library.
133 */
134 extern void
135 xen_vbd_record_set_free(xen_vbd_record_set *set);
139 typedef struct xen_vbd_record_opt_set
140 {
141 size_t size;
142 xen_vbd_record_opt *contents[];
143 } xen_vbd_record_opt_set;
145 /**
146 * Allocate a xen_vbd_record_opt_set of the given size.
147 */
148 extern xen_vbd_record_opt_set *
149 xen_vbd_record_opt_set_alloc(size_t size);
151 /**
152 * Free the given xen_vbd_record_opt_set, and all referenced values.
153 * The given set must have been allocated by this library.
154 */
155 extern void
156 xen_vbd_record_opt_set_free(xen_vbd_record_opt_set *set);
159 /**
160 * Get a record containing the current state of the given VBD.
161 */
162 extern bool
163 xen_vbd_get_record(xen_session *session, xen_vbd_record **result, xen_vbd vbd);
166 /**
167 * Get a reference to the VBD instance with the specified UUID.
168 */
169 extern bool
170 xen_vbd_get_by_uuid(xen_session *session, xen_vbd *result, char *uuid);
173 /**
174 * Create a new VBD instance, and return its handle.
175 */
176 extern bool
177 xen_vbd_create(xen_session *session, xen_vbd *result, xen_vbd_record *record);
180 /**
181 * Destroy the specified VBD instance.
182 */
183 extern bool
184 xen_vbd_destroy(xen_session *session, xen_vbd vbd);
187 /**
188 * Get the uuid field of the given VBD.
189 */
190 extern bool
191 xen_vbd_get_uuid(xen_session *session, char **result, xen_vbd vbd);
194 /**
195 * Get the VM field of the given VBD.
196 */
197 extern bool
198 xen_vbd_get_vm(xen_session *session, xen_vm *result, xen_vbd vbd);
201 /**
202 * Get the VDI field of the given VBD.
203 */
204 extern bool
205 xen_vbd_get_vdi(xen_session *session, xen_vdi *result, xen_vbd vbd);
208 /**
209 * Get the device field of the given VBD.
210 */
211 extern bool
212 xen_vbd_get_device(xen_session *session, char **result, xen_vbd vbd);
215 /**
216 * Get the bootable field of the given VBD.
217 */
218 extern bool
219 xen_vbd_get_bootable(xen_session *session, bool *result, xen_vbd vbd);
222 /**
223 * Get the mode field of the given VBD.
224 */
225 extern bool
226 xen_vbd_get_mode(xen_session *session, enum xen_vbd_mode *result, xen_vbd vbd);
229 /**
230 * Get the type field of the given VBD.
231 */
232 extern bool
233 xen_vbd_get_type(xen_session *session, enum xen_vbd_type *result, xen_vbd vbd);
236 /**
237 * Get the metrics field of the given VBD.
238 */
239 extern bool
240 xen_vbd_get_metrics(xen_session *session, xen_vbd_metrics *result, xen_vbd vbd);
243 /**
244 * Set the device field of the given VBD.
245 */
246 extern bool
247 xen_vbd_set_device(xen_session *session, xen_vbd vbd, char *device);
250 /**
251 * Set the bootable field of the given VBD.
252 */
253 extern bool
254 xen_vbd_set_bootable(xen_session *session, xen_vbd vbd, bool bootable);
257 /**
258 * Set the mode field of the given VBD.
259 */
260 extern bool
261 xen_vbd_set_mode(xen_session *session, xen_vbd vbd, enum xen_vbd_mode mode);
264 /**
265 * Set the type field of the given VBD.
266 */
267 extern bool
268 xen_vbd_set_type(xen_session *session, xen_vbd vbd, enum xen_vbd_type type);
271 /**
272 * Change the media in the device for CDROM-like devices only. For
273 * other devices, detach the VBD and attach a new one
274 */
275 extern bool
276 xen_vbd_media_change(xen_session *session, xen_vbd vbd, xen_vdi vdi);
279 #endif