source: trunk/packages/xen-3.1/xen-3.1/tools/libxen/include/xen/api/xen_sr.h @ 34

Last change on this file since 34 was 34, checked in by hartmans, 18 years ago

Add xen and xen-common

File size: 5.9 KB
Line 
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 */
40extern void
41xen_sr_free(xen_sr sr);
42
43
44typedef 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 */
53extern xen_sr_set *
54xen_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 */
60extern void
61xen_sr_set_free(xen_sr_set *set);
62
63
64typedef 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 */
82extern xen_sr_record *
83xen_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 */
89extern void
90xen_sr_record_free(xen_sr_record *record);
91
92
93typedef 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 */
106extern xen_sr_record_opt *
107xen_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 */
113extern void
114xen_sr_record_opt_free(xen_sr_record_opt *record_opt);
115
116
117typedef 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 */
126extern xen_sr_record_set *
127xen_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 */
133extern void
134xen_sr_record_set_free(xen_sr_record_set *set);
135
136
137
138typedef 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 */
147extern xen_sr_record_opt_set *
148xen_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 */
154extern void
155xen_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 */
161extern bool
162xen_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 */
168extern bool
169xen_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 */
175extern bool
176xen_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 */
182extern bool
183xen_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 */
189extern bool
190xen_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 */
196extern bool
197xen_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 */
203extern bool
204xen_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 */
210extern bool
211xen_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 */
217extern bool
218xen_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 */
224extern bool
225xen_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 */
231extern bool
232xen_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 */
238extern bool
239xen_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 */
245extern bool
246xen_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 */
252extern bool
253xen_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 */
259extern bool
260xen_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 */
266extern bool
267xen_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 */
273extern bool
274xen_sr_get_all(xen_session *session, struct xen_sr_set **result);
275
276
277#endif
Note: See TracBrowser for help on using the repository browser.