aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxen/src
diff options
context:
space:
mode:
authorEwan Mellor <ewan@xensource.com>2007-04-09 17:09:21 +0100
committerEwan Mellor <ewan@xensource.com>2007-04-09 17:09:21 +0100
commit6492f2ffbf3fadb112a5e819c1afb56cd258893c (patch)
tree23acde499a940cb3a4597adfabf64a7687b6fa8c /tools/libxen/src
parent668fbded84ff31d548ae5e84419b2acab88600e2 (diff)
downloadxen-6492f2ffbf3fadb112a5e819c1afb56cd258893c.tar.gz
xen-6492f2ffbf3fadb112a5e819c1afb56cd258893c.tar.bz2
xen-6492f2ffbf3fadb112a5e819c1afb56cd258893c.zip
Added documentation, C bindings, and a test for VM_metrics.{start_time,
VCPUs_CPU,VCPUs_params}. Changed VM_metrics.start_time to be a DateTime, not an integer. Signed-off-by: Ewan Mellor <ewan@xensource.com>
Diffstat (limited to 'tools/libxen/src')
-rw-r--r--tools/libxen/src/xen_common.c19
-rw-r--r--tools/libxen/src/xen_int_int_map.c39
-rw-r--r--tools/libxen/src/xen_vm_metrics.c63
3 files changed, 121 insertions, 0 deletions
diff --git a/tools/libxen/src/xen_common.c b/tools/libxen/src/xen_common.c
index 70ecc1e4fc..6b52723d9d 100644
--- a/tools/libxen/src/xen_common.c
+++ b/tools/libxen/src/xen_common.c
@@ -35,6 +35,7 @@
#include "xen_host.h"
#include "xen_internal.h"
#include "xen_int_float_map.h"
+#include "xen_int_int_map.h"
#include "xen_string_string_map.h"
@@ -1697,3 +1698,21 @@ const abstract_type abstract_type_int_float_map =
.struct_size = sizeof(xen_int_float_map_contents),
.members = int_float_members
};
+
+static struct struct_member int_int_members[] =
+{
+ {
+ .type = &abstract_type_int,
+ .offset = offsetof(xen_int_int_map_contents, key)
+ },
+ {
+ .type = &abstract_type_int,
+ .offset = offsetof(xen_int_int_map_contents, val)
+ }
+};
+const abstract_type abstract_type_int_int_map =
+ {
+ .typename = MAP,
+ .struct_size = sizeof(xen_int_int_map_contents),
+ .members = int_int_members
+ };
diff --git a/tools/libxen/src/xen_int_int_map.c b/tools/libxen/src/xen_int_int_map.c
new file mode 100644
index 0000000000..b7eeba6e96
--- /dev/null
+++ b/tools/libxen/src/xen_int_int_map.c
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2006-2007, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "xen_common.h"
+#include "xen_int_int_map.h"
+#include "xen_internal.h"
+
+
+xen_int_int_map *
+xen_int_int_map_alloc(size_t size)
+{
+ xen_int_int_map *result = calloc(1, sizeof(xen_int_int_map) +
+ size * sizeof(struct xen_int_int_map_contents));
+ result->size = size;
+ return result;
+}
+
+
+void
+xen_int_int_map_free(xen_int_int_map *map)
+{
+ free(map);
+}
diff --git a/tools/libxen/src/xen_vm_metrics.c b/tools/libxen/src/xen_vm_metrics.c
index 11e421282b..bd0509bfc4 100644
--- a/tools/libxen/src/xen_vm_metrics.c
+++ b/tools/libxen/src/xen_vm_metrics.c
@@ -22,7 +22,9 @@
#include "xen_common.h"
#include "xen_int_float_map.h"
+#include "xen_int_int_map.h"
#include "xen_internal.h"
+#include "xen_string_string_map.h"
#include "xen_vm_metrics.h"
@@ -49,6 +51,15 @@ static const struct_member xen_vm_metrics_record_struct_members[] =
{ .key = "VCPUs_utilisation",
.type = &abstract_type_int_float_map,
.offset = offsetof(xen_vm_metrics_record, vcpus_utilisation) },
+ { .key = "VCPUs_CPU",
+ .type = &abstract_type_int_int_map,
+ .offset = offsetof(xen_vm_metrics_record, vcpus_cpu) },
+ { .key = "VCPUs_params",
+ .type = &abstract_type_string_string_map,
+ .offset = offsetof(xen_vm_metrics_record, vcpus_params) },
+ { .key = "start_time",
+ .type = &abstract_type_datetime,
+ .offset = offsetof(xen_vm_metrics_record, start_time) },
{ .key = "last_updated",
.type = &abstract_type_datetime,
.offset = offsetof(xen_vm_metrics_record, last_updated) }
@@ -74,6 +85,8 @@ xen_vm_metrics_record_free(xen_vm_metrics_record *record)
free(record->handle);
free(record->uuid);
xen_int_float_map_free(record->vcpus_utilisation);
+ xen_int_int_map_free(record->vcpus_cpu);
+ xen_string_string_map_free(record->vcpus_params);
free(record);
}
@@ -168,6 +181,56 @@ xen_vm_metrics_get_vcpus_utilisation(xen_session *session, xen_int_float_map **r
bool
+xen_vm_metrics_get_vcpus_cpu(xen_session *session, xen_int_int_map **result, xen_vm_metrics vm_metrics)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vm_metrics }
+ };
+
+ abstract_type result_type = abstract_type_int_int_map;
+
+ *result = NULL;
+ XEN_CALL_("VM_metrics.get_VCPUs_CPU");
+ return session->ok;
+}
+
+
+bool
+xen_vm_metrics_get_vcpus_params(xen_session *session, xen_string_string_map **result, xen_vm_metrics vm_metrics)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vm_metrics }
+ };
+
+ abstract_type result_type = abstract_type_string_string_map;
+
+ *result = NULL;
+ XEN_CALL_("VM_metrics.get_VCPUs_params");
+ return session->ok;
+}
+
+
+bool
+xen_vm_metrics_get_start_time(xen_session *session, time_t *result, xen_vm_metrics vm_metrics)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vm_metrics }
+ };
+
+ abstract_type result_type = abstract_type_datetime;
+
+ XEN_CALL_("VM_metrics.get_start_time");
+ return session->ok;
+}
+
+
+bool
xen_vm_metrics_get_last_updated(xen_session *session, time_t *result, xen_vm_metrics vm_metrics)
{
abstract_value param_values[] =