aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxen
diff options
context:
space:
mode:
authorEwan Mellor <ewan@xensource.com>2007-02-20 16:30:24 +0000
committerEwan Mellor <ewan@xensource.com>2007-02-20 16:30:24 +0000
commitada588411f0ee53081fa6054e073089a4aa6cc4f (patch)
tree1739b910399c61336c1a0c6b27a035972d73ae67 /tools/libxen
parentd5ae26ac7a9d955283792e882ec4090d69442302 (diff)
downloadxen-ada588411f0ee53081fa6054e073089a4aa6cc4f.tar.gz
xen-ada588411f0ee53081fa6054e073089a4aa6cc4f.tar.bz2
xen-ada588411f0ee53081fa6054e073089a4aa6cc4f.zip
Remove VM.VCPUs_number and VM.VCPUs_utilisation as these have moved onto the
VM_metrics class. Remove VM_metrics.VM -- the backreference is unnecessary and awkward to deal with. Signed-off-by: Ewan Mellor <ewan@xensource.com>
Diffstat (limited to 'tools/libxen')
-rw-r--r--tools/libxen/include/xen_vm_metrics.h11
-rw-r--r--tools/libxen/src/xen_vm_metrics.c24
-rw-r--r--tools/libxen/test/test_bindings.c42
3 files changed, 37 insertions, 40 deletions
diff --git a/tools/libxen/include/xen_vm_metrics.h b/tools/libxen/include/xen_vm_metrics.h
index 740e327d10..e3b06c214b 100644
--- a/tools/libxen/include/xen_vm_metrics.h
+++ b/tools/libxen/include/xen_vm_metrics.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, XenSource Inc.
+ * 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
@@ -21,7 +21,6 @@
#include "xen_common.h"
#include "xen_int_float_map.h"
-#include "xen_vm_decl.h"
#include "xen_vm_metrics_decl.h"
@@ -64,7 +63,6 @@ typedef struct xen_vm_metrics_record
{
xen_vm_metrics handle;
char *uuid;
- struct xen_vm_record_opt *vm;
int64_t memory_actual;
int64_t vcpus_number;
xen_int_float_map *vcpus_utilisation;
@@ -171,13 +169,6 @@ xen_vm_metrics_get_uuid(xen_session *session, char **result, xen_vm_metrics vm_m
/**
- * Get the VM field of the given VM_metrics.
- */
-extern bool
-xen_vm_metrics_get_vm(xen_session *session, xen_vm *result, xen_vm_metrics vm_metrics);
-
-
-/**
* Get the memory/actual field of the given VM_metrics.
*/
extern bool
diff --git a/tools/libxen/src/xen_vm_metrics.c b/tools/libxen/src/xen_vm_metrics.c
index 03a08d8971..6f5e95166e 100644
--- a/tools/libxen/src/xen_vm_metrics.c
+++ b/tools/libxen/src/xen_vm_metrics.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, XenSource Inc.
+ * 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
@@ -23,7 +23,6 @@
#include "xen_common.h"
#include "xen_int_float_map.h"
#include "xen_internal.h"
-#include "xen_vm.h"
#include "xen_vm_metrics.h"
@@ -41,9 +40,6 @@ static const struct_member xen_vm_metrics_record_struct_members[] =
{ .key = "uuid",
.type = &abstract_type_string,
.offset = offsetof(xen_vm_metrics_record, uuid) },
- { .key = "VM",
- .type = &abstract_type_ref,
- .offset = offsetof(xen_vm_metrics_record, vm) },
{ .key = "memory_actual",
.type = &abstract_type_int,
.offset = offsetof(xen_vm_metrics_record, memory_actual) },
@@ -74,7 +70,6 @@ xen_vm_metrics_record_free(xen_vm_metrics_record *record)
}
free(record->handle);
free(record->uuid);
- xen_vm_record_opt_free(record->vm);
xen_int_float_map_free(record->vcpus_utilisation);
free(record);
}
@@ -121,23 +116,6 @@ xen_vm_metrics_get_by_uuid(xen_session *session, xen_vm_metrics *result, char *u
bool
-xen_vm_metrics_get_vm(xen_session *session, xen_vm *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;
-
- *result = NULL;
- XEN_CALL_("VM_metrics.get_VM");
- return session->ok;
-}
-
-
-bool
xen_vm_metrics_get_memory_actual(xen_session *session, int64_t *result, xen_vm_metrics vm_metrics)
{
abstract_value param_values[] =
diff --git a/tools/libxen/test/test_bindings.c b/tools/libxen/test/test_bindings.c
index c1df98dcea..90d33e4ff8 100644
--- a/tools/libxen/test/test_bindings.c
+++ b/tools/libxen/test/test_bindings.c
@@ -31,6 +31,7 @@
#include "xen_vdi.h"
#include "xen_console.h"
#include "xen_vm.h"
+#include "xen_vm_metrics.h"
static void usage()
@@ -61,6 +62,7 @@ typedef struct
static xen_vm create_new_vm(xen_session *session, bool hvm);
static void print_vm_power_state(xen_session *session, xen_vm vm);
+static void print_vm_metrics(xen_session *session, xen_vm vm);
static size_t
@@ -245,12 +247,7 @@ int main(int argc, char **argv)
printf("%s.\n", xen_vm_power_state_to_string(vm_record->power_state));
- for (size_t i = 0; i < vm_record->vcpus_utilisation->size; i++)
- {
- printf("%"PRId64" -> %lf.\n",
- vm_record->vcpus_utilisation->contents[i].key,
- vm_record->vcpus_utilisation->contents[i].val);
- }
+ print_vm_metrics(session, vm);
xen_uuid_bytes_free(vm_uuid_bytes);
xen_uuid_free(vm_uuid);
@@ -323,7 +320,6 @@ static xen_vm create_new_vm(xen_session *session, bool hvm)
.memory_static_min = 128,
.vcpus_policy = "credit",
.vcpus_params = vcpus_params,
- .vcpus_number = 2,
.actions_after_shutdown = XEN_ON_NORMAL_EXIT_DESTROY,
.actions_after_reboot = XEN_ON_NORMAL_EXIT_RESTART,
.actions_after_crash = XEN_ON_CRASH_BEHAVIOUR_PRESERVE,
@@ -519,3 +515,35 @@ static void print_vm_power_state(xen_session *session, xen_vm vm)
xen_uuid_free(vm_uuid);
}
+
+
+/**
+ * Print the metrics for the given VM.
+ */
+static void print_vm_metrics(xen_session *session, xen_vm vm)
+{
+ xen_vm_metrics vm_metrics;
+ if (!xen_vm_get_metrics(session, &vm_metrics, vm))
+ {
+ print_error(session);
+ return;
+ }
+
+ xen_vm_metrics_record *vm_metrics_record;
+ if (!xen_vm_metrics_get_record(session, &vm_metrics_record, vm_metrics))
+ {
+ xen_vm_metrics_free(vm_metrics);
+ print_error(session);
+ return;
+ }
+
+ for (size_t i = 0; i < vm_metrics_record->vcpus_utilisation->size; i++)
+ {
+ printf("%"PRId64" -> %lf.\n",
+ vm_metrics_record->vcpus_utilisation->contents[i].key,
+ vm_metrics_record->vcpus_utilisation->contents[i].val);
+ }
+
+ xen_vm_metrics_record_free(vm_metrics_record);
+ xen_vm_metrics_free(vm_metrics);
+}