ia64/xen-unstable

view tools/libxen/src/xen_vbd_type.c @ 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
children 295858ddac87
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 #include <string.h>
21 #include "xen_internal.h"
22 #include "xen_vbd_type.h"
23 #include "xen_vbd_type_internal.h"
26 /*
27 * Maintain this in the same order as the enum declaration!
28 */
29 static const char *lookup_table[] =
30 {
31 "CD",
32 "Disk"
33 };
36 extern xen_vbd_type_set *
37 xen_vbd_type_set_alloc(size_t size)
38 {
39 return calloc(1, sizeof(xen_vbd_type_set) +
40 size * sizeof(enum xen_vbd_type));
41 }
44 extern void
45 xen_vbd_type_set_free(xen_vbd_type_set *set)
46 {
47 free(set);
48 }
51 const char *
52 xen_vbd_type_to_string(enum xen_vbd_type val)
53 {
54 return lookup_table[val];
55 }
58 extern enum xen_vbd_type
59 xen_vbd_type_from_string(xen_session *session, const char *str)
60 {
61 return ENUM_LOOKUP(session, str, lookup_table);
62 }
65 const abstract_type xen_vbd_type_abstract_type_ =
66 {
67 .typename = ENUM,
68 .enum_marshaller =
69 (const char *(*)(int))&xen_vbd_type_to_string,
70 .enum_demarshaller =
71 (int (*)(xen_session *, const char *))&xen_vbd_type_from_string
72 };
75 const abstract_type xen_vbd_type_set_abstract_type_ =
76 {
77 .typename = SET,
78 .child = &xen_vbd_type_abstract_type_
79 };