ia64/xen-unstable

changeset 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 988b90c6b4f3
children 0aa6755159d5
files docs/xen-api/xenapi-datamodel.tex tools/libxen/include/xen_vbd.h tools/libxen/include/xen_vbd_metrics.h tools/libxen/include/xen_vbd_metrics_decl.h tools/libxen/include/xen_vbd_type.h tools/libxen/include/xen_vbd_type_internal.h tools/libxen/src/xen_vbd.c tools/libxen/src/xen_vbd_metrics.c tools/libxen/src/xen_vbd_type.c tools/python/xen/xend/XendAPI.py
line diff
     1.1 --- a/docs/xen-api/xenapi-datamodel.tex	Tue Feb 20 19:38:24 2007 +0000
     1.2 +++ b/docs/xen-api/xenapi-datamodel.tex	Tue Feb 20 21:28:19 2007 +0000
     1.3 @@ -36,6 +36,7 @@ Name & Description \\
     1.4  {\tt SR} & A storage repository \\
     1.5  {\tt VDI} & A virtual disk image \\
     1.6  {\tt VBD} & A virtual block device \\
     1.7 +{\tt VBD\_metrics} & The metrics associated with a virtual block device \\
     1.8  {\tt PBD} & The physical block devices through which hosts access SRs \\
     1.9  {\tt crashdump} & A VM crashdump \\
    1.10  {\tt VTPM} & A virtual TPM device \\
    1.11 @@ -9462,8 +9463,7 @@ Quals & Field & Type & Description \\
    1.12  $\mathit{RW}$ &  {\tt bootable} & bool & true if this VBD is bootable \\
    1.13  $\mathit{RW}$ &  {\tt mode} & vbd\_mode & the mode the VBD should be mounted with \\
    1.14  $\mathit{RW}$ &  {\tt type} & vbd\_type & how the VBD will appear to the guest (e.g. disk or CD) \\
    1.15 -$\mathit{RO}_\mathit{run}$ &  {\tt io/read\_kbs} & float & Read bandwidth (KiB/s) \\
    1.16 -$\mathit{RO}_\mathit{run}$ &  {\tt io/write\_kbs} & float & Write bandwidth (KiB/s) \\
    1.17 +$\mathit{RO}_\mathit{run}$ &  {\tt metrics} & VBD\_metrics ref & metrics associated with this VBD. \\
    1.18  \hline
    1.19  \end{longtable}
    1.20  \subsection{Additional RPCs associated with class: VBD}
    1.21 @@ -9862,13 +9862,13 @@ void
    1.22  \vspace{0.3cm}
    1.23  \vspace{0.3cm}
    1.24  \vspace{0.3cm}
    1.25 -\subsubsection{RPC name:~get\_io\_read\_kbs}
    1.26 -
    1.27 -{\bf Overview:} 
    1.28 -Get the io/read\_kbs field of the given VBD.
    1.29 -
    1.30 - \noindent {\bf Signature:} 
    1.31 -\begin{verbatim} float get_io_read_kbs (session_id s, VBD ref self)\end{verbatim}
    1.32 +\subsubsection{RPC name:~get\_metrics}
    1.33 +
    1.34 +{\bf Overview:} 
    1.35 +Get the metrics field of the given VBD.
    1.36 +
    1.37 + \noindent {\bf Signature:} 
    1.38 +\begin{verbatim} (VBD_metrics ref) get_metrics (session_id s, VBD ref self)\end{verbatim}
    1.39  
    1.40  
    1.41  \noindent{\bf Arguments:}
    1.42 @@ -9886,39 +9886,7 @@ Get the io/read\_kbs field of the given 
    1.43  
    1.44   \noindent {\bf Return Type:} 
    1.45  {\tt 
    1.46 -float
    1.47 -}
    1.48 -
    1.49 -
    1.50 -value of the field
    1.51 -\vspace{0.3cm}
    1.52 -\vspace{0.3cm}
    1.53 -\vspace{0.3cm}
    1.54 -\subsubsection{RPC name:~get\_io\_write\_kbs}
    1.55 -
    1.56 -{\bf Overview:} 
    1.57 -Get the io/write\_kbs field of the given VBD.
    1.58 -
    1.59 - \noindent {\bf Signature:} 
    1.60 -\begin{verbatim} float get_io_write_kbs (session_id s, VBD ref self)\end{verbatim}
    1.61 -
    1.62 -
    1.63 -\noindent{\bf Arguments:}
    1.64 -
    1.65 - 
    1.66 -\vspace{0.3cm}
    1.67 -\begin{tabular}{|c|c|p{7cm}|}
    1.68 - \hline
    1.69 -{\bf type} & {\bf name} & {\bf description} \\ \hline
    1.70 -{\tt VBD ref } & self & reference to the object \\ \hline 
    1.71 -
    1.72 -\end{tabular}
    1.73 -
    1.74 -\vspace{0.3cm}
    1.75 -
    1.76 - \noindent {\bf Return Type:} 
    1.77 -{\tt 
    1.78 -float
    1.79 +VBD\_metrics ref
    1.80  }
    1.81  
    1.82  
    1.83 @@ -10057,6 +10025,185 @@ all fields from the object
    1.84  
    1.85  \vspace{1cm}
    1.86  \newpage
    1.87 +\section{Class: VBD\_metrics}
    1.88 +\subsection{Fields for class: VBD\_metrics}
    1.89 +\begin{longtable}{|lllp{0.38\textwidth}|}
    1.90 +\hline
    1.91 +\multicolumn{1}{|l}{Name} & \multicolumn{3}{l|}{\bf VBD\_metrics} \\
    1.92 +\multicolumn{1}{|l}{Description} & \multicolumn{3}{l|}{\parbox{11cm}{\em
    1.93 +The metrics associated with a virtual block device.}} \\
    1.94 +\hline
    1.95 +Quals & Field & Type & Description \\
    1.96 +\hline
    1.97 +$\mathit{RO}_\mathit{run}$ &  {\tt uuid} & string & unique identifier/object reference \\
    1.98 +$\mathit{RO}_\mathit{run}$ &  {\tt io/read\_kbs} & float & Read bandwidth (KiB/s) \\
    1.99 +$\mathit{RO}_\mathit{run}$ &  {\tt io/write\_kbs} & float & Write bandwidth (KiB/s) \\
   1.100 +\hline
   1.101 +\end{longtable}
   1.102 +\subsection{Additional RPCs associated with class: VBD\_metrics}
   1.103 +\subsubsection{RPC name:~get\_uuid}
   1.104 +
   1.105 +{\bf Overview:} 
   1.106 +Get the uuid field of the given VBD\_metrics.
   1.107 +
   1.108 + \noindent {\bf Signature:} 
   1.109 +\begin{verbatim} string get_uuid (session_id s, VBD_metrics ref self)\end{verbatim}
   1.110 +
   1.111 +
   1.112 +\noindent{\bf Arguments:}
   1.113 +
   1.114 + 
   1.115 +\vspace{0.3cm}
   1.116 +\begin{tabular}{|c|c|p{7cm}|}
   1.117 + \hline
   1.118 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.119 +{\tt VBD\_metrics ref } & self & reference to the object \\ \hline 
   1.120 +
   1.121 +\end{tabular}
   1.122 +
   1.123 +\vspace{0.3cm}
   1.124 +
   1.125 + \noindent {\bf Return Type:} 
   1.126 +{\tt 
   1.127 +string
   1.128 +}
   1.129 +
   1.130 +
   1.131 +value of the field
   1.132 +\vspace{0.3cm}
   1.133 +\vspace{0.3cm}
   1.134 +\vspace{0.3cm}
   1.135 +\subsubsection{RPC name:~get\_io\_read\_kbs}
   1.136 +
   1.137 +{\bf Overview:} 
   1.138 +Get the io/read\_kbs field of the given VBD\_metrics.
   1.139 +
   1.140 + \noindent {\bf Signature:} 
   1.141 +\begin{verbatim} float get_io_read_kbs (session_id s, VBD_metrics ref self)\end{verbatim}
   1.142 +
   1.143 +
   1.144 +\noindent{\bf Arguments:}
   1.145 +
   1.146 + 
   1.147 +\vspace{0.3cm}
   1.148 +\begin{tabular}{|c|c|p{7cm}|}
   1.149 + \hline
   1.150 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.151 +{\tt VBD\_metrics ref } & self & reference to the object \\ \hline 
   1.152 +
   1.153 +\end{tabular}
   1.154 +
   1.155 +\vspace{0.3cm}
   1.156 +
   1.157 + \noindent {\bf Return Type:} 
   1.158 +{\tt 
   1.159 +float
   1.160 +}
   1.161 +
   1.162 +
   1.163 +value of the field
   1.164 +\vspace{0.3cm}
   1.165 +\vspace{0.3cm}
   1.166 +\vspace{0.3cm}
   1.167 +\subsubsection{RPC name:~get\_io\_write\_kbs}
   1.168 +
   1.169 +{\bf Overview:} 
   1.170 +Get the io/write\_kbs field of the given VBD\_metrics.
   1.171 +
   1.172 + \noindent {\bf Signature:} 
   1.173 +\begin{verbatim} float get_io_write_kbs (session_id s, VBD_metrics ref self)\end{verbatim}
   1.174 +
   1.175 +
   1.176 +\noindent{\bf Arguments:}
   1.177 +
   1.178 + 
   1.179 +\vspace{0.3cm}
   1.180 +\begin{tabular}{|c|c|p{7cm}|}
   1.181 + \hline
   1.182 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.183 +{\tt VBD\_metrics ref } & self & reference to the object \\ \hline 
   1.184 +
   1.185 +\end{tabular}
   1.186 +
   1.187 +\vspace{0.3cm}
   1.188 +
   1.189 + \noindent {\bf Return Type:} 
   1.190 +{\tt 
   1.191 +float
   1.192 +}
   1.193 +
   1.194 +
   1.195 +value of the field
   1.196 +\vspace{0.3cm}
   1.197 +\vspace{0.3cm}
   1.198 +\vspace{0.3cm}
   1.199 +\subsubsection{RPC name:~get\_by\_uuid}
   1.200 +
   1.201 +{\bf Overview:} 
   1.202 +Get a reference to the VBD\_metrics instance with the specified UUID.
   1.203 +
   1.204 + \noindent {\bf Signature:} 
   1.205 +\begin{verbatim} (VBD_metrics ref) get_by_uuid (session_id s, string uuid)\end{verbatim}
   1.206 +
   1.207 +
   1.208 +\noindent{\bf Arguments:}
   1.209 +
   1.210 + 
   1.211 +\vspace{0.3cm}
   1.212 +\begin{tabular}{|c|c|p{7cm}|}
   1.213 + \hline
   1.214 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.215 +{\tt string } & uuid & UUID of object to return \\ \hline 
   1.216 +
   1.217 +\end{tabular}
   1.218 +
   1.219 +\vspace{0.3cm}
   1.220 +
   1.221 + \noindent {\bf Return Type:} 
   1.222 +{\tt 
   1.223 +VBD\_metrics ref
   1.224 +}
   1.225 +
   1.226 +
   1.227 +reference to the object
   1.228 +\vspace{0.3cm}
   1.229 +\vspace{0.3cm}
   1.230 +\vspace{0.3cm}
   1.231 +\subsubsection{RPC name:~get\_record}
   1.232 +
   1.233 +{\bf Overview:} 
   1.234 +Get a record containing the current state of the given VBD\_metrics.
   1.235 +
   1.236 + \noindent {\bf Signature:} 
   1.237 +\begin{verbatim} (VBD_metrics record) get_record (session_id s, VBD_metrics ref self)\end{verbatim}
   1.238 +
   1.239 +
   1.240 +\noindent{\bf Arguments:}
   1.241 +
   1.242 + 
   1.243 +\vspace{0.3cm}
   1.244 +\begin{tabular}{|c|c|p{7cm}|}
   1.245 + \hline
   1.246 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.247 +{\tt VBD\_metrics ref } & self & reference to the object \\ \hline 
   1.248 +
   1.249 +\end{tabular}
   1.250 +
   1.251 +\vspace{0.3cm}
   1.252 +
   1.253 + \noindent {\bf Return Type:} 
   1.254 +{\tt 
   1.255 +VBD\_metrics record
   1.256 +}
   1.257 +
   1.258 +
   1.259 +all fields from the object
   1.260 +\vspace{0.3cm}
   1.261 +\vspace{0.3cm}
   1.262 +\vspace{0.3cm}
   1.263 +
   1.264 +\vspace{1cm}
   1.265 +\newpage
   1.266  \section{Class: PBD}
   1.267  \subsection{Fields for class: PBD}
   1.268  \begin{longtable}{|lllp{0.38\textwidth}|}
     2.1 --- a/tools/libxen/include/xen_vbd.h	Tue Feb 20 19:38:24 2007 +0000
     2.2 +++ b/tools/libxen/include/xen_vbd.h	Tue Feb 20 21:28:19 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,9 @@
    2.11  
    2.12  #include "xen_common.h"
    2.13  #include "xen_vbd_decl.h"
    2.14 +#include "xen_vbd_metrics_decl.h"
    2.15  #include "xen_vbd_mode.h"
    2.16 +#include "xen_vbd_type.h"
    2.17  #include "xen_vdi_decl.h"
    2.18  #include "xen_vm_decl.h"
    2.19  
    2.20 @@ -71,8 +73,8 @@ typedef struct xen_vbd_record
    2.21      char *image;
    2.22      bool bootable;
    2.23      enum xen_vbd_mode mode;
    2.24 -    double io_read_kbs;
    2.25 -    double io_write_kbs;
    2.26 +    enum xen_vbd_type type;
    2.27 +    struct xen_vbd_metrics_record_opt *metrics;
    2.28  } xen_vbd_record;
    2.29  
    2.30  /**
    2.31 @@ -155,14 +157,14 @@ xen_vbd_record_opt_set_free(xen_vbd_reco
    2.32  
    2.33  
    2.34  /**
    2.35 - * Get the current state of the given VBD.  !!!
    2.36 + * Get a record containing the current state of the given VBD.
    2.37   */
    2.38  extern bool
    2.39  xen_vbd_get_record(xen_session *session, xen_vbd_record **result, xen_vbd vbd);
    2.40  
    2.41  
    2.42  /**
    2.43 - * Get a reference to the object with the specified UUID.  !!!
    2.44 + * Get a reference to the VBD instance with the specified UUID.
    2.45   */
    2.46  extern bool
    2.47  xen_vbd_get_by_uuid(xen_session *session, xen_vbd *result, char *uuid);
    2.48 @@ -225,17 +227,17 @@ xen_vbd_get_mode(xen_session *session, e
    2.49  
    2.50  
    2.51  /**
    2.52 - * Get the io/read_kbs field of the given VBD.
    2.53 + * Get the type field of the given VBD.
    2.54   */
    2.55  extern bool
    2.56 -xen_vbd_get_io_read_kbs(xen_session *session, double *result, xen_vbd vbd);
    2.57 +xen_vbd_get_type(xen_session *session, enum xen_vbd_type *result, xen_vbd vbd);
    2.58  
    2.59  
    2.60  /**
    2.61 - * Get the io/write_kbs field of the given VBD.
    2.62 + * Get the metrics field of the given VBD.
    2.63   */
    2.64  extern bool
    2.65 -xen_vbd_get_io_write_kbs(xen_session *session, double *result, xen_vbd vbd);
    2.66 +xen_vbd_get_metrics(xen_session *session, xen_vbd_metrics *result, xen_vbd vbd);
    2.67  
    2.68  
    2.69  /**
    2.70 @@ -260,6 +262,13 @@ xen_vbd_set_mode(xen_session *session, x
    2.71  
    2.72  
    2.73  /**
    2.74 + * Set the type field of the given VBD.
    2.75 + */
    2.76 +extern bool
    2.77 +xen_vbd_set_type(xen_session *session, xen_vbd vbd, enum xen_vbd_type type);
    2.78 +
    2.79 +
    2.80 +/**
    2.81   * Change the media in the device for CDROM-like devices only. For
    2.82   * other devices, detach the VBD and attach a new one
    2.83   */
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/tools/libxen/include/xen_vbd_metrics.h	Tue Feb 20 21:28:19 2007 +0000
     3.3 @@ -0,0 +1,183 @@
     3.4 +/*
     3.5 + * Copyright (c) 2006-2007, XenSource Inc.
     3.6 + *
     3.7 + * This library is free software; you can redistribute it and/or
     3.8 + * modify it under the terms of the GNU Lesser General Public
     3.9 + * License as published by the Free Software Foundation; either
    3.10 + * version 2.1 of the License, or (at your option) any later version.
    3.11 + *
    3.12 + * This library is distributed in the hope that it will be useful,
    3.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    3.15 + * Lesser General Public License for more details.
    3.16 + *
    3.17 + * You should have received a copy of the GNU Lesser General Public
    3.18 + * License along with this library; if not, write to the Free Software
    3.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
    3.20 + */
    3.21 +
    3.22 +#ifndef XEN_VBD_METRICS_H
    3.23 +#define XEN_VBD_METRICS_H
    3.24 +
    3.25 +#include "xen_common.h"
    3.26 +#include "xen_vbd_metrics_decl.h"
    3.27 +
    3.28 +
    3.29 +/*
    3.30 + * The VBD_metrics class.
    3.31 + * 
    3.32 + * The metrics associated with a virtual block device.
    3.33 + */
    3.34 +
    3.35 +
    3.36 +/**
    3.37 + * Free the given xen_vbd_metrics.  The given handle must have been
    3.38 + * allocated by this library.
    3.39 + */
    3.40 +extern void
    3.41 +xen_vbd_metrics_free(xen_vbd_metrics vbd_metrics);
    3.42 +
    3.43 +
    3.44 +typedef struct xen_vbd_metrics_set
    3.45 +{
    3.46 +    size_t size;
    3.47 +    xen_vbd_metrics *contents[];
    3.48 +} xen_vbd_metrics_set;
    3.49 +
    3.50 +/**
    3.51 + * Allocate a xen_vbd_metrics_set of the given size.
    3.52 + */
    3.53 +extern xen_vbd_metrics_set *
    3.54 +xen_vbd_metrics_set_alloc(size_t size);
    3.55 +
    3.56 +/**
    3.57 + * Free the given xen_vbd_metrics_set.  The given set must have been
    3.58 + * allocated by this library.
    3.59 + */
    3.60 +extern void
    3.61 +xen_vbd_metrics_set_free(xen_vbd_metrics_set *set);
    3.62 +
    3.63 +
    3.64 +typedef struct xen_vbd_metrics_record
    3.65 +{
    3.66 +    xen_vbd_metrics handle;
    3.67 +    char *uuid;
    3.68 +    double io_read_kbs;
    3.69 +    double io_write_kbs;
    3.70 +} xen_vbd_metrics_record;
    3.71 +
    3.72 +/**
    3.73 + * Allocate a xen_vbd_metrics_record.
    3.74 + */
    3.75 +extern xen_vbd_metrics_record *
    3.76 +xen_vbd_metrics_record_alloc(void);
    3.77 +
    3.78 +/**
    3.79 + * Free the given xen_vbd_metrics_record, and all referenced values. 
    3.80 + * The given record must have been allocated by this library.
    3.81 + */
    3.82 +extern void
    3.83 +xen_vbd_metrics_record_free(xen_vbd_metrics_record *record);
    3.84 +
    3.85 +
    3.86 +typedef struct xen_vbd_metrics_record_opt
    3.87 +{
    3.88 +    bool is_record;
    3.89 +    union
    3.90 +    {
    3.91 +        xen_vbd_metrics handle;
    3.92 +        xen_vbd_metrics_record *record;
    3.93 +    } u;
    3.94 +} xen_vbd_metrics_record_opt;
    3.95 +
    3.96 +/**
    3.97 + * Allocate a xen_vbd_metrics_record_opt.
    3.98 + */
    3.99 +extern xen_vbd_metrics_record_opt *
   3.100 +xen_vbd_metrics_record_opt_alloc(void);
   3.101 +
   3.102 +/**
   3.103 + * Free the given xen_vbd_metrics_record_opt, and all referenced
   3.104 + * values.  The given record_opt must have been allocated by this library.
   3.105 + */
   3.106 +extern void
   3.107 +xen_vbd_metrics_record_opt_free(xen_vbd_metrics_record_opt *record_opt);
   3.108 +
   3.109 +
   3.110 +typedef struct xen_vbd_metrics_record_set
   3.111 +{
   3.112 +    size_t size;
   3.113 +    xen_vbd_metrics_record *contents[];
   3.114 +} xen_vbd_metrics_record_set;
   3.115 +
   3.116 +/**
   3.117 + * Allocate a xen_vbd_metrics_record_set of the given size.
   3.118 + */
   3.119 +extern xen_vbd_metrics_record_set *
   3.120 +xen_vbd_metrics_record_set_alloc(size_t size);
   3.121 +
   3.122 +/**
   3.123 + * Free the given xen_vbd_metrics_record_set, and all referenced
   3.124 + * values.  The given set must have been allocated by this library.
   3.125 + */
   3.126 +extern void
   3.127 +xen_vbd_metrics_record_set_free(xen_vbd_metrics_record_set *set);
   3.128 +
   3.129 +
   3.130 +
   3.131 +typedef struct xen_vbd_metrics_record_opt_set
   3.132 +{
   3.133 +    size_t size;
   3.134 +    xen_vbd_metrics_record_opt *contents[];
   3.135 +} xen_vbd_metrics_record_opt_set;
   3.136 +
   3.137 +/**
   3.138 + * Allocate a xen_vbd_metrics_record_opt_set of the given size.
   3.139 + */
   3.140 +extern xen_vbd_metrics_record_opt_set *
   3.141 +xen_vbd_metrics_record_opt_set_alloc(size_t size);
   3.142 +
   3.143 +/**
   3.144 + * Free the given xen_vbd_metrics_record_opt_set, and all referenced
   3.145 + * values.  The given set must have been allocated by this library.
   3.146 + */
   3.147 +extern void
   3.148 +xen_vbd_metrics_record_opt_set_free(xen_vbd_metrics_record_opt_set *set);
   3.149 +
   3.150 +
   3.151 +/**
   3.152 + * Get a record containing the current state of the given VBD_metrics.
   3.153 + */
   3.154 +extern bool
   3.155 +xen_vbd_metrics_get_record(xen_session *session, xen_vbd_metrics_record **result, xen_vbd_metrics vbd_metrics);
   3.156 +
   3.157 +
   3.158 +/**
   3.159 + * Get a reference to the VBD_metrics instance with the specified UUID.
   3.160 + */
   3.161 +extern bool
   3.162 +xen_vbd_metrics_get_by_uuid(xen_session *session, xen_vbd_metrics *result, char *uuid);
   3.163 +
   3.164 +
   3.165 +/**
   3.166 + * Get the uuid field of the given VBD_metrics.
   3.167 + */
   3.168 +extern bool
   3.169 +xen_vbd_metrics_get_uuid(xen_session *session, char **result, xen_vbd_metrics vbd_metrics);
   3.170 +
   3.171 +
   3.172 +/**
   3.173 + * Get the io/read_kbs field of the given VBD_metrics.
   3.174 + */
   3.175 +extern bool
   3.176 +xen_vbd_metrics_get_io_read_kbs(xen_session *session, double *result, xen_vbd_metrics vbd_metrics);
   3.177 +
   3.178 +
   3.179 +/**
   3.180 + * Get the io/write_kbs field of the given VBD_metrics.
   3.181 + */
   3.182 +extern bool
   3.183 +xen_vbd_metrics_get_io_write_kbs(xen_session *session, double *result, xen_vbd_metrics vbd_metrics);
   3.184 +
   3.185 +
   3.186 +#endif
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/tools/libxen/include/xen_vbd_metrics_decl.h	Tue Feb 20 21:28:19 2007 +0000
     4.3 @@ -0,0 +1,30 @@
     4.4 +/*
     4.5 + * Copyright (c) 2006-2007, XenSource Inc.
     4.6 + *
     4.7 + * This library is free software; you can redistribute it and/or
     4.8 + * modify it under the terms of the GNU Lesser General Public
     4.9 + * License as published by the Free Software Foundation; either
    4.10 + * version 2.1 of the License, or (at your option) any later version.
    4.11 + *
    4.12 + * This library is distributed in the hope that it will be useful,
    4.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    4.15 + * Lesser General Public License for more details.
    4.16 + *
    4.17 + * You should have received a copy of the GNU Lesser General Public
    4.18 + * License along with this library; if not, write to the Free Software
    4.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
    4.20 + */
    4.21 +
    4.22 +#ifndef XEN_VBD_METRICS_DECL_H
    4.23 +#define XEN_VBD_METRICS_DECL_H
    4.24 +
    4.25 +typedef void *xen_vbd_metrics;
    4.26 +
    4.27 +struct xen_vbd_metrics_set;
    4.28 +struct xen_vbd_metrics_record;
    4.29 +struct xen_vbd_metrics_record_set;
    4.30 +struct xen_vbd_metrics_record_opt;
    4.31 +struct xen_vbd_metrics_record_opt_set;
    4.32 +
    4.33 +#endif
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/tools/libxen/include/xen_vbd_type.h	Tue Feb 20 21:28:19 2007 +0000
     5.3 @@ -0,0 +1,77 @@
     5.4 +/*
     5.5 + * Copyright (c) 2006-2007, XenSource Inc.
     5.6 + *
     5.7 + * This library is free software; you can redistribute it and/or
     5.8 + * modify it under the terms of the GNU Lesser General Public
     5.9 + * License as published by the Free Software Foundation; either
    5.10 + * version 2.1 of the License, or (at your option) any later version.
    5.11 + *
    5.12 + * This library is distributed in the hope that it will be useful,
    5.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    5.15 + * Lesser General Public License for more details.
    5.16 + *
    5.17 + * You should have received a copy of the GNU Lesser General Public
    5.18 + * License along with this library; if not, write to the Free Software
    5.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
    5.20 + */
    5.21 +
    5.22 +#ifndef XEN_VBD_TYPE_H
    5.23 +#define XEN_VBD_TYPE_H
    5.24 +
    5.25 +
    5.26 +#include "xen_common.h"
    5.27 +
    5.28 +
    5.29 +enum xen_vbd_type
    5.30 +{
    5.31 +    /**
    5.32 +     * VBD will appear to guest as CD
    5.33 +     */
    5.34 +    XEN_VBD_TYPE_CD,
    5.35 +
    5.36 +    /**
    5.37 +     * VBD will appear to guest as disk
    5.38 +     */
    5.39 +    XEN_VBD_TYPE_DISK
    5.40 +};
    5.41 +
    5.42 +
    5.43 +typedef struct xen_vbd_type_set
    5.44 +{
    5.45 +    size_t size;
    5.46 +    enum xen_vbd_type contents[];
    5.47 +} xen_vbd_type_set;
    5.48 +
    5.49 +/**
    5.50 + * Allocate a xen_vbd_type_set of the given size.
    5.51 + */
    5.52 +extern xen_vbd_type_set *
    5.53 +xen_vbd_type_set_alloc(size_t size);
    5.54 +
    5.55 +/**
    5.56 + * Free the given xen_vbd_type_set.  The given set must have been
    5.57 + * allocated by this library.
    5.58 + */
    5.59 +extern void
    5.60 +xen_vbd_type_set_free(xen_vbd_type_set *set);
    5.61 +
    5.62 +
    5.63 +/**
    5.64 + * Return the name corresponding to the given code.  This string must
    5.65 + * not be modified or freed.
    5.66 + */
    5.67 +extern const char *
    5.68 +xen_vbd_type_to_string(enum xen_vbd_type val);
    5.69 +
    5.70 +
    5.71 +/**
    5.72 + * Return the correct code for the given string, or set the session
    5.73 + * object to failure and return an undefined value if the given string does
    5.74 + * not match a known code.
    5.75 + */
    5.76 +extern enum xen_vbd_type
    5.77 +xen_vbd_type_from_string(xen_session *session, const char *str);
    5.78 +
    5.79 +
    5.80 +#endif
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/tools/libxen/include/xen_vbd_type_internal.h	Tue Feb 20 21:28:19 2007 +0000
     6.3 @@ -0,0 +1,37 @@
     6.4 +/*
     6.5 + * Copyright (c) 2006-2007, XenSource Inc.
     6.6 + *
     6.7 + * This library is free software; you can redistribute it and/or
     6.8 + * modify it under the terms of the GNU Lesser General Public
     6.9 + * License as published by the Free Software Foundation; either
    6.10 + * version 2.1 of the License, or (at your option) any later version.
    6.11 + *
    6.12 + * This library is distributed in the hope that it will be useful,
    6.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    6.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    6.15 + * Lesser General Public License for more details.
    6.16 + *
    6.17 + * You should have received a copy of the GNU Lesser General Public
    6.18 + * License along with this library; if not, write to the Free Software
    6.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
    6.20 + */
    6.21 +
    6.22 +
    6.23 +/*
    6.24 + * Declarations of the abstract types used during demarshalling of enum
    6.25 + * xen_vbd_type.  Internal to this library -- do not use from outside.
    6.26 + */
    6.27 +
    6.28 +
    6.29 +#ifndef XEN_VBD_TYPE_INTERNAL_H
    6.30 +#define XEN_VBD_TYPE_INTERNAL_H
    6.31 +
    6.32 +
    6.33 +#include "xen_internal.h"
    6.34 +
    6.35 +
    6.36 +extern const abstract_type xen_vbd_type_abstract_type_;
    6.37 +extern const abstract_type xen_vbd_type_set_abstract_type_;
    6.38 +
    6.39 +
    6.40 +#endif
     7.1 --- a/tools/libxen/src/xen_vbd.c	Tue Feb 20 19:38:24 2007 +0000
     7.2 +++ b/tools/libxen/src/xen_vbd.c	Tue Feb 20 21:28:19 2007 +0000
     7.3 @@ -1,5 +1,5 @@
     7.4  /*
     7.5 - * Copyright (c) 2006, XenSource Inc.
     7.6 + * Copyright (c) 2006-2007, XenSource Inc.
     7.7   *
     7.8   * This library is free software; you can redistribute it and/or
     7.9   * modify it under the terms of the GNU Lesser General Public
    7.10 @@ -23,7 +23,9 @@
    7.11  #include "xen_common.h"
    7.12  #include "xen_internal.h"
    7.13  #include "xen_vbd.h"
    7.14 +#include "xen_vbd_metrics.h"
    7.15  #include "xen_vbd_mode_internal.h"
    7.16 +#include "xen_vbd_type_internal.h"
    7.17  #include "xen_vdi.h"
    7.18  #include "xen_vm.h"
    7.19  
    7.20 @@ -60,12 +62,12 @@ static const struct_member xen_vbd_recor
    7.21          { .key = "mode",
    7.22            .type = &xen_vbd_mode_abstract_type_,
    7.23            .offset = offsetof(xen_vbd_record, mode) },
    7.24 -        { .key = "io_read_kbs",
    7.25 -          .type = &abstract_type_float,
    7.26 -          .offset = offsetof(xen_vbd_record, io_read_kbs) },
    7.27 -        { .key = "io_write_kbs",
    7.28 -          .type = &abstract_type_float,
    7.29 -          .offset = offsetof(xen_vbd_record, io_write_kbs) }
    7.30 +        { .key = "type",
    7.31 +          .type = &xen_vbd_type_abstract_type_,
    7.32 +          .offset = offsetof(xen_vbd_record, type) },
    7.33 +        { .key = "metrics",
    7.34 +          .type = &abstract_type_ref,
    7.35 +          .offset = offsetof(xen_vbd_record, metrics) }
    7.36      };
    7.37  
    7.38  const abstract_type xen_vbd_record_abstract_type_ =
    7.39 @@ -90,6 +92,7 @@ xen_vbd_record_free(xen_vbd_record *reco
    7.40      xen_vm_record_opt_free(record->vm);
    7.41      xen_vdi_record_opt_free(record->vdi);
    7.42      free(record->device);
    7.43 +    xen_vbd_metrics_record_opt_free(record->metrics);
    7.44      free(record);
    7.45  }
    7.46  
    7.47 @@ -242,15 +245,13 @@ xen_vbd_get_mode(xen_session *session, e
    7.48          };
    7.49  
    7.50      abstract_type result_type = xen_vbd_mode_abstract_type_;
    7.51 -    char *result_str = NULL;
    7.52      XEN_CALL_("VBD.get_mode");
    7.53 -    *result = xen_vbd_mode_from_string(session, result_str);
    7.54      return session->ok;
    7.55  }
    7.56  
    7.57  
    7.58  bool
    7.59 -xen_vbd_get_io_read_kbs(xen_session *session, double *result, xen_vbd vbd)
    7.60 +xen_vbd_get_type(xen_session *session, enum xen_vbd_type *result, xen_vbd vbd)
    7.61  {
    7.62      abstract_value param_values[] =
    7.63          {
    7.64 @@ -258,15 +259,14 @@ xen_vbd_get_io_read_kbs(xen_session *ses
    7.65                .u.string_val = vbd }
    7.66          };
    7.67  
    7.68 -    abstract_type result_type = abstract_type_float;
    7.69 -
    7.70 -    XEN_CALL_("VBD.get_io_read_kbs");
    7.71 +    abstract_type result_type = xen_vbd_type_abstract_type_;
    7.72 +    XEN_CALL_("VBD.get_type");
    7.73      return session->ok;
    7.74  }
    7.75  
    7.76  
    7.77  bool
    7.78 -xen_vbd_get_io_write_kbs(xen_session *session, double *result, xen_vbd vbd)
    7.79 +xen_vbd_get_metrics(xen_session *session, xen_vbd_metrics *result, xen_vbd vbd)
    7.80  {
    7.81      abstract_value param_values[] =
    7.82          {
    7.83 @@ -274,9 +274,10 @@ xen_vbd_get_io_write_kbs(xen_session *se
    7.84                .u.string_val = vbd }
    7.85          };
    7.86  
    7.87 -    abstract_type result_type = abstract_type_float;
    7.88 +    abstract_type result_type = abstract_type_string;
    7.89  
    7.90 -    XEN_CALL_("VBD.get_io_write_kbs");
    7.91 +    *result = NULL;
    7.92 +    XEN_CALL_("VBD.get_metrics");
    7.93      return session->ok;
    7.94  }
    7.95  
    7.96 @@ -330,6 +331,22 @@ xen_vbd_set_mode(xen_session *session, x
    7.97  
    7.98  
    7.99  bool
   7.100 +xen_vbd_set_type(xen_session *session, xen_vbd vbd, enum xen_vbd_type type)
   7.101 +{
   7.102 +    abstract_value param_values[] =
   7.103 +        {
   7.104 +            { .type = &abstract_type_string,
   7.105 +              .u.string_val = vbd },
   7.106 +            { .type = &xen_vbd_type_abstract_type_,
   7.107 +              .u.string_val = xen_vbd_type_to_string(type) }
   7.108 +        };
   7.109 +
   7.110 +    xen_call_(session, "VBD.set_type", param_values, 2, NULL, NULL);
   7.111 +    return session->ok;
   7.112 +}
   7.113 +
   7.114 +
   7.115 +bool
   7.116  xen_vbd_media_change(xen_session *session, xen_vbd vbd, xen_vdi vdi)
   7.117  {
   7.118      abstract_value param_values[] =
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/tools/libxen/src/xen_vbd_metrics.c	Tue Feb 20 21:28:19 2007 +0000
     8.3 @@ -0,0 +1,150 @@
     8.4 +/*
     8.5 + * Copyright (c) 2006-2007, XenSource Inc.
     8.6 + *
     8.7 + * This library is free software; you can redistribute it and/or
     8.8 + * modify it under the terms of the GNU Lesser General Public
     8.9 + * License as published by the Free Software Foundation; either
    8.10 + * version 2.1 of the License, or (at your option) any later version.
    8.11 + *
    8.12 + * This library is distributed in the hope that it will be useful,
    8.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    8.15 + * Lesser General Public License for more details.
    8.16 + *
    8.17 + * You should have received a copy of the GNU Lesser General Public
    8.18 + * License along with this library; if not, write to the Free Software
    8.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
    8.20 + */
    8.21 +
    8.22 +
    8.23 +#include <stddef.h>
    8.24 +#include <stdlib.h>
    8.25 +
    8.26 +#include "xen_common.h"
    8.27 +#include "xen_internal.h"
    8.28 +#include "xen_vbd_metrics.h"
    8.29 +
    8.30 +
    8.31 +XEN_FREE(xen_vbd_metrics)
    8.32 +XEN_SET_ALLOC_FREE(xen_vbd_metrics)
    8.33 +XEN_ALLOC(xen_vbd_metrics_record)
    8.34 +XEN_SET_ALLOC_FREE(xen_vbd_metrics_record)
    8.35 +XEN_ALLOC(xen_vbd_metrics_record_opt)
    8.36 +XEN_RECORD_OPT_FREE(xen_vbd_metrics)
    8.37 +XEN_SET_ALLOC_FREE(xen_vbd_metrics_record_opt)
    8.38 +
    8.39 +
    8.40 +static const struct_member xen_vbd_metrics_record_struct_members[] =
    8.41 +    {
    8.42 +        { .key = "uuid",
    8.43 +          .type = &abstract_type_string,
    8.44 +          .offset = offsetof(xen_vbd_metrics_record, uuid) },
    8.45 +        { .key = "io_read_kbs",
    8.46 +          .type = &abstract_type_float,
    8.47 +          .offset = offsetof(xen_vbd_metrics_record, io_read_kbs) },
    8.48 +        { .key = "io_write_kbs",
    8.49 +          .type = &abstract_type_float,
    8.50 +          .offset = offsetof(xen_vbd_metrics_record, io_write_kbs) }
    8.51 +    };
    8.52 +
    8.53 +const abstract_type xen_vbd_metrics_record_abstract_type_ =
    8.54 +    {
    8.55 +       .typename = STRUCT,
    8.56 +       .struct_size = sizeof(xen_vbd_metrics_record),
    8.57 +       .member_count =
    8.58 +           sizeof(xen_vbd_metrics_record_struct_members) / sizeof(struct_member),
    8.59 +       .members = xen_vbd_metrics_record_struct_members
    8.60 +    };
    8.61 +
    8.62 +
    8.63 +void
    8.64 +xen_vbd_metrics_record_free(xen_vbd_metrics_record *record)
    8.65 +{
    8.66 +    if (record == NULL)
    8.67 +    {
    8.68 +        return;
    8.69 +    }
    8.70 +    free(record->handle);
    8.71 +    free(record->uuid);
    8.72 +    free(record);
    8.73 +}
    8.74 +
    8.75 +
    8.76 +bool
    8.77 +xen_vbd_metrics_get_record(xen_session *session, xen_vbd_metrics_record **result, xen_vbd_metrics vbd_metrics)
    8.78 +{
    8.79 +    abstract_value param_values[] =
    8.80 +        {
    8.81 +            { .type = &abstract_type_string,
    8.82 +              .u.string_val = vbd_metrics }
    8.83 +        };
    8.84 +
    8.85 +    abstract_type result_type = xen_vbd_metrics_record_abstract_type_;
    8.86 +
    8.87 +    *result = NULL;
    8.88 +    XEN_CALL_("VBD_metrics.get_record");
    8.89 +
    8.90 +    if (session->ok)
    8.91 +    {
    8.92 +       (*result)->handle = xen_strdup_((*result)->uuid);
    8.93 +    }
    8.94 +
    8.95 +    return session->ok;
    8.96 +}
    8.97 +
    8.98 +
    8.99 +bool
   8.100 +xen_vbd_metrics_get_by_uuid(xen_session *session, xen_vbd_metrics *result, char *uuid)
   8.101 +{
   8.102 +    abstract_value param_values[] =
   8.103 +        {
   8.104 +            { .type = &abstract_type_string,
   8.105 +              .u.string_val = uuid }
   8.106 +        };
   8.107 +
   8.108 +    abstract_type result_type = abstract_type_string;
   8.109 +
   8.110 +    *result = NULL;
   8.111 +    XEN_CALL_("VBD_metrics.get_by_uuid");
   8.112 +    return session->ok;
   8.113 +}
   8.114 +
   8.115 +
   8.116 +bool
   8.117 +xen_vbd_metrics_get_io_read_kbs(xen_session *session, double *result, xen_vbd_metrics vbd_metrics)
   8.118 +{
   8.119 +    abstract_value param_values[] =
   8.120 +        {
   8.121 +            { .type = &abstract_type_string,
   8.122 +              .u.string_val = vbd_metrics }
   8.123 +        };
   8.124 +
   8.125 +    abstract_type result_type = abstract_type_float;
   8.126 +
   8.127 +    XEN_CALL_("VBD_metrics.get_io_read_kbs");
   8.128 +    return session->ok;
   8.129 +}
   8.130 +
   8.131 +
   8.132 +bool
   8.133 +xen_vbd_metrics_get_io_write_kbs(xen_session *session, double *result, xen_vbd_metrics vbd_metrics)
   8.134 +{
   8.135 +    abstract_value param_values[] =
   8.136 +        {
   8.137 +            { .type = &abstract_type_string,
   8.138 +              .u.string_val = vbd_metrics }
   8.139 +        };
   8.140 +
   8.141 +    abstract_type result_type = abstract_type_float;
   8.142 +
   8.143 +    XEN_CALL_("VBD_metrics.get_io_write_kbs");
   8.144 +    return session->ok;
   8.145 +}
   8.146 +
   8.147 +
   8.148 +bool
   8.149 +xen_vbd_metrics_get_uuid(xen_session *session, char **result, xen_vbd_metrics vbd_metrics)
   8.150 +{
   8.151 +    *result = session->ok ? xen_strdup_((char *)vbd_metrics) : NULL;
   8.152 +    return session->ok;
   8.153 +}
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/tools/libxen/src/xen_vbd_type.c	Tue Feb 20 21:28:19 2007 +0000
     9.3 @@ -0,0 +1,81 @@
     9.4 +/*
     9.5 + * Copyright (c) 2006-2007, XenSource Inc.
     9.6 + *
     9.7 + * This library is free software; you can redistribute it and/or
     9.8 + * modify it under the terms of the GNU Lesser General Public
     9.9 + * License as published by the Free Software Foundation; either
    9.10 + * version 2.1 of the License, or (at your option) any later version.
    9.11 + *
    9.12 + * This library is distributed in the hope that it will be useful,
    9.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    9.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    9.15 + * Lesser General Public License for more details.
    9.16 + *
    9.17 + * You should have received a copy of the GNU Lesser General Public
    9.18 + * License along with this library; if not, write to the Free Software
    9.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
    9.20 + */
    9.21 +
    9.22 +#include <string.h>
    9.23 +
    9.24 +#include "xen_internal.h"
    9.25 +#include "xen_vbd_type.h"
    9.26 +#include "xen_vbd_type_internal.h"
    9.27 +
    9.28 +
    9.29 +/*
    9.30 + * Maintain this in the same order as the enum declaration!
    9.31 + */
    9.32 +static const char *lookup_table[] =
    9.33 +{
    9.34 +    "CD",
    9.35 +    "Disk"
    9.36 +};
    9.37 +
    9.38 +
    9.39 +extern xen_vbd_type_set *
    9.40 +xen_vbd_type_set_alloc(size_t size)
    9.41 +{
    9.42 +    return calloc(1, sizeof(xen_vbd_type_set) +
    9.43 +                  size * sizeof(enum xen_vbd_type));
    9.44 +}
    9.45 +
    9.46 +
    9.47 +extern void
    9.48 +xen_vbd_type_set_free(xen_vbd_type_set *set)
    9.49 +{
    9.50 +    free(set);
    9.51 +}
    9.52 +
    9.53 +
    9.54 +const char *
    9.55 +xen_vbd_type_to_string(enum xen_vbd_type val)
    9.56 +{
    9.57 +    return lookup_table[val];
    9.58 +}
    9.59 +
    9.60 +
    9.61 +extern enum xen_vbd_type
    9.62 +xen_vbd_type_from_string(xen_session *session, const char *str)
    9.63 +{
    9.64 +    return ENUM_LOOKUP(session, str, lookup_table);
    9.65 +}
    9.66 +
    9.67 +
    9.68 +const abstract_type xen_vbd_type_abstract_type_ =
    9.69 +    {
    9.70 +        .typename = ENUM,
    9.71 +        .enum_marshaller =
    9.72 +             (const char *(*)(int))&xen_vbd_type_to_string,
    9.73 +        .enum_demarshaller =
    9.74 +             (int (*)(xen_session *, const char *))&xen_vbd_type_from_string
    9.75 +    };
    9.76 +
    9.77 +
    9.78 +const abstract_type xen_vbd_type_set_abstract_type_ =
    9.79 +    {
    9.80 +        .typename = SET,
    9.81 +        .child = &xen_vbd_type_abstract_type_
    9.82 +    };
    9.83 +
    9.84 +
    10.1 --- a/tools/python/xen/xend/XendAPI.py	Tue Feb 20 19:38:24 2007 +0000
    10.2 +++ b/tools/python/xen/xend/XendAPI.py	Tue Feb 20 21:28:19 2007 +0000
    10.3 @@ -209,6 +209,16 @@ def valid_vbd(func):
    10.4             _check_ref(lambda r: XendDomain.instance().is_valid_dev('vbd', r),
    10.5                        'VBD', func, *args, **kwargs)
    10.6  
    10.7 +def valid_vbd_metrics(func):
    10.8 +    """Decorator to verify if ref is valid before calling method.
    10.9 +
   10.10 +    @param func: function with params: (self, session, ref, ...)
   10.11 +    @rtype: callable object
   10.12 +    """    
   10.13 +    return lambda *args, **kwargs: \
   10.14 +           _check_ref(lambda r: XendDomain.instance().is_valid_dev('vbd', r),
   10.15 +                      'VBD_metrics', func, *args, **kwargs)
   10.16 +
   10.17  def valid_vif(func):
   10.18      """Decorator to verify if vif_ref is valid before calling method.
   10.19  
   10.20 @@ -378,6 +388,7 @@ class XendAPI(object):
   10.21              'network'      : valid_network,
   10.22              'VM'           : valid_vm,
   10.23              'VBD'          : valid_vbd,
   10.24 +            'VBD_metrics'  : valid_vbd_metrics,
   10.25              'VIF'          : valid_vif,
   10.26              'VDI'          : valid_vdi,
   10.27              'VTPM'         : valid_vtpm,
   10.28 @@ -1450,8 +1461,7 @@ class XendAPI(object):
   10.29      # Xen API: Class VBD
   10.30      # ----------------------------------------------------------------
   10.31  
   10.32 -    VBD_attr_ro = ['io_read_kbs',
   10.33 -                   'io_write_kbs']
   10.34 +    VBD_attr_ro = ['metrics']
   10.35      VBD_attr_rw = ['VM',
   10.36                     'VDI',
   10.37                     'device',
   10.38 @@ -1481,7 +1491,9 @@ class XendAPI(object):
   10.39          for k in cfg.keys():
   10.40              if k in valid_vbd_keys:
   10.41                  return_cfg[k] = cfg[k]
   10.42 -                
   10.43 +
   10.44 +        return_cfg['metrics'] = vbd_ref
   10.45 +
   10.46          return xen_api_success(return_cfg)
   10.47  
   10.48      def VBD_media_change(self, session, vbd_ref, vdi_ref):
   10.49 @@ -1521,12 +1533,16 @@ class XendAPI(object):
   10.50          XendTask.log_progress(0, 100, vm.destroy_vbd, vbd_ref)
   10.51          return xen_api_success_void()
   10.52  
   10.53 -    # attributes (rw)
   10.54      def _VBD_get(self, vbd_ref, prop):
   10.55          return xen_api_success(
   10.56              XendDomain.instance().get_dev_property_by_uuid(
   10.57              'vbd', vbd_ref, prop))
   10.58  
   10.59 +    # attributes (ro)
   10.60 +    def VBD_get_metrics(self, _, vbd_ref):
   10.61 +        return xen_api_success(vbd_ref)
   10.62 +
   10.63 +    # attributes (rw)
   10.64      def VBD_get_VM(self, session, vbd_ref):
   10.65          return self._VBD_get(vbd_ref, 'VM')
   10.66      
   10.67 @@ -1545,12 +1561,6 @@ class XendAPI(object):
   10.68      def VBD_get_type(self, session, vbd_ref):
   10.69          return self._VBD_get(vbd_ref, 'type')
   10.70  
   10.71 -    def VBD_get_io_read_kbs(self, session, vbd_ref):
   10.72 -        return self._VBD_get(vbd_ref, 'io_read_kbs')
   10.73 -    
   10.74 -    def VBD_get_io_write_kbs(self, session, vbd_ref):
   10.75 -        return self._VBD_get(vbd_ref, 'io_write_kbs')
   10.76 -
   10.77      def VBD_set_bootable(self, session, vbd_ref, bootable):
   10.78          bootable = bool(bootable)
   10.79          xd = XendDomain.instance()
   10.80 @@ -1565,6 +1575,30 @@ class XendAPI(object):
   10.81          vbds = reduce(lambda x, y: x + y, vbds)
   10.82          return xen_api_success(vbds)
   10.83  
   10.84 +
   10.85 +    # Xen API: Class VBD_metrics
   10.86 +    # ----------------------------------------------------------------
   10.87 +
   10.88 +    VBD_metrics_attr_ro = ['io_read_kbs',
   10.89 +                           'io_write_kbs']
   10.90 +    VBD_metrics_attr_rw = []
   10.91 +    VBD_methods = []
   10.92 +
   10.93 +    def VBD_metrics_get_record(self, _, ref):
   10.94 +        vm = XendDomain.instance().get_vm_with_dev_uuid('vbd', ref)
   10.95 +        if not vm:
   10.96 +            return xen_api_error(['HANDLE_INVALID', 'VBD_metrics', ref])
   10.97 +        return xen_api_success(
   10.98 +            { 'io_read_kbs'  : vm.get_dev_property('vbd', ref, 'io_read_kbs'),
   10.99 +              'io_write_kbs' : vm.get_dev_property('vbd', ref, 'io_write_kbs') })
  10.100 +
  10.101 +    def VBD_metrics_get_io_write_kbs(self, _, ref):
  10.102 +        return self._VBD_get(ref, 'io_read_kbs')
  10.103 +    
  10.104 +    def VBD_metrics_get_io_write_kbs(self, session, vbd_ref):
  10.105 +        return self._VBD_get(ref, 'io_write_kbs')
  10.106 +
  10.107 +
  10.108      # Xen API: Class VIF
  10.109      # ----------------------------------------------------------------
  10.110