ia64/xen-unstable

view tools/libxen/include/xen_vif.h @ 14047:bab07bed5c0a

Added modelling and C bindings for VIF/VBD QoS parameter setting. No Xend
implementation yet.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Tue Feb 20 22:40:55 2007 +0000 (2007-02-20)
parents 0aa6755159d5
children fd7f23e44b11
line source
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 */
19 #ifndef XEN_VIF_H
20 #define XEN_VIF_H
22 #include "xen_common.h"
23 #include "xen_network_decl.h"
24 #include "xen_string_string_map.h"
25 #include "xen_vif_decl.h"
26 #include "xen_vif_metrics_decl.h"
27 #include "xen_vm_decl.h"
30 /*
31 * The VIF class.
32 *
33 * A virtual network interface.
34 */
37 /**
38 * Free the given xen_vif. The given handle must have been allocated
39 * by this library.
40 */
41 extern void
42 xen_vif_free(xen_vif vif);
45 typedef struct xen_vif_set
46 {
47 size_t size;
48 xen_vif *contents[];
49 } xen_vif_set;
51 /**
52 * Allocate a xen_vif_set of the given size.
53 */
54 extern xen_vif_set *
55 xen_vif_set_alloc(size_t size);
57 /**
58 * Free the given xen_vif_set. The given set must have been allocated
59 * by this library.
60 */
61 extern void
62 xen_vif_set_free(xen_vif_set *set);
65 typedef struct xen_vif_record
66 {
67 xen_vif handle;
68 char *uuid;
69 char *device;
70 struct xen_network_record_opt *network;
71 struct xen_vm_record_opt *vm;
72 char *mac;
73 int64_t mtu;
74 char *qos_algorithm_type;
75 xen_string_string_map *qos_algorithm_params;
76 struct xen_vif_metrics_record_opt *metrics;
77 } xen_vif_record;
79 /**
80 * Allocate a xen_vif_record.
81 */
82 extern xen_vif_record *
83 xen_vif_record_alloc(void);
85 /**
86 * Free the given xen_vif_record, and all referenced values. The given
87 * record must have been allocated by this library.
88 */
89 extern void
90 xen_vif_record_free(xen_vif_record *record);
93 typedef struct xen_vif_record_opt
94 {
95 bool is_record;
96 union
97 {
98 xen_vif handle;
99 xen_vif_record *record;
100 } u;
101 } xen_vif_record_opt;
103 /**
104 * Allocate a xen_vif_record_opt.
105 */
106 extern xen_vif_record_opt *
107 xen_vif_record_opt_alloc(void);
109 /**
110 * Free the given xen_vif_record_opt, and all referenced values. The
111 * given record_opt must have been allocated by this library.
112 */
113 extern void
114 xen_vif_record_opt_free(xen_vif_record_opt *record_opt);
117 typedef struct xen_vif_record_set
118 {
119 size_t size;
120 xen_vif_record *contents[];
121 } xen_vif_record_set;
123 /**
124 * Allocate a xen_vif_record_set of the given size.
125 */
126 extern xen_vif_record_set *
127 xen_vif_record_set_alloc(size_t size);
129 /**
130 * Free the given xen_vif_record_set, and all referenced values. The
131 * given set must have been allocated by this library.
132 */
133 extern void
134 xen_vif_record_set_free(xen_vif_record_set *set);
138 typedef struct xen_vif_record_opt_set
139 {
140 size_t size;
141 xen_vif_record_opt *contents[];
142 } xen_vif_record_opt_set;
144 /**
145 * Allocate a xen_vif_record_opt_set of the given size.
146 */
147 extern xen_vif_record_opt_set *
148 xen_vif_record_opt_set_alloc(size_t size);
150 /**
151 * Free the given xen_vif_record_opt_set, and all referenced values.
152 * The given set must have been allocated by this library.
153 */
154 extern void
155 xen_vif_record_opt_set_free(xen_vif_record_opt_set *set);
158 /**
159 * Get a record containing the current state of the given VIF.
160 */
161 extern bool
162 xen_vif_get_record(xen_session *session, xen_vif_record **result, xen_vif vif);
165 /**
166 * Get a reference to the VIF instance with the specified UUID.
167 */
168 extern bool
169 xen_vif_get_by_uuid(xen_session *session, xen_vif *result, char *uuid);
172 /**
173 * Create a new VIF instance, and return its handle.
174 */
175 extern bool
176 xen_vif_create(xen_session *session, xen_vif *result, xen_vif_record *record);
179 /**
180 * Destroy the specified VIF instance.
181 */
182 extern bool
183 xen_vif_destroy(xen_session *session, xen_vif vif);
186 /**
187 * Get the uuid field of the given VIF.
188 */
189 extern bool
190 xen_vif_get_uuid(xen_session *session, char **result, xen_vif vif);
193 /**
194 * Get the device field of the given VIF.
195 */
196 extern bool
197 xen_vif_get_device(xen_session *session, char **result, xen_vif vif);
200 /**
201 * Get the network field of the given VIF.
202 */
203 extern bool
204 xen_vif_get_network(xen_session *session, xen_network *result, xen_vif vif);
207 /**
208 * Get the VM field of the given VIF.
209 */
210 extern bool
211 xen_vif_get_vm(xen_session *session, xen_vm *result, xen_vif vif);
214 /**
215 * Get the MAC field of the given VIF.
216 */
217 extern bool
218 xen_vif_get_mac(xen_session *session, char **result, xen_vif vif);
221 /**
222 * Get the MTU field of the given VIF.
223 */
224 extern bool
225 xen_vif_get_mtu(xen_session *session, int64_t *result, xen_vif vif);
228 /**
229 * Get the qos/algorithm_type field of the given VIF.
230 */
231 extern bool
232 xen_vif_get_qos_algorithm_type(xen_session *session, char **result, xen_vif vif);
235 /**
236 * Get the qos/algorithm_params field of the given VIF.
237 */
238 extern bool
239 xen_vif_get_qos_algorithm_params(xen_session *session, xen_string_string_map **result, xen_vif vif);
242 /**
243 * Get the metrics field of the given VIF.
244 */
245 extern bool
246 xen_vif_get_metrics(xen_session *session, xen_vif_metrics *result, xen_vif vif);
249 /**
250 * Set the device field of the given VIF.
251 */
252 extern bool
253 xen_vif_set_device(xen_session *session, xen_vif vif, char *device);
256 /**
257 * Set the MAC field of the given VIF.
258 */
259 extern bool
260 xen_vif_set_mac(xen_session *session, xen_vif vif, char *mac);
263 /**
264 * Set the MTU field of the given VIF.
265 */
266 extern bool
267 xen_vif_set_mtu(xen_session *session, xen_vif vif, int64_t mtu);
270 /**
271 * Set the qos/algorithm_type field of the given VIF.
272 */
273 extern bool
274 xen_vif_set_qos_algorithm_type(xen_session *session, xen_vif vif, char *algorithm_type);
277 /**
278 * Set the qos/algorithm_params field of the given VIF.
279 */
280 extern bool
281 xen_vif_set_qos_algorithm_params(xen_session *session, xen_vif vif, xen_string_string_map *algorithm_params);
284 /**
285 * Add the given key-value pair to the qos/algorithm_params field of
286 * the given VIF.
287 */
288 extern bool
289 xen_vif_add_to_qos_algorithm_params(xen_session *session, xen_vif vif, char *key, char *value);
292 /**
293 * Remove the given key and its corresponding value from the
294 * qos/algorithm_params field of the given VIF. If the key is not in that
295 * Map, then do nothing.
296 */
297 extern bool
298 xen_vif_remove_from_qos_algorithm_params(xen_session *session, xen_vif vif, char *key);
301 #endif