ia64/xen-unstable

changeset 14042:8773b1a38c83

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>
author Ewan Mellor <ewan@xensource.com>
date Tue Feb 20 16:30:24 2007 +0000 (2007-02-20)
parents 8bcd71c3b495
children be35eed950da
files docs/xen-api/xenapi-datamodel.tex tools/libxen/include/xen_vm_metrics.h tools/libxen/src/xen_vm_metrics.c tools/libxen/test/test_bindings.c
line diff
     1.1 --- a/docs/xen-api/xenapi-datamodel.tex	Tue Feb 20 15:24:01 2007 +0000
     1.2 +++ b/docs/xen-api/xenapi-datamodel.tex	Tue Feb 20 16:30:24 2007 +0000
     1.3 @@ -61,7 +61,6 @@ VIF.VM & VM.VIFs & one-to-many\\
     1.4  VIF.network & network.VIFs & one-to-many\\
     1.5  host.metrics & host\_metrics.host & one-to-one\\
     1.6  PIF.metrics & PIF\_metrics.PIF & one-to-one\\
     1.7 -VM.metrics & VM\_metrics.VM & one-to-one\\
     1.8  PIF.host & host.PIFs & one-to-many\\
     1.9  PIF.network & network.PIFs & one-to-many\\
    1.10  SR.VDIs & VDI.SR & many-to-one\\
    1.11 @@ -1076,8 +1075,6 @@ Quals & Field & Type & Description \\
    1.12  $\mathit{RW}$ &  {\tt VCPUs/params} & (string $\rightarrow$ string) Map & configuration parameters for the selected VCPU policy \\
    1.13  $\mathit{RW}$ &  {\tt VCPUs/max} & int & Max number of VCPUs \\
    1.14  $\mathit{RW}$ &  {\tt VCPUs/at\_startup} & int & Boot number of VCPUs \\
    1.15 -$\mathit{RO}_\mathit{ins}$ &  {\tt VCPUs/number} & int & Current number of VCPUs \\
    1.16 -$\mathit{RO}_\mathit{run}$ &  {\tt VCPUs/utilisation} & (int $\rightarrow$ float) Map & Utilisation for all of guest's current VCPUs \\
    1.17  $\mathit{RW}$ &  {\tt actions/after\_shutdown} & on\_normal\_exit & action to take after the guest has shutdown itself \\
    1.18  $\mathit{RW}$ &  {\tt actions/after\_reboot} & on\_normal\_exit & action to take after the guest has rebooted itself \\
    1.19  $\mathit{RW}$ &  {\tt actions/after\_crash} & on\_crash\_behaviour & action to take if the guest crashes \\
    1.20 @@ -1102,7 +1099,7 @@ Quals & Field & Type & Description \\
    1.21  $\mathit{RO}_\mathit{run}$ &  {\tt tools\_version} & (string $\rightarrow$ string) Map & versions of installed paravirtualised drivers \\
    1.22  $\mathit{RW}$ &  {\tt other\_config} & (string $\rightarrow$ string) Map & additional configuration \\
    1.23  $\mathit{RO}_\mathit{run}$ &  {\tt is\_control\_domain} & bool & true if this is a control domain (domain 0 or a driver domain) \\
    1.24 -$\mathit{RO}_\mathit{ins}$ &  {\tt metrics} & VM\_metrics ref & metrics associated with this VM. \\
    1.25 +$\mathit{RO}_\mathit{run}$ &  {\tt metrics} & VM\_metrics ref & metrics associated with this VM. \\
    1.26  \hline
    1.27  \end{longtable}
    1.28  \subsection{Additional RPCs associated with class: VM}
    1.29 @@ -2548,70 +2545,6 @@ void
    1.30  \vspace{0.3cm}
    1.31  \vspace{0.3cm}
    1.32  \vspace{0.3cm}
    1.33 -\subsubsection{RPC name:~get\_VCPUs\_number}
    1.34 -
    1.35 -{\bf Overview:} 
    1.36 -Get the VCPUs/number field of the given VM.
    1.37 -
    1.38 - \noindent {\bf Signature:} 
    1.39 -\begin{verbatim} int get_VCPUs_number (session_id s, VM ref self)\end{verbatim}
    1.40 -
    1.41 -
    1.42 -\noindent{\bf Arguments:}
    1.43 -
    1.44 - 
    1.45 -\vspace{0.3cm}
    1.46 -\begin{tabular}{|c|c|p{7cm}|}
    1.47 - \hline
    1.48 -{\bf type} & {\bf name} & {\bf description} \\ \hline
    1.49 -{\tt VM ref } & self & reference to the object \\ \hline 
    1.50 -
    1.51 -\end{tabular}
    1.52 -
    1.53 -\vspace{0.3cm}
    1.54 -
    1.55 - \noindent {\bf Return Type:} 
    1.56 -{\tt 
    1.57 -int
    1.58 -}
    1.59 -
    1.60 -
    1.61 -value of the field
    1.62 -\vspace{0.3cm}
    1.63 -\vspace{0.3cm}
    1.64 -\vspace{0.3cm}
    1.65 -\subsubsection{RPC name:~get\_VCPUs\_utilisation}
    1.66 -
    1.67 -{\bf Overview:} 
    1.68 -Get the VCPUs/utilisation field of the given VM.
    1.69 -
    1.70 - \noindent {\bf Signature:} 
    1.71 -\begin{verbatim} ((int -> float) Map) get_VCPUs_utilisation (session_id s, VM ref self)\end{verbatim}
    1.72 -
    1.73 -
    1.74 -\noindent{\bf Arguments:}
    1.75 -
    1.76 - 
    1.77 -\vspace{0.3cm}
    1.78 -\begin{tabular}{|c|c|p{7cm}|}
    1.79 - \hline
    1.80 -{\bf type} & {\bf name} & {\bf description} \\ \hline
    1.81 -{\tt VM ref } & self & reference to the object \\ \hline 
    1.82 -
    1.83 -\end{tabular}
    1.84 -
    1.85 -\vspace{0.3cm}
    1.86 -
    1.87 - \noindent {\bf Return Type:} 
    1.88 -{\tt 
    1.89 -(int $\rightarrow$ float) Map
    1.90 -}
    1.91 -
    1.92 -
    1.93 -value of the field
    1.94 -\vspace{0.3cm}
    1.95 -\vspace{0.3cm}
    1.96 -\vspace{0.3cm}
    1.97  \subsubsection{RPC name:~get\_actions\_after\_shutdown}
    1.98  
    1.99  {\bf Overview:} 
   1.100 @@ -4273,7 +4206,6 @@ The metrics associated with a VM.}} \\
   1.101  Quals & Field & Type & Description \\
   1.102  \hline
   1.103  $\mathit{RO}_\mathit{run}$ &  {\tt uuid} & string & unique identifier/object reference \\
   1.104 -$\mathit{RO}_\mathit{ins}$ &  {\tt VM} & VM ref & VM to which these metrics apply \\
   1.105  $\mathit{RO}_\mathit{run}$ &  {\tt memory/actual} & int & Guest's actual memory (bytes) \\
   1.106  $\mathit{RO}_\mathit{run}$ &  {\tt VCPUs/number} & int & Current number of VCPUs \\
   1.107  $\mathit{RO}_\mathit{run}$ &  {\tt VCPUs/utilisation} & (int $\rightarrow$ float) Map & Utilisation for all of guest's current VCPUs \\
   1.108 @@ -4312,38 +4244,6 @@ value of the field
   1.109  \vspace{0.3cm}
   1.110  \vspace{0.3cm}
   1.111  \vspace{0.3cm}
   1.112 -\subsubsection{RPC name:~get\_VM}
   1.113 -
   1.114 -{\bf Overview:} 
   1.115 -Get the VM field of the given VM\_metrics.
   1.116 -
   1.117 - \noindent {\bf Signature:} 
   1.118 -\begin{verbatim} (VM ref) get_VM (session_id s, VM_metrics ref self)\end{verbatim}
   1.119 -
   1.120 -
   1.121 -\noindent{\bf Arguments:}
   1.122 -
   1.123 - 
   1.124 -\vspace{0.3cm}
   1.125 -\begin{tabular}{|c|c|p{7cm}|}
   1.126 - \hline
   1.127 -{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.128 -{\tt VM\_metrics ref } & self & reference to the object \\ \hline 
   1.129 -
   1.130 -\end{tabular}
   1.131 -
   1.132 -\vspace{0.3cm}
   1.133 -
   1.134 - \noindent {\bf Return Type:} 
   1.135 -{\tt 
   1.136 -VM ref
   1.137 -}
   1.138 -
   1.139 -
   1.140 -value of the field
   1.141 -\vspace{0.3cm}
   1.142 -\vspace{0.3cm}
   1.143 -\vspace{0.3cm}
   1.144  \subsubsection{RPC name:~get\_memory\_actual}
   1.145  
   1.146  {\bf Overview:} 
     2.1 --- a/tools/libxen/include/xen_vm_metrics.h	Tue Feb 20 15:24:01 2007 +0000
     2.2 +++ b/tools/libxen/include/xen_vm_metrics.h	Tue Feb 20 16:30:24 2007 +0000
     2.3 @@ -1,5 +1,5 @@
     2.4  /*
     2.5 - * Copyright (c) 2006, XenSource Inc.
     2.6 + * Copyright (c) 2006-2007, XenSource Inc.
     2.7   *
     2.8   * This library is free software; you can redistribute it and/or
     2.9   * modify it under the terms of the GNU Lesser General Public
    2.10 @@ -21,7 +21,6 @@
    2.11  
    2.12  #include "xen_common.h"
    2.13  #include "xen_int_float_map.h"
    2.14 -#include "xen_vm_decl.h"
    2.15  #include "xen_vm_metrics_decl.h"
    2.16  
    2.17  
    2.18 @@ -64,7 +63,6 @@ typedef struct xen_vm_metrics_record
    2.19  {
    2.20      xen_vm_metrics handle;
    2.21      char *uuid;
    2.22 -    struct xen_vm_record_opt *vm;
    2.23      int64_t memory_actual;
    2.24      int64_t vcpus_number;
    2.25      xen_int_float_map *vcpus_utilisation;
    2.26 @@ -171,13 +169,6 @@ xen_vm_metrics_get_uuid(xen_session *ses
    2.27  
    2.28  
    2.29  /**
    2.30 - * Get the VM field of the given VM_metrics.
    2.31 - */
    2.32 -extern bool
    2.33 -xen_vm_metrics_get_vm(xen_session *session, xen_vm *result, xen_vm_metrics vm_metrics);
    2.34 -
    2.35 -
    2.36 -/**
    2.37   * Get the memory/actual field of the given VM_metrics.
    2.38   */
    2.39  extern bool
     3.1 --- a/tools/libxen/src/xen_vm_metrics.c	Tue Feb 20 15:24:01 2007 +0000
     3.2 +++ b/tools/libxen/src/xen_vm_metrics.c	Tue Feb 20 16:30:24 2007 +0000
     3.3 @@ -1,5 +1,5 @@
     3.4  /*
     3.5 - * Copyright (c) 2006, XenSource Inc.
     3.6 + * Copyright (c) 2006-2007, XenSource Inc.
     3.7   *
     3.8   * This library is free software; you can redistribute it and/or
     3.9   * modify it under the terms of the GNU Lesser General Public
    3.10 @@ -23,7 +23,6 @@
    3.11  #include "xen_common.h"
    3.12  #include "xen_int_float_map.h"
    3.13  #include "xen_internal.h"
    3.14 -#include "xen_vm.h"
    3.15  #include "xen_vm_metrics.h"
    3.16  
    3.17  
    3.18 @@ -41,9 +40,6 @@ static const struct_member xen_vm_metric
    3.19          { .key = "uuid",
    3.20            .type = &abstract_type_string,
    3.21            .offset = offsetof(xen_vm_metrics_record, uuid) },
    3.22 -        { .key = "VM",
    3.23 -          .type = &abstract_type_ref,
    3.24 -          .offset = offsetof(xen_vm_metrics_record, vm) },
    3.25          { .key = "memory_actual",
    3.26            .type = &abstract_type_int,
    3.27            .offset = offsetof(xen_vm_metrics_record, memory_actual) },
    3.28 @@ -74,7 +70,6 @@ xen_vm_metrics_record_free(xen_vm_metric
    3.29      }
    3.30      free(record->handle);
    3.31      free(record->uuid);
    3.32 -    xen_vm_record_opt_free(record->vm);
    3.33      xen_int_float_map_free(record->vcpus_utilisation);
    3.34      free(record);
    3.35  }
    3.36 @@ -121,23 +116,6 @@ xen_vm_metrics_get_by_uuid(xen_session *
    3.37  
    3.38  
    3.39  bool
    3.40 -xen_vm_metrics_get_vm(xen_session *session, xen_vm *result, xen_vm_metrics vm_metrics)
    3.41 -{
    3.42 -    abstract_value param_values[] =
    3.43 -        {
    3.44 -            { .type = &abstract_type_string,
    3.45 -              .u.string_val = vm_metrics }
    3.46 -        };
    3.47 -
    3.48 -    abstract_type result_type = abstract_type_string;
    3.49 -
    3.50 -    *result = NULL;
    3.51 -    XEN_CALL_("VM_metrics.get_VM");
    3.52 -    return session->ok;
    3.53 -}
    3.54 -
    3.55 -
    3.56 -bool
    3.57  xen_vm_metrics_get_memory_actual(xen_session *session, int64_t *result, xen_vm_metrics vm_metrics)
    3.58  {
    3.59      abstract_value param_values[] =
     4.1 --- a/tools/libxen/test/test_bindings.c	Tue Feb 20 15:24:01 2007 +0000
     4.2 +++ b/tools/libxen/test/test_bindings.c	Tue Feb 20 16:30:24 2007 +0000
     4.3 @@ -31,6 +31,7 @@
     4.4  #include "xen_vdi.h"
     4.5  #include "xen_console.h"
     4.6  #include "xen_vm.h"
     4.7 +#include "xen_vm_metrics.h"
     4.8  
     4.9  
    4.10  static void usage()
    4.11 @@ -61,6 +62,7 @@ typedef struct
    4.12  
    4.13  static xen_vm create_new_vm(xen_session *session, bool hvm);
    4.14  static void print_vm_power_state(xen_session *session, xen_vm vm);
    4.15 +static void print_vm_metrics(xen_session *session, xen_vm vm);
    4.16  
    4.17  
    4.18  static size_t
    4.19 @@ -245,12 +247,7 @@ int main(int argc, char **argv)
    4.20  
    4.21      printf("%s.\n", xen_vm_power_state_to_string(vm_record->power_state));
    4.22  
    4.23 -    for (size_t i = 0; i < vm_record->vcpus_utilisation->size; i++)
    4.24 -    {
    4.25 -        printf("%"PRId64" -> %lf.\n",
    4.26 -               vm_record->vcpus_utilisation->contents[i].key,
    4.27 -               vm_record->vcpus_utilisation->contents[i].val);
    4.28 -    }
    4.29 +    print_vm_metrics(session, vm);
    4.30  
    4.31      xen_uuid_bytes_free(vm_uuid_bytes);
    4.32      xen_uuid_free(vm_uuid);
    4.33 @@ -323,7 +320,6 @@ static xen_vm create_new_vm(xen_session 
    4.34              .memory_static_min = 128,
    4.35              .vcpus_policy = "credit",
    4.36              .vcpus_params = vcpus_params,
    4.37 -            .vcpus_number = 2,
    4.38              .actions_after_shutdown = XEN_ON_NORMAL_EXIT_DESTROY,
    4.39              .actions_after_reboot = XEN_ON_NORMAL_EXIT_RESTART,
    4.40              .actions_after_crash = XEN_ON_CRASH_BEHAVIOUR_PRESERVE,
    4.41 @@ -519,3 +515,35 @@ static void print_vm_power_state(xen_ses
    4.42  
    4.43      xen_uuid_free(vm_uuid);
    4.44  }
    4.45 +
    4.46 +
    4.47 +/**
    4.48 + * Print the metrics for the given VM.
    4.49 + */
    4.50 +static void print_vm_metrics(xen_session *session, xen_vm vm)
    4.51 +{
    4.52 +    xen_vm_metrics vm_metrics;
    4.53 +    if (!xen_vm_get_metrics(session, &vm_metrics, vm))
    4.54 +    {
    4.55 +        print_error(session);
    4.56 +        return;
    4.57 +    }
    4.58 +
    4.59 +    xen_vm_metrics_record *vm_metrics_record;
    4.60 +    if (!xen_vm_metrics_get_record(session, &vm_metrics_record, vm_metrics))
    4.61 +    {
    4.62 +        xen_vm_metrics_free(vm_metrics);
    4.63 +        print_error(session);
    4.64 +        return;
    4.65 +    }
    4.66 +
    4.67 +    for (size_t i = 0; i < vm_metrics_record->vcpus_utilisation->size; i++)
    4.68 +    {
    4.69 +        printf("%"PRId64" -> %lf.\n",
    4.70 +               vm_metrics_record->vcpus_utilisation->contents[i].key,
    4.71 +               vm_metrics_record->vcpus_utilisation->contents[i].val);
    4.72 +    }
    4.73 +
    4.74 +    xen_vm_metrics_record_free(vm_metrics_record);
    4.75 +    xen_vm_metrics_free(vm_metrics);
    4.76 +}