ia64/xen-unstable

view tools/libxen/include/xen_vbd.h @ 12281:9febecbeaeb0

[XENAPI] Add 'image' field to xen_vbd_record, allowing an image to be
associated with the vbd. xend supports this field and the client
bindings need it to support existing images that are not under
control of an SR.

Signed-off-by: Jim Fehlig <jfehlig@novell.com>
author kfraser@localhost.localdomain
date Tue Nov 07 10:46:03 2006 +0000 (2006-11-07)
parents 8f090c551b09
children 08b38d041269
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_VBD_H
20 #define XEN_VBD_H
22 #include "xen_common.h"
23 #include "xen_driver_type.h"
24 #include "xen_vbd_decl.h"
25 #include "xen_vbd_mode.h"
26 #include "xen_vdi_decl.h"
27 #include "xen_vm_decl.h"
30 /*
31 * The VBD class.
32 *
33 * A virtual block device.
34 */
37 /**
38 * Free the given xen_vbd. The given handle must have been allocated
39 * by this library.
40 */
41 extern void
42 xen_vbd_free(xen_vbd vbd);
45 typedef struct xen_vbd_set
46 {
47 size_t size;
48 xen_vbd *contents[];
49 } xen_vbd_set;
51 /**
52 * Allocate a xen_vbd_set of the given size.
53 */
54 extern xen_vbd_set *
55 xen_vbd_set_alloc(size_t size);
57 /**
58 * Free the given xen_vbd_set. The given set must have been allocated
59 * by this library.
60 */
61 extern void
62 xen_vbd_set_free(xen_vbd_set *set);
65 typedef struct xen_vbd_record
66 {
67 xen_vbd handle;
68 char *uuid;
69 struct xen_vm_record_opt *vm;
70 struct xen_vdi_record_opt *vdi;
71 char *device;
72 char *image;
73 enum xen_vbd_mode mode;
74 enum xen_driver_type driver;
75 double io_read_kbs;
76 double io_write_kbs;
77 } xen_vbd_record;
79 /**
80 * Allocate a xen_vbd_record.
81 */
82 extern xen_vbd_record *
83 xen_vbd_record_alloc(void);
85 /**
86 * Free the given xen_vbd_record, and all referenced values. The given
87 * record must have been allocated by this library.
88 */
89 extern void
90 xen_vbd_record_free(xen_vbd_record *record);
93 typedef struct xen_vbd_record_opt
94 {
95 bool is_record;
96 union
97 {
98 xen_vbd handle;
99 xen_vbd_record *record;
100 } u;
101 } xen_vbd_record_opt;
103 /**
104 * Allocate a xen_vbd_record_opt.
105 */
106 extern xen_vbd_record_opt *
107 xen_vbd_record_opt_alloc(void);
109 /**
110 * Free the given xen_vbd_record_opt, and all referenced values. The
111 * given record_opt must have been allocated by this library.
112 */
113 extern void
114 xen_vbd_record_opt_free(xen_vbd_record_opt *record_opt);
117 typedef struct xen_vbd_record_set
118 {
119 size_t size;
120 xen_vbd_record *contents[];
121 } xen_vbd_record_set;
123 /**
124 * Allocate a xen_vbd_record_set of the given size.
125 */
126 extern xen_vbd_record_set *
127 xen_vbd_record_set_alloc(size_t size);
129 /**
130 * Free the given xen_vbd_record_set, and all referenced values. The
131 * given set must have been allocated by this library.
132 */
133 extern void
134 xen_vbd_record_set_free(xen_vbd_record_set *set);
138 typedef struct xen_vbd_record_opt_set
139 {
140 size_t size;
141 xen_vbd_record_opt *contents[];
142 } xen_vbd_record_opt_set;
144 /**
145 * Allocate a xen_vbd_record_opt_set of the given size.
146 */
147 extern xen_vbd_record_opt_set *
148 xen_vbd_record_opt_set_alloc(size_t size);
150 /**
151 * Free the given xen_vbd_record_opt_set, and all referenced values.
152 * The given set must have been allocated by this library.
153 */
154 extern void
155 xen_vbd_record_opt_set_free(xen_vbd_record_opt_set *set);
158 /**
159 * Get the current state of the given VBD. !!!
160 */
161 extern bool
162 xen_vbd_get_record(xen_session *session, xen_vbd_record **result, xen_vbd vbd);
165 /**
166 * Get a reference to the object with the specified UUID. !!!
167 */
168 extern bool
169 xen_vbd_get_by_uuid(xen_session *session, xen_vbd *result, char *uuid);
172 /**
173 * Create a new VBD instance, and return its handle.
174 */
175 extern bool
176 xen_vbd_create(xen_session *session, xen_vbd *result, xen_vbd_record *record);
179 /**
180 * Get the uuid field of the given VBD.
181 */
182 extern bool
183 xen_vbd_get_uuid(xen_session *session, char **result, xen_vbd vbd);
186 /**
187 * Get the VM field of the given VBD.
188 */
189 extern bool
190 xen_vbd_get_vm(xen_session *session, xen_vm *result, xen_vbd vbd);
193 /**
194 * Get the VDI field of the given VBD.
195 */
196 extern bool
197 xen_vbd_get_vdi(xen_session *session, xen_vdi *result, xen_vbd vbd);
200 /**
201 * Get the device field of the given VBD.
202 */
203 extern bool
204 xen_vbd_get_device(xen_session *session, char **result, xen_vbd vbd);
207 /**
208 * Get the mode field of the given VBD.
209 */
210 extern bool
211 xen_vbd_get_mode(xen_session *session, enum xen_vbd_mode *result, xen_vbd vbd);
214 /**
215 * Get the driver field of the given VBD.
216 */
217 extern bool
218 xen_vbd_get_driver(xen_session *session, enum xen_driver_type *result, xen_vbd vbd);
221 /**
222 * Get the io/read_kbs field of the given VBD.
223 */
224 extern bool
225 xen_vbd_get_io_read_kbs(xen_session *session, double *result, xen_vbd vbd);
228 /**
229 * Get the io/write_kbs field of the given VBD.
230 */
231 extern bool
232 xen_vbd_get_io_write_kbs(xen_session *session, double *result, xen_vbd vbd);
235 /**
236 * Set the VM field of the given VBD.
237 */
238 extern bool
239 xen_vbd_set_vm(xen_session *session, xen_vbd xen_vbd, xen_vm vm);
242 /**
243 * Set the VDI field of the given VBD.
244 */
245 extern bool
246 xen_vbd_set_vdi(xen_session *session, xen_vbd xen_vbd, xen_vdi vdi);
249 /**
250 * Set the device field of the given VBD.
251 */
252 extern bool
253 xen_vbd_set_device(xen_session *session, xen_vbd xen_vbd, char *device);
256 /**
257 * Set the mode field of the given VBD.
258 */
259 extern bool
260 xen_vbd_set_mode(xen_session *session, xen_vbd xen_vbd, enum xen_vbd_mode mode);
263 /**
264 * Set the driver field of the given VBD.
265 */
266 extern bool
267 xen_vbd_set_driver(xen_session *session, xen_vbd xen_vbd, enum xen_driver_type driver);
270 /**
271 * Change the media in the device for CDROM-like devices only. For
272 * other devices, detach the VBD and attach a new one
273 */
274 extern bool
275 xen_vbd_media_change(xen_session *session, xen_vbd vbd, xen_vdi vdi);
278 #endif