diff options
author | Ewan Mellor <ewan@xensource.com> | 2007-02-20 16:30:24 +0000 |
---|---|---|
committer | Ewan Mellor <ewan@xensource.com> | 2007-02-20 16:30:24 +0000 |
commit | ada588411f0ee53081fa6054e073089a4aa6cc4f (patch) | |
tree | 1739b910399c61336c1a0c6b27a035972d73ae67 /tools/libxen/test | |
parent | d5ae26ac7a9d955283792e882ec4090d69442302 (diff) | |
download | xen-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/test')
-rw-r--r-- | tools/libxen/test/test_bindings.c | 42 |
1 files changed, 35 insertions, 7 deletions
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); +} |