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 | */ |
---|
18 | |
---|
19 | #ifndef XEN_SR_H |
---|
20 | #define XEN_SR_H |
---|
21 | |
---|
22 | #include <xen/api/xen_common.h> |
---|
23 | #include <xen/api/xen_pbd_decl.h> |
---|
24 | #include <xen/api/xen_sr_decl.h> |
---|
25 | #include <xen/api/xen_string_set.h> |
---|
26 | #include <xen/api/xen_vdi_decl.h> |
---|
27 | |
---|
28 | |
---|
29 | /* |
---|
30 | * The SR class. |
---|
31 | * |
---|
32 | * A storage repository. |
---|
33 | */ |
---|
34 | |
---|
35 | |
---|
36 | /** |
---|
37 | * Free the given xen_sr. The given handle must have been allocated by |
---|
38 | * this library. |
---|
39 | */ |
---|
40 | extern void |
---|
41 | xen_sr_free(xen_sr sr); |
---|
42 | |
---|
43 | |
---|
44 | typedef struct xen_sr_set |
---|
45 | { |
---|
46 | size_t size; |
---|
47 | xen_sr *contents[]; |
---|
48 | } xen_sr_set; |
---|
49 | |
---|
50 | /** |
---|
51 | * Allocate a xen_sr_set of the given size. |
---|
52 | */ |
---|
53 | extern xen_sr_set * |
---|
54 | xen_sr_set_alloc(size_t size); |
---|
55 | |
---|
56 | /** |
---|
57 | * Free the given xen_sr_set. The given set must have been allocated |
---|
58 | * by this library. |
---|
59 | */ |
---|
60 | extern void |
---|
61 | xen_sr_set_free(xen_sr_set *set); |
---|
62 | |
---|
63 | |
---|
64 | typedef struct xen_sr_record |
---|
65 | { |
---|
66 | xen_sr handle; |
---|
67 | char *uuid; |
---|
68 | char *name_label; |
---|
69 | char *name_description; |
---|
70 | struct xen_vdi_record_opt_set *vdis; |
---|
71 | struct xen_pbd_record_opt_set *pbds; |
---|
72 | int64_t virtual_allocation; |
---|
73 | int64_t physical_utilisation; |
---|
74 | int64_t physical_size; |
---|
75 | char *type; |
---|
76 | char *content_type; |
---|
77 | } xen_sr_record; |
---|
78 | |
---|
79 | /** |
---|
80 | * Allocate a xen_sr_record. |
---|
81 | */ |
---|
82 | extern xen_sr_record * |
---|
83 | xen_sr_record_alloc(void); |
---|
84 | |
---|
85 | /** |
---|
86 | * Free the given xen_sr_record, and all referenced values. The given |
---|
87 | * record must have been allocated by this library. |
---|
88 | */ |
---|
89 | extern void |
---|
90 | xen_sr_record_free(xen_sr_record *record); |
---|
91 | |
---|
92 | |
---|
93 | typedef struct xen_sr_record_opt |
---|
94 | { |
---|
95 | bool is_record; |
---|
96 | union |
---|
97 | { |
---|
98 | xen_sr handle; |
---|
99 | xen_sr_record *record; |
---|
100 | } u; |
---|
101 | } xen_sr_record_opt; |
---|
102 | |
---|
103 | /** |
---|
104 | * Allocate a xen_sr_record_opt. |
---|
105 | */ |
---|
106 | extern xen_sr_record_opt * |
---|
107 | xen_sr_record_opt_alloc(void); |
---|
108 | |
---|
109 | /** |
---|
110 | * Free the given xen_sr_record_opt, and all referenced values. The |
---|
111 | * given record_opt must have been allocated by this library. |
---|
112 | */ |
---|
113 | extern void |
---|
114 | xen_sr_record_opt_free(xen_sr_record_opt *record_opt); |
---|
115 | |
---|
116 | |
---|
117 | typedef struct xen_sr_record_set |
---|
118 | { |
---|
119 | size_t size; |
---|
120 | xen_sr_record *contents[]; |
---|
121 | } xen_sr_record_set; |
---|
122 | |
---|
123 | /** |
---|
124 | * Allocate a xen_sr_record_set of the given size. |
---|
125 | */ |
---|
126 | extern xen_sr_record_set * |
---|
127 | xen_sr_record_set_alloc(size_t size); |
---|
128 | |
---|
129 | /** |
---|
130 | * Free the given xen_sr_record_set, and all referenced values. The |
---|
131 | * given set must have been allocated by this library. |
---|
132 | */ |
---|
133 | extern void |
---|
134 | xen_sr_record_set_free(xen_sr_record_set *set); |
---|
135 | |
---|
136 | |
---|
137 | |
---|
138 | typedef struct xen_sr_record_opt_set |
---|
139 | { |
---|
140 | size_t size; |
---|
141 | xen_sr_record_opt *contents[]; |
---|
142 | } xen_sr_record_opt_set; |
---|
143 | |
---|
144 | /** |
---|
145 | * Allocate a xen_sr_record_opt_set of the given size. |
---|
146 | */ |
---|
147 | extern xen_sr_record_opt_set * |
---|
148 | xen_sr_record_opt_set_alloc(size_t size); |
---|
149 | |
---|
150 | /** |
---|
151 | * Free the given xen_sr_record_opt_set, and all referenced values. |
---|
152 | * The given set must have been allocated by this library. |
---|
153 | */ |
---|
154 | extern void |
---|
155 | xen_sr_record_opt_set_free(xen_sr_record_opt_set *set); |
---|
156 | |
---|
157 | |
---|
158 | /** |
---|
159 | * Get a record containing the current state of the given SR. |
---|
160 | */ |
---|
161 | extern bool |
---|
162 | xen_sr_get_record(xen_session *session, xen_sr_record **result, xen_sr sr); |
---|
163 | |
---|
164 | |
---|
165 | /** |
---|
166 | * Get a reference to the SR instance with the specified UUID. |
---|
167 | */ |
---|
168 | extern bool |
---|
169 | xen_sr_get_by_uuid(xen_session *session, xen_sr *result, char *uuid); |
---|
170 | |
---|
171 | |
---|
172 | /** |
---|
173 | * Get all the SR instances with the given label. |
---|
174 | */ |
---|
175 | extern bool |
---|
176 | xen_sr_get_by_name_label(xen_session *session, struct xen_sr_set **result, char *label); |
---|
177 | |
---|
178 | |
---|
179 | /** |
---|
180 | * Get the uuid field of the given SR. |
---|
181 | */ |
---|
182 | extern bool |
---|
183 | xen_sr_get_uuid(xen_session *session, char **result, xen_sr sr); |
---|
184 | |
---|
185 | |
---|
186 | /** |
---|
187 | * Get the name/label field of the given SR. |
---|
188 | */ |
---|
189 | extern bool |
---|
190 | xen_sr_get_name_label(xen_session *session, char **result, xen_sr sr); |
---|
191 | |
---|
192 | |
---|
193 | /** |
---|
194 | * Get the name/description field of the given SR. |
---|
195 | */ |
---|
196 | extern bool |
---|
197 | xen_sr_get_name_description(xen_session *session, char **result, xen_sr sr); |
---|
198 | |
---|
199 | |
---|
200 | /** |
---|
201 | * Get the VDIs field of the given SR. |
---|
202 | */ |
---|
203 | extern bool |
---|
204 | xen_sr_get_vdis(xen_session *session, struct xen_vdi_set **result, xen_sr sr); |
---|
205 | |
---|
206 | |
---|
207 | /** |
---|
208 | * Get the PBDs field of the given SR. |
---|
209 | */ |
---|
210 | extern bool |
---|
211 | xen_sr_get_pbds(xen_session *session, struct xen_pbd_set **result, xen_sr sr); |
---|
212 | |
---|
213 | |
---|
214 | /** |
---|
215 | * Get the virtual_allocation field of the given SR. |
---|
216 | */ |
---|
217 | extern bool |
---|
218 | xen_sr_get_virtual_allocation(xen_session *session, int64_t *result, xen_sr sr); |
---|
219 | |
---|
220 | |
---|
221 | /** |
---|
222 | * Get the physical_utilisation field of the given SR. |
---|
223 | */ |
---|
224 | extern bool |
---|
225 | xen_sr_get_physical_utilisation(xen_session *session, int64_t *result, xen_sr sr); |
---|
226 | |
---|
227 | |
---|
228 | /** |
---|
229 | * Get the physical_size field of the given SR. |
---|
230 | */ |
---|
231 | extern bool |
---|
232 | xen_sr_get_physical_size(xen_session *session, int64_t *result, xen_sr sr); |
---|
233 | |
---|
234 | |
---|
235 | /** |
---|
236 | * Get the type field of the given SR. |
---|
237 | */ |
---|
238 | extern bool |
---|
239 | xen_sr_get_type(xen_session *session, char **result, xen_sr sr); |
---|
240 | |
---|
241 | |
---|
242 | /** |
---|
243 | * Get the content_type field of the given SR. |
---|
244 | */ |
---|
245 | extern bool |
---|
246 | xen_sr_get_content_type(xen_session *session, char **result, xen_sr sr); |
---|
247 | |
---|
248 | |
---|
249 | /** |
---|
250 | * Set the name/label field of the given SR. |
---|
251 | */ |
---|
252 | extern bool |
---|
253 | xen_sr_set_name_label(xen_session *session, xen_sr sr, char *label); |
---|
254 | |
---|
255 | |
---|
256 | /** |
---|
257 | * Set the name/description field of the given SR. |
---|
258 | */ |
---|
259 | extern bool |
---|
260 | xen_sr_set_name_description(xen_session *session, xen_sr sr, char *description); |
---|
261 | |
---|
262 | |
---|
263 | /** |
---|
264 | * Return a set of all the SR types supported by the system. |
---|
265 | */ |
---|
266 | extern bool |
---|
267 | xen_sr_get_supported_types(xen_session *session, struct xen_string_set **result); |
---|
268 | |
---|
269 | |
---|
270 | /** |
---|
271 | * Return a list of all the SRs known to the system. |
---|
272 | */ |
---|
273 | extern bool |
---|
274 | xen_sr_get_all(xen_session *session, struct xen_sr_set **result); |
---|
275 | |
---|
276 | |
---|
277 | #endif |
---|