2
* Copyright (c) 2006-2007, XenSource Inc.
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.
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.
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
23
#include "xen_internal.h"
24
#include <xen/api/xen_common.h>
25
#include <xen/api/xen_pbd.h>
26
#include <xen/api/xen_sr.h>
27
#include <xen/api/xen_vdi.h>
31
XEN_SET_ALLOC_FREE(xen_sr)
32
XEN_ALLOC(xen_sr_record)
33
XEN_SET_ALLOC_FREE(xen_sr_record)
34
XEN_ALLOC(xen_sr_record_opt)
35
XEN_RECORD_OPT_FREE(xen_sr)
36
XEN_SET_ALLOC_FREE(xen_sr_record_opt)
39
static const struct_member xen_sr_record_struct_members[] =
42
.type = &abstract_type_string,
43
.offset = offsetof(xen_sr_record, uuid) },
44
{ .key = "name_label",
45
.type = &abstract_type_string,
46
.offset = offsetof(xen_sr_record, name_label) },
47
{ .key = "name_description",
48
.type = &abstract_type_string,
49
.offset = offsetof(xen_sr_record, name_description) },
51
.type = &abstract_type_ref_set,
52
.offset = offsetof(xen_sr_record, vdis) },
54
.type = &abstract_type_ref_set,
55
.offset = offsetof(xen_sr_record, pbds) },
56
{ .key = "virtual_allocation",
57
.type = &abstract_type_int,
58
.offset = offsetof(xen_sr_record, virtual_allocation) },
59
{ .key = "physical_utilisation",
60
.type = &abstract_type_int,
61
.offset = offsetof(xen_sr_record, physical_utilisation) },
62
{ .key = "physical_size",
63
.type = &abstract_type_int,
64
.offset = offsetof(xen_sr_record, physical_size) },
66
.type = &abstract_type_string,
67
.offset = offsetof(xen_sr_record, type) },
68
{ .key = "content_type",
69
.type = &abstract_type_string,
70
.offset = offsetof(xen_sr_record, content_type) }
73
const abstract_type xen_sr_record_abstract_type_ =
76
.struct_size = sizeof(xen_sr_record),
78
sizeof(xen_sr_record_struct_members) / sizeof(struct_member),
79
.members = xen_sr_record_struct_members
84
xen_sr_record_free(xen_sr_record *record)
92
free(record->name_label);
93
free(record->name_description);
94
xen_vdi_record_opt_set_free(record->vdis);
95
xen_pbd_record_opt_set_free(record->pbds);
97
free(record->content_type);
103
xen_sr_get_record(xen_session *session, xen_sr_record **result, xen_sr sr)
105
abstract_value param_values[] =
107
{ .type = &abstract_type_string,
111
abstract_type result_type = xen_sr_record_abstract_type_;
114
XEN_CALL_("SR.get_record");
118
(*result)->handle = xen_strdup_((*result)->uuid);
126
xen_sr_get_by_uuid(xen_session *session, xen_sr *result, char *uuid)
128
abstract_value param_values[] =
130
{ .type = &abstract_type_string,
131
.u.string_val = uuid }
134
abstract_type result_type = abstract_type_string;
137
XEN_CALL_("SR.get_by_uuid");
143
xen_sr_get_by_name_label(xen_session *session, struct xen_sr_set **result, char *label)
145
abstract_value param_values[] =
147
{ .type = &abstract_type_string,
148
.u.string_val = label }
151
abstract_type result_type = abstract_type_string_set;
154
XEN_CALL_("SR.get_by_name_label");
160
xen_sr_get_name_label(xen_session *session, char **result, xen_sr sr)
162
abstract_value param_values[] =
164
{ .type = &abstract_type_string,
168
abstract_type result_type = abstract_type_string;
171
XEN_CALL_("SR.get_name_label");
177
xen_sr_get_name_description(xen_session *session, char **result, xen_sr sr)
179
abstract_value param_values[] =
181
{ .type = &abstract_type_string,
185
abstract_type result_type = abstract_type_string;
188
XEN_CALL_("SR.get_name_description");
194
xen_sr_get_vdis(xen_session *session, struct xen_vdi_set **result, xen_sr sr)
196
abstract_value param_values[] =
198
{ .type = &abstract_type_string,
202
abstract_type result_type = abstract_type_string_set;
205
XEN_CALL_("SR.get_VDIs");
211
xen_sr_get_pbds(xen_session *session, struct xen_pbd_set **result, xen_sr sr)
213
abstract_value param_values[] =
215
{ .type = &abstract_type_string,
219
abstract_type result_type = abstract_type_string_set;
222
XEN_CALL_("SR.get_PBDs");
228
xen_sr_get_virtual_allocation(xen_session *session, int64_t *result, xen_sr sr)
230
abstract_value param_values[] =
232
{ .type = &abstract_type_string,
236
abstract_type result_type = abstract_type_int;
238
XEN_CALL_("SR.get_virtual_allocation");
244
xen_sr_get_physical_utilisation(xen_session *session, int64_t *result, xen_sr sr)
246
abstract_value param_values[] =
248
{ .type = &abstract_type_string,
252
abstract_type result_type = abstract_type_int;
254
XEN_CALL_("SR.get_physical_utilisation");
260
xen_sr_get_physical_size(xen_session *session, int64_t *result, xen_sr sr)
262
abstract_value param_values[] =
264
{ .type = &abstract_type_string,
268
abstract_type result_type = abstract_type_int;
270
XEN_CALL_("SR.get_physical_size");
276
xen_sr_get_type(xen_session *session, char **result, xen_sr sr)
278
abstract_value param_values[] =
280
{ .type = &abstract_type_string,
284
abstract_type result_type = abstract_type_string;
287
XEN_CALL_("SR.get_type");
293
xen_sr_get_content_type(xen_session *session, char **result, xen_sr sr)
295
abstract_value param_values[] =
297
{ .type = &abstract_type_string,
301
abstract_type result_type = abstract_type_string;
304
XEN_CALL_("SR.get_content_type");
310
xen_sr_set_name_label(xen_session *session, xen_sr sr, char *label)
312
abstract_value param_values[] =
314
{ .type = &abstract_type_string,
315
.u.string_val = sr },
316
{ .type = &abstract_type_string,
317
.u.string_val = label }
320
xen_call_(session, "SR.set_name_label", param_values, 2, NULL, NULL);
326
xen_sr_set_name_description(xen_session *session, xen_sr sr, char *description)
328
abstract_value param_values[] =
330
{ .type = &abstract_type_string,
331
.u.string_val = sr },
332
{ .type = &abstract_type_string,
333
.u.string_val = description }
336
xen_call_(session, "SR.set_name_description", param_values, 2, NULL, NULL);
342
xen_sr_get_supported_types(xen_session *session, struct xen_string_set **result)
345
abstract_type result_type = abstract_type_string_set;
348
xen_call_(session, "SR.get_supported_types", NULL, 0, &result_type, result);
354
xen_sr_get_all(xen_session *session, struct xen_sr_set **result)
357
abstract_type result_type = abstract_type_string_set;
360
xen_call_(session, "SR.get_all", NULL, 0, &result_type, result);
366
xen_sr_get_uuid(xen_session *session, char **result, xen_sr sr)
368
abstract_value param_values[] =
370
{ .type = &abstract_type_string,
374
abstract_type result_type = abstract_type_string;
377
XEN_CALL_("SR.get_uuid");