ia64/xen-unstable

annotate tools/libxen/src/xen_vbd_metrics.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 42dd9055ee1f
rev   line source
ewan@14045 1 /*
ewan@14045 2 * Copyright (c) 2006-2007, XenSource Inc.
ewan@14045 3 *
ewan@14045 4 * This library is free software; you can redistribute it and/or
ewan@14045 5 * modify it under the terms of the GNU Lesser General Public
ewan@14045 6 * License as published by the Free Software Foundation; either
ewan@14045 7 * version 2.1 of the License, or (at your option) any later version.
ewan@14045 8 *
ewan@14045 9 * This library is distributed in the hope that it will be useful,
ewan@14045 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ewan@14045 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
ewan@14045 12 * Lesser General Public License for more details.
ewan@14045 13 *
ewan@14045 14 * You should have received a copy of the GNU Lesser General Public
ewan@14045 15 * License along with this library; if not, write to the Free Software
ewan@14045 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
ewan@14045 17 */
ewan@14045 18
ewan@14045 19
ewan@14045 20 #include <stddef.h>
ewan@14045 21 #include <stdlib.h>
ewan@14045 22
ewan@14045 23 #include "xen_common.h"
ewan@14045 24 #include "xen_internal.h"
ewan@14045 25 #include "xen_vbd_metrics.h"
ewan@14045 26
ewan@14045 27
ewan@14045 28 XEN_FREE(xen_vbd_metrics)
ewan@14045 29 XEN_SET_ALLOC_FREE(xen_vbd_metrics)
ewan@14045 30 XEN_ALLOC(xen_vbd_metrics_record)
ewan@14045 31 XEN_SET_ALLOC_FREE(xen_vbd_metrics_record)
ewan@14045 32 XEN_ALLOC(xen_vbd_metrics_record_opt)
ewan@14045 33 XEN_RECORD_OPT_FREE(xen_vbd_metrics)
ewan@14045 34 XEN_SET_ALLOC_FREE(xen_vbd_metrics_record_opt)
ewan@14045 35
ewan@14045 36
ewan@14045 37 static const struct_member xen_vbd_metrics_record_struct_members[] =
ewan@14045 38 {
ewan@14045 39 { .key = "uuid",
ewan@14045 40 .type = &abstract_type_string,
ewan@14045 41 .offset = offsetof(xen_vbd_metrics_record, uuid) },
ewan@14045 42 { .key = "io_read_kbs",
ewan@14045 43 .type = &abstract_type_float,
ewan@14045 44 .offset = offsetof(xen_vbd_metrics_record, io_read_kbs) },
ewan@14045 45 { .key = "io_write_kbs",
ewan@14045 46 .type = &abstract_type_float,
ewan@14045 47 .offset = offsetof(xen_vbd_metrics_record, io_write_kbs) }
ewan@14045 48 };
ewan@14045 49
ewan@14045 50 const abstract_type xen_vbd_metrics_record_abstract_type_ =
ewan@14045 51 {
ewan@14045 52 .typename = STRUCT,
ewan@14045 53 .struct_size = sizeof(xen_vbd_metrics_record),
ewan@14045 54 .member_count =
ewan@14045 55 sizeof(xen_vbd_metrics_record_struct_members) / sizeof(struct_member),
ewan@14045 56 .members = xen_vbd_metrics_record_struct_members
ewan@14045 57 };
ewan@14045 58
ewan@14045 59
ewan@14045 60 void
ewan@14045 61 xen_vbd_metrics_record_free(xen_vbd_metrics_record *record)
ewan@14045 62 {
ewan@14045 63 if (record == NULL)
ewan@14045 64 {
ewan@14045 65 return;
ewan@14045 66 }
ewan@14045 67 free(record->handle);
ewan@14045 68 free(record->uuid);
ewan@14045 69 free(record);
ewan@14045 70 }
ewan@14045 71
ewan@14045 72
ewan@14045 73 bool
ewan@14045 74 xen_vbd_metrics_get_record(xen_session *session, xen_vbd_metrics_record **result, xen_vbd_metrics vbd_metrics)
ewan@14045 75 {
ewan@14045 76 abstract_value param_values[] =
ewan@14045 77 {
ewan@14045 78 { .type = &abstract_type_string,
ewan@14045 79 .u.string_val = vbd_metrics }
ewan@14045 80 };
ewan@14045 81
ewan@14045 82 abstract_type result_type = xen_vbd_metrics_record_abstract_type_;
ewan@14045 83
ewan@14045 84 *result = NULL;
ewan@14045 85 XEN_CALL_("VBD_metrics.get_record");
ewan@14045 86
ewan@14045 87 if (session->ok)
ewan@14045 88 {
ewan@14045 89 (*result)->handle = xen_strdup_((*result)->uuid);
ewan@14045 90 }
ewan@14045 91
ewan@14045 92 return session->ok;
ewan@14045 93 }
ewan@14045 94
ewan@14045 95
ewan@14045 96 bool
ewan@14045 97 xen_vbd_metrics_get_by_uuid(xen_session *session, xen_vbd_metrics *result, char *uuid)
ewan@14045 98 {
ewan@14045 99 abstract_value param_values[] =
ewan@14045 100 {
ewan@14045 101 { .type = &abstract_type_string,
ewan@14045 102 .u.string_val = uuid }
ewan@14045 103 };
ewan@14045 104
ewan@14045 105 abstract_type result_type = abstract_type_string;
ewan@14045 106
ewan@14045 107 *result = NULL;
ewan@14045 108 XEN_CALL_("VBD_metrics.get_by_uuid");
ewan@14045 109 return session->ok;
ewan@14045 110 }
ewan@14045 111
ewan@14045 112
ewan@14045 113 bool
ewan@14045 114 xen_vbd_metrics_get_io_read_kbs(xen_session *session, double *result, xen_vbd_metrics vbd_metrics)
ewan@14045 115 {
ewan@14045 116 abstract_value param_values[] =
ewan@14045 117 {
ewan@14045 118 { .type = &abstract_type_string,
ewan@14045 119 .u.string_val = vbd_metrics }
ewan@14045 120 };
ewan@14045 121
ewan@14045 122 abstract_type result_type = abstract_type_float;
ewan@14045 123
ewan@14045 124 XEN_CALL_("VBD_metrics.get_io_read_kbs");
ewan@14045 125 return session->ok;
ewan@14045 126 }
ewan@14045 127
ewan@14045 128
ewan@14045 129 bool
ewan@14045 130 xen_vbd_metrics_get_io_write_kbs(xen_session *session, double *result, xen_vbd_metrics vbd_metrics)
ewan@14045 131 {
ewan@14045 132 abstract_value param_values[] =
ewan@14045 133 {
ewan@14045 134 { .type = &abstract_type_string,
ewan@14045 135 .u.string_val = vbd_metrics }
ewan@14045 136 };
ewan@14045 137
ewan@14045 138 abstract_type result_type = abstract_type_float;
ewan@14045 139
ewan@14045 140 XEN_CALL_("VBD_metrics.get_io_write_kbs");
ewan@14045 141 return session->ok;
ewan@14045 142 }
ewan@14045 143
ewan@14045 144
ewan@14045 145 bool
ewan@14045 146 xen_vbd_metrics_get_uuid(xen_session *session, char **result, xen_vbd_metrics vbd_metrics)
ewan@14045 147 {
ewan@14045 148 *result = session->ok ? xen_strdup_((char *)vbd_metrics) : NULL;
ewan@14045 149 return session->ok;
ewan@14045 150 }