ia64/xen-unstable

view tools/libxen/include/xen_pbd.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 66c2a4085863
children 42dd9055ee1f
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_PBD_H
20 #define XEN_PBD_H
22 #include "xen_common.h"
23 #include "xen_host_decl.h"
24 #include "xen_pbd_decl.h"
25 #include "xen_sr_decl.h"
26 #include "xen_string_string_map.h"
29 /*
30 * The PBD class.
31 *
32 * The physical block devices through which hosts access SRs.
33 */
36 /**
37 * Free the given xen_pbd. The given handle must have been allocated
38 * by this library.
39 */
40 extern void
41 xen_pbd_free(xen_pbd pbd);
44 typedef struct xen_pbd_set
45 {
46 size_t size;
47 xen_pbd *contents[];
48 } xen_pbd_set;
50 /**
51 * Allocate a xen_pbd_set of the given size.
52 */
53 extern xen_pbd_set *
54 xen_pbd_set_alloc(size_t size);
56 /**
57 * Free the given xen_pbd_set. The given set must have been allocated
58 * by this library.
59 */
60 extern void
61 xen_pbd_set_free(xen_pbd_set *set);
64 typedef struct xen_pbd_record
65 {
66 xen_pbd handle;
67 char *uuid;
68 struct xen_host_record_opt *host;
69 struct xen_sr_record_opt *sr;
70 xen_string_string_map *device_config;
71 bool currently_attached;
72 } xen_pbd_record;
74 /**
75 * Allocate a xen_pbd_record.
76 */
77 extern xen_pbd_record *
78 xen_pbd_record_alloc(void);
80 /**
81 * Free the given xen_pbd_record, and all referenced values. The given
82 * record must have been allocated by this library.
83 */
84 extern void
85 xen_pbd_record_free(xen_pbd_record *record);
88 typedef struct xen_pbd_record_opt
89 {
90 bool is_record;
91 union
92 {
93 xen_pbd handle;
94 xen_pbd_record *record;
95 } u;
96 } xen_pbd_record_opt;
98 /**
99 * Allocate a xen_pbd_record_opt.
100 */
101 extern xen_pbd_record_opt *
102 xen_pbd_record_opt_alloc(void);
104 /**
105 * Free the given xen_pbd_record_opt, and all referenced values. The
106 * given record_opt must have been allocated by this library.
107 */
108 extern void
109 xen_pbd_record_opt_free(xen_pbd_record_opt *record_opt);
112 typedef struct xen_pbd_record_set
113 {
114 size_t size;
115 xen_pbd_record *contents[];
116 } xen_pbd_record_set;
118 /**
119 * Allocate a xen_pbd_record_set of the given size.
120 */
121 extern xen_pbd_record_set *
122 xen_pbd_record_set_alloc(size_t size);
124 /**
125 * Free the given xen_pbd_record_set, and all referenced values. The
126 * given set must have been allocated by this library.
127 */
128 extern void
129 xen_pbd_record_set_free(xen_pbd_record_set *set);
133 typedef struct xen_pbd_record_opt_set
134 {
135 size_t size;
136 xen_pbd_record_opt *contents[];
137 } xen_pbd_record_opt_set;
139 /**
140 * Allocate a xen_pbd_record_opt_set of the given size.
141 */
142 extern xen_pbd_record_opt_set *
143 xen_pbd_record_opt_set_alloc(size_t size);
145 /**
146 * Free the given xen_pbd_record_opt_set, and all referenced values.
147 * The given set must have been allocated by this library.
148 */
149 extern void
150 xen_pbd_record_opt_set_free(xen_pbd_record_opt_set *set);
153 /**
154 * Get a record containing the current state of the given PBD.
155 */
156 extern bool
157 xen_pbd_get_record(xen_session *session, xen_pbd_record **result, xen_pbd pbd);
160 /**
161 * Get a reference to the PBD instance with the specified UUID.
162 */
163 extern bool
164 xen_pbd_get_by_uuid(xen_session *session, xen_pbd *result, char *uuid);
167 /**
168 * Create a new PBD instance, and return its handle.
169 */
170 extern bool
171 xen_pbd_create(xen_session *session, xen_pbd *result, xen_pbd_record *record);
174 /**
175 * Destroy the specified PBD instance.
176 */
177 extern bool
178 xen_pbd_destroy(xen_session *session, xen_pbd pbd);
181 /**
182 * Get the uuid field of the given PBD.
183 */
184 extern bool
185 xen_pbd_get_uuid(xen_session *session, char **result, xen_pbd pbd);
188 /**
189 * Get the host field of the given PBD.
190 */
191 extern bool
192 xen_pbd_get_host(xen_session *session, xen_host *result, xen_pbd pbd);
195 /**
196 * Get the SR field of the given PBD.
197 */
198 extern bool
199 xen_pbd_get_sr(xen_session *session, xen_sr *result, xen_pbd pbd);
202 /**
203 * Get the device_config field of the given PBD.
204 */
205 extern bool
206 xen_pbd_get_device_config(xen_session *session, xen_string_string_map **result, xen_pbd pbd);
209 /**
210 * Get the currently_attached field of the given PBD.
211 */
212 extern bool
213 xen_pbd_get_currently_attached(xen_session *session, bool *result, xen_pbd pbd);
216 #endif