ia64/xen-unstable
changeset 14046:0aa6755159d5
Split the VIF I/O statistics fields out into a VIF_metrics class. Implement
this in Xend, and fix the VBD_metrics implementation. Implement C bindings
also.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
this in Xend, and fix the VBD_metrics implementation. Implement C bindings
also.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
author | Ewan Mellor <ewan@xensource.com> |
---|---|
date | Tue Feb 20 21:55:11 2007 +0000 (2007-02-20) |
parents | 7819d9332fba |
children | bab07bed5c0a |
files | docs/xen-api/xenapi-datamodel.tex tools/libxen/include/xen_vif.h tools/libxen/include/xen_vif_metrics.h tools/libxen/include/xen_vif_metrics_decl.h tools/libxen/src/xen_vif.c tools/libxen/src/xen_vif_metrics.c tools/python/xen/xend/XendAPI.py |
line diff
1.1 --- a/docs/xen-api/xenapi-datamodel.tex Tue Feb 20 21:28:19 2007 +0000 1.2 +++ b/docs/xen-api/xenapi-datamodel.tex Tue Feb 20 21:55:11 2007 +0000 1.3 @@ -31,6 +31,7 @@ Name & Description \\ 1.4 {\tt host\_cpu} & A physical CPU \\ 1.5 {\tt network} & A virtual network \\ 1.6 {\tt VIF} & A virtual network interface \\ 1.7 +{\tt VIF\_metrics} & The metrics associated with a virtual network device \\ 1.8 {\tt PIF} & A physical network interface (note separate VLANs are represented as several PIFs) \\ 1.9 {\tt PIF\_metrics} & The metrics associated with a physical network interface \\ 1.10 {\tt SR} & A storage repository \\ 1.11 @@ -6709,8 +6710,7 @@ Quals & Field & Type & Description \\ 1.12 $\mathit{RO}_\mathit{ins}$ & {\tt VM} & VM ref & virtual machine to which this vif is connected \\ 1.13 $\mathit{RW}$ & {\tt MAC} & string & ethernet MAC address of virtual interface, as exposed to guest \\ 1.14 $\mathit{RW}$ & {\tt MTU} & int & MTU in octets \\ 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} & VIF\_metrics ref & metrics associated with this VIF. \\ 1.18 \hline 1.19 \end{longtable} 1.20 \subsection{Additional RPCs associated with class: VIF} 1.21 @@ -7008,13 +7008,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 VIF. 1.29 - 1.30 - \noindent {\bf Signature:} 1.31 -\begin{verbatim} float get_io_read_kbs (session_id s, VIF 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 VIF. 1.36 + 1.37 + \noindent {\bf Signature:} 1.38 +\begin{verbatim} (VIF_metrics ref) get_metrics (session_id s, VIF ref self)\end{verbatim} 1.39 1.40 1.41 \noindent{\bf Arguments:} 1.42 @@ -7032,39 +7032,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 VIF. 1.58 - 1.59 - \noindent {\bf Signature:} 1.60 -\begin{verbatim} float get_io_write_kbs (session_id s, VIF 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 VIF 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 +VIF\_metrics ref 1.80 } 1.81 1.82 1.83 @@ -7203,6 +7171,185 @@ all fields from the object 1.84 1.85 \vspace{1cm} 1.86 \newpage 1.87 +\section{Class: VIF\_metrics} 1.88 +\subsection{Fields for class: VIF\_metrics} 1.89 +\begin{longtable}{|lllp{0.38\textwidth}|} 1.90 +\hline 1.91 +\multicolumn{1}{|l}{Name} & \multicolumn{3}{l|}{\bf VIF\_metrics} \\ 1.92 +\multicolumn{1}{|l}{Description} & \multicolumn{3}{l|}{\parbox{11cm}{\em 1.93 +The metrics associated with a virtual network 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: VIF\_metrics} 1.103 +\subsubsection{RPC name:~get\_uuid} 1.104 + 1.105 +{\bf Overview:} 1.106 +Get the uuid field of the given VIF\_metrics. 1.107 + 1.108 + \noindent {\bf Signature:} 1.109 +\begin{verbatim} string get_uuid (session_id s, VIF_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 VIF\_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 VIF\_metrics. 1.139 + 1.140 + \noindent {\bf Signature:} 1.141 +\begin{verbatim} float get_io_read_kbs (session_id s, VIF_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 VIF\_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 VIF\_metrics. 1.171 + 1.172 + \noindent {\bf Signature:} 1.173 +\begin{verbatim} float get_io_write_kbs (session_id s, VIF_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 VIF\_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 VIF\_metrics instance with the specified UUID. 1.203 + 1.204 + \noindent {\bf Signature:} 1.205 +\begin{verbatim} (VIF_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 +VIF\_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 VIF\_metrics. 1.235 + 1.236 + \noindent {\bf Signature:} 1.237 +\begin{verbatim} (VIF_metrics record) get_record (session_id s, VIF_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 VIF\_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 +VIF\_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: PIF} 1.267 \subsection{Fields for class: PIF} 1.268 \begin{longtable}{|lllp{0.38\textwidth}|}
2.1 --- a/tools/libxen/include/xen_vif.h Tue Feb 20 21:28:19 2007 +0000 2.2 +++ b/tools/libxen/include/xen_vif.h Tue Feb 20 21:55:11 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 @@ -22,6 +22,7 @@ 2.11 #include "xen_common.h" 2.12 #include "xen_network_decl.h" 2.13 #include "xen_vif_decl.h" 2.14 +#include "xen_vif_metrics_decl.h" 2.15 #include "xen_vm_decl.h" 2.16 2.17 2.18 @@ -69,8 +70,7 @@ typedef struct xen_vif_record 2.19 struct xen_vm_record_opt *vm; 2.20 char *mac; 2.21 int64_t mtu; 2.22 - double io_read_kbs; 2.23 - double io_write_kbs; 2.24 + struct xen_vif_metrics_record_opt *metrics; 2.25 } xen_vif_record; 2.26 2.27 /** 2.28 @@ -223,17 +223,10 @@ xen_vif_get_mtu(xen_session *session, in 2.29 2.30 2.31 /** 2.32 - * Get the io/read_kbs field of the given VIF. 2.33 + * Get the metrics field of the given VIF. 2.34 */ 2.35 extern bool 2.36 -xen_vif_get_io_read_kbs(xen_session *session, double *result, xen_vif vif); 2.37 - 2.38 - 2.39 -/** 2.40 - * Get the io/write_kbs field of the given VIF. 2.41 - */ 2.42 -extern bool 2.43 -xen_vif_get_io_write_kbs(xen_session *session, double *result, xen_vif vif); 2.44 +xen_vif_get_metrics(xen_session *session, xen_vif_metrics *result, xen_vif vif); 2.45 2.46 2.47 /**
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/tools/libxen/include/xen_vif_metrics.h Tue Feb 20 21:55:11 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_VIF_METRICS_H 3.23 +#define XEN_VIF_METRICS_H 3.24 + 3.25 +#include "xen_common.h" 3.26 +#include "xen_vif_metrics_decl.h" 3.27 + 3.28 + 3.29 +/* 3.30 + * The VIF_metrics class. 3.31 + * 3.32 + * The metrics associated with a virtual network device. 3.33 + */ 3.34 + 3.35 + 3.36 +/** 3.37 + * Free the given xen_vif_metrics. The given handle must have been 3.38 + * allocated by this library. 3.39 + */ 3.40 +extern void 3.41 +xen_vif_metrics_free(xen_vif_metrics vif_metrics); 3.42 + 3.43 + 3.44 +typedef struct xen_vif_metrics_set 3.45 +{ 3.46 + size_t size; 3.47 + xen_vif_metrics *contents[]; 3.48 +} xen_vif_metrics_set; 3.49 + 3.50 +/** 3.51 + * Allocate a xen_vif_metrics_set of the given size. 3.52 + */ 3.53 +extern xen_vif_metrics_set * 3.54 +xen_vif_metrics_set_alloc(size_t size); 3.55 + 3.56 +/** 3.57 + * Free the given xen_vif_metrics_set. The given set must have been 3.58 + * allocated by this library. 3.59 + */ 3.60 +extern void 3.61 +xen_vif_metrics_set_free(xen_vif_metrics_set *set); 3.62 + 3.63 + 3.64 +typedef struct xen_vif_metrics_record 3.65 +{ 3.66 + xen_vif_metrics handle; 3.67 + char *uuid; 3.68 + double io_read_kbs; 3.69 + double io_write_kbs; 3.70 +} xen_vif_metrics_record; 3.71 + 3.72 +/** 3.73 + * Allocate a xen_vif_metrics_record. 3.74 + */ 3.75 +extern xen_vif_metrics_record * 3.76 +xen_vif_metrics_record_alloc(void); 3.77 + 3.78 +/** 3.79 + * Free the given xen_vif_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_vif_metrics_record_free(xen_vif_metrics_record *record); 3.84 + 3.85 + 3.86 +typedef struct xen_vif_metrics_record_opt 3.87 +{ 3.88 + bool is_record; 3.89 + union 3.90 + { 3.91 + xen_vif_metrics handle; 3.92 + xen_vif_metrics_record *record; 3.93 + } u; 3.94 +} xen_vif_metrics_record_opt; 3.95 + 3.96 +/** 3.97 + * Allocate a xen_vif_metrics_record_opt. 3.98 + */ 3.99 +extern xen_vif_metrics_record_opt * 3.100 +xen_vif_metrics_record_opt_alloc(void); 3.101 + 3.102 +/** 3.103 + * Free the given xen_vif_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_vif_metrics_record_opt_free(xen_vif_metrics_record_opt *record_opt); 3.108 + 3.109 + 3.110 +typedef struct xen_vif_metrics_record_set 3.111 +{ 3.112 + size_t size; 3.113 + xen_vif_metrics_record *contents[]; 3.114 +} xen_vif_metrics_record_set; 3.115 + 3.116 +/** 3.117 + * Allocate a xen_vif_metrics_record_set of the given size. 3.118 + */ 3.119 +extern xen_vif_metrics_record_set * 3.120 +xen_vif_metrics_record_set_alloc(size_t size); 3.121 + 3.122 +/** 3.123 + * Free the given xen_vif_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_vif_metrics_record_set_free(xen_vif_metrics_record_set *set); 3.128 + 3.129 + 3.130 + 3.131 +typedef struct xen_vif_metrics_record_opt_set 3.132 +{ 3.133 + size_t size; 3.134 + xen_vif_metrics_record_opt *contents[]; 3.135 +} xen_vif_metrics_record_opt_set; 3.136 + 3.137 +/** 3.138 + * Allocate a xen_vif_metrics_record_opt_set of the given size. 3.139 + */ 3.140 +extern xen_vif_metrics_record_opt_set * 3.141 +xen_vif_metrics_record_opt_set_alloc(size_t size); 3.142 + 3.143 +/** 3.144 + * Free the given xen_vif_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_vif_metrics_record_opt_set_free(xen_vif_metrics_record_opt_set *set); 3.149 + 3.150 + 3.151 +/** 3.152 + * Get a record containing the current state of the given VIF_metrics. 3.153 + */ 3.154 +extern bool 3.155 +xen_vif_metrics_get_record(xen_session *session, xen_vif_metrics_record **result, xen_vif_metrics vif_metrics); 3.156 + 3.157 + 3.158 +/** 3.159 + * Get a reference to the VIF_metrics instance with the specified UUID. 3.160 + */ 3.161 +extern bool 3.162 +xen_vif_metrics_get_by_uuid(xen_session *session, xen_vif_metrics *result, char *uuid); 3.163 + 3.164 + 3.165 +/** 3.166 + * Get the uuid field of the given VIF_metrics. 3.167 + */ 3.168 +extern bool 3.169 +xen_vif_metrics_get_uuid(xen_session *session, char **result, xen_vif_metrics vif_metrics); 3.170 + 3.171 + 3.172 +/** 3.173 + * Get the io/read_kbs field of the given VIF_metrics. 3.174 + */ 3.175 +extern bool 3.176 +xen_vif_metrics_get_io_read_kbs(xen_session *session, double *result, xen_vif_metrics vif_metrics); 3.177 + 3.178 + 3.179 +/** 3.180 + * Get the io/write_kbs field of the given VIF_metrics. 3.181 + */ 3.182 +extern bool 3.183 +xen_vif_metrics_get_io_write_kbs(xen_session *session, double *result, xen_vif_metrics vif_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_vif_metrics_decl.h Tue Feb 20 21:55:11 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_VIF_METRICS_DECL_H 4.23 +#define XEN_VIF_METRICS_DECL_H 4.24 + 4.25 +typedef void *xen_vif_metrics; 4.26 + 4.27 +struct xen_vif_metrics_set; 4.28 +struct xen_vif_metrics_record; 4.29 +struct xen_vif_metrics_record_set; 4.30 +struct xen_vif_metrics_record_opt; 4.31 +struct xen_vif_metrics_record_opt_set; 4.32 + 4.33 +#endif
5.1 --- a/tools/libxen/src/xen_vif.c Tue Feb 20 21:28:19 2007 +0000 5.2 +++ b/tools/libxen/src/xen_vif.c Tue Feb 20 21:55:11 2007 +0000 5.3 @@ -1,5 +1,5 @@ 5.4 /* 5.5 - * Copyright (c) 2006, XenSource Inc. 5.6 + * Copyright (c) 2006-2007, XenSource Inc. 5.7 * 5.8 * This library is free software; you can redistribute it and/or 5.9 * modify it under the terms of the GNU Lesser General Public 5.10 @@ -24,6 +24,7 @@ 5.11 #include "xen_internal.h" 5.12 #include "xen_network.h" 5.13 #include "xen_vif.h" 5.14 +#include "xen_vif_metrics.h" 5.15 #include "xen_vm.h" 5.16 5.17 5.18 @@ -56,12 +57,9 @@ static const struct_member xen_vif_recor 5.19 { .key = "MTU", 5.20 .type = &abstract_type_int, 5.21 .offset = offsetof(xen_vif_record, mtu) }, 5.22 - { .key = "io_read_kbs", 5.23 - .type = &abstract_type_float, 5.24 - .offset = offsetof(xen_vif_record, io_read_kbs) }, 5.25 - { .key = "io_write_kbs", 5.26 - .type = &abstract_type_float, 5.27 - .offset = offsetof(xen_vif_record, io_write_kbs) } 5.28 + { .key = "metrics", 5.29 + .type = &abstract_type_ref, 5.30 + .offset = offsetof(xen_vif_record, metrics) } 5.31 }; 5.32 5.33 const abstract_type xen_vif_record_abstract_type_ = 5.34 @@ -87,6 +85,7 @@ xen_vif_record_free(xen_vif_record *reco 5.35 xen_network_record_opt_free(record->network); 5.36 xen_vm_record_opt_free(record->vm); 5.37 free(record->mac); 5.38 + xen_vif_metrics_record_opt_free(record->metrics); 5.39 free(record); 5.40 } 5.41 5.42 @@ -247,7 +246,7 @@ xen_vif_get_mtu(xen_session *session, in 5.43 5.44 5.45 bool 5.46 -xen_vif_get_io_read_kbs(xen_session *session, double *result, xen_vif vif) 5.47 +xen_vif_get_metrics(xen_session *session, xen_vif_metrics *result, xen_vif vif) 5.48 { 5.49 abstract_value param_values[] = 5.50 { 5.51 @@ -255,25 +254,10 @@ xen_vif_get_io_read_kbs(xen_session *ses 5.52 .u.string_val = vif } 5.53 }; 5.54 5.55 - abstract_type result_type = abstract_type_float; 5.56 - 5.57 - XEN_CALL_("VIF.get_io_read_kbs"); 5.58 - return session->ok; 5.59 -} 5.60 - 5.61 + abstract_type result_type = abstract_type_string; 5.62 5.63 -bool 5.64 -xen_vif_get_io_write_kbs(xen_session *session, double *result, xen_vif vif) 5.65 -{ 5.66 - abstract_value param_values[] = 5.67 - { 5.68 - { .type = &abstract_type_string, 5.69 - .u.string_val = vif } 5.70 - }; 5.71 - 5.72 - abstract_type result_type = abstract_type_float; 5.73 - 5.74 - XEN_CALL_("VIF.get_io_write_kbs"); 5.75 + *result = NULL; 5.76 + XEN_CALL_("VIF.get_metrics"); 5.77 return session->ok; 5.78 } 5.79
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/tools/libxen/src/xen_vif_metrics.c Tue Feb 20 21:55:11 2007 +0000 6.3 @@ -0,0 +1,150 @@ 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 +#include <stddef.h> 6.24 +#include <stdlib.h> 6.25 + 6.26 +#include "xen_common.h" 6.27 +#include "xen_internal.h" 6.28 +#include "xen_vif_metrics.h" 6.29 + 6.30 + 6.31 +XEN_FREE(xen_vif_metrics) 6.32 +XEN_SET_ALLOC_FREE(xen_vif_metrics) 6.33 +XEN_ALLOC(xen_vif_metrics_record) 6.34 +XEN_SET_ALLOC_FREE(xen_vif_metrics_record) 6.35 +XEN_ALLOC(xen_vif_metrics_record_opt) 6.36 +XEN_RECORD_OPT_FREE(xen_vif_metrics) 6.37 +XEN_SET_ALLOC_FREE(xen_vif_metrics_record_opt) 6.38 + 6.39 + 6.40 +static const struct_member xen_vif_metrics_record_struct_members[] = 6.41 + { 6.42 + { .key = "uuid", 6.43 + .type = &abstract_type_string, 6.44 + .offset = offsetof(xen_vif_metrics_record, uuid) }, 6.45 + { .key = "io_read_kbs", 6.46 + .type = &abstract_type_float, 6.47 + .offset = offsetof(xen_vif_metrics_record, io_read_kbs) }, 6.48 + { .key = "io_write_kbs", 6.49 + .type = &abstract_type_float, 6.50 + .offset = offsetof(xen_vif_metrics_record, io_write_kbs) } 6.51 + }; 6.52 + 6.53 +const abstract_type xen_vif_metrics_record_abstract_type_ = 6.54 + { 6.55 + .typename = STRUCT, 6.56 + .struct_size = sizeof(xen_vif_metrics_record), 6.57 + .member_count = 6.58 + sizeof(xen_vif_metrics_record_struct_members) / sizeof(struct_member), 6.59 + .members = xen_vif_metrics_record_struct_members 6.60 + }; 6.61 + 6.62 + 6.63 +void 6.64 +xen_vif_metrics_record_free(xen_vif_metrics_record *record) 6.65 +{ 6.66 + if (record == NULL) 6.67 + { 6.68 + return; 6.69 + } 6.70 + free(record->handle); 6.71 + free(record->uuid); 6.72 + free(record); 6.73 +} 6.74 + 6.75 + 6.76 +bool 6.77 +xen_vif_metrics_get_record(xen_session *session, xen_vif_metrics_record **result, xen_vif_metrics vif_metrics) 6.78 +{ 6.79 + abstract_value param_values[] = 6.80 + { 6.81 + { .type = &abstract_type_string, 6.82 + .u.string_val = vif_metrics } 6.83 + }; 6.84 + 6.85 + abstract_type result_type = xen_vif_metrics_record_abstract_type_; 6.86 + 6.87 + *result = NULL; 6.88 + XEN_CALL_("VIF_metrics.get_record"); 6.89 + 6.90 + if (session->ok) 6.91 + { 6.92 + (*result)->handle = xen_strdup_((*result)->uuid); 6.93 + } 6.94 + 6.95 + return session->ok; 6.96 +} 6.97 + 6.98 + 6.99 +bool 6.100 +xen_vif_metrics_get_by_uuid(xen_session *session, xen_vif_metrics *result, char *uuid) 6.101 +{ 6.102 + abstract_value param_values[] = 6.103 + { 6.104 + { .type = &abstract_type_string, 6.105 + .u.string_val = uuid } 6.106 + }; 6.107 + 6.108 + abstract_type result_type = abstract_type_string; 6.109 + 6.110 + *result = NULL; 6.111 + XEN_CALL_("VIF_metrics.get_by_uuid"); 6.112 + return session->ok; 6.113 +} 6.114 + 6.115 + 6.116 +bool 6.117 +xen_vif_metrics_get_io_read_kbs(xen_session *session, double *result, xen_vif_metrics vif_metrics) 6.118 +{ 6.119 + abstract_value param_values[] = 6.120 + { 6.121 + { .type = &abstract_type_string, 6.122 + .u.string_val = vif_metrics } 6.123 + }; 6.124 + 6.125 + abstract_type result_type = abstract_type_float; 6.126 + 6.127 + XEN_CALL_("VIF_metrics.get_io_read_kbs"); 6.128 + return session->ok; 6.129 +} 6.130 + 6.131 + 6.132 +bool 6.133 +xen_vif_metrics_get_io_write_kbs(xen_session *session, double *result, xen_vif_metrics vif_metrics) 6.134 +{ 6.135 + abstract_value param_values[] = 6.136 + { 6.137 + { .type = &abstract_type_string, 6.138 + .u.string_val = vif_metrics } 6.139 + }; 6.140 + 6.141 + abstract_type result_type = abstract_type_float; 6.142 + 6.143 + XEN_CALL_("VIF_metrics.get_io_write_kbs"); 6.144 + return session->ok; 6.145 +} 6.146 + 6.147 + 6.148 +bool 6.149 +xen_vif_metrics_get_uuid(xen_session *session, char **result, xen_vif_metrics vif_metrics) 6.150 +{ 6.151 + *result = session->ok ? xen_strdup_((char *)vif_metrics) : NULL; 6.152 + return session->ok; 6.153 +}
7.1 --- a/tools/python/xen/xend/XendAPI.py Tue Feb 20 21:28:19 2007 +0000 7.2 +++ b/tools/python/xen/xend/XendAPI.py Tue Feb 20 21:55:11 2007 +0000 7.3 @@ -229,6 +229,16 @@ def valid_vif(func): 7.4 _check_ref(lambda r: XendDomain.instance().is_valid_dev('vif', r), 7.5 'VIF', func, *args, **kwargs) 7.6 7.7 +def valid_vif_metrics(func): 7.8 + """Decorator to verify if ref is valid before calling method. 7.9 + 7.10 + @param func: function with params: (self, session, ref, ...) 7.11 + @rtype: callable object 7.12 + """ 7.13 + return lambda *args, **kwargs: \ 7.14 + _check_ref(lambda r: XendDomain.instance().is_valid_dev('vif', r), 7.15 + 'VIF_metrics', func, *args, **kwargs) 7.16 + 7.17 def valid_vdi(func): 7.18 """Decorator to verify if vdi_ref is valid before calling method. 7.19 7.20 @@ -390,6 +400,7 @@ class XendAPI(object): 7.21 'VBD' : valid_vbd, 7.22 'VBD_metrics' : valid_vbd_metrics, 7.23 'VIF' : valid_vif, 7.24 + 'VIF_metrics' : valid_vif_metrics, 7.25 'VDI' : valid_vdi, 7.26 'VTPM' : valid_vtpm, 7.27 'console' : valid_console, 7.28 @@ -1592,18 +1603,17 @@ class XendAPI(object): 7.29 { 'io_read_kbs' : vm.get_dev_property('vbd', ref, 'io_read_kbs'), 7.30 'io_write_kbs' : vm.get_dev_property('vbd', ref, 'io_write_kbs') }) 7.31 7.32 - def VBD_metrics_get_io_write_kbs(self, _, ref): 7.33 + def VBD_metrics_get_io_read_kbs(self, _, ref): 7.34 return self._VBD_get(ref, 'io_read_kbs') 7.35 7.36 - def VBD_metrics_get_io_write_kbs(self, session, vbd_ref): 7.37 + def VBD_metrics_get_io_write_kbs(self, session, ref): 7.38 return self._VBD_get(ref, 'io_write_kbs') 7.39 7.40 7.41 # Xen API: Class VIF 7.42 # ---------------------------------------------------------------- 7.43 7.44 - VIF_attr_ro = ['io_read_kbs', 7.45 - 'io_write_kbs'] 7.46 + VIF_attr_ro = ['metrics'] 7.47 VIF_attr_rw = ['device', 7.48 'network', 7.49 'VM', 7.50 @@ -1633,6 +1643,8 @@ class XendAPI(object): 7.51 if k in valid_vif_keys: 7.52 return_cfg[k] = cfg[k] 7.53 7.54 + return_cfg['metrics'] = vif_ref 7.55 + 7.56 return xen_api_success(return_cfg) 7.57 7.58 # class methods 7.59 @@ -1659,36 +1671,28 @@ class XendAPI(object): 7.60 vm.destroy_vif(vif_ref) 7.61 return xen_api_success_void() 7.62 7.63 + def _VIF_get(self, ref, prop): 7.64 + return xen_api_success( 7.65 + XendDomain.instance().get_dev_property_by_uuid('vif', ref, prop)) 7.66 + 7.67 # getters/setters 7.68 + def VIF_get_metrics(self, _, vif_ref): 7.69 + return xen_api_success(vif_ref) 7.70 + 7.71 def VIF_get_VM(self, session, vif_ref): 7.72 xendom = XendDomain.instance() 7.73 vm = xendom.get_vm_with_dev_uuid('vif', vif_ref) 7.74 return xen_api_success(vm.get_uuid()) 7.75 7.76 def VIF_get_MTU(self, session, vif_ref): 7.77 - xendom = XendDomain.instance() 7.78 - return xen_api_success(xendom.get_dev_property_by_uuid('vif', vif_ref, 7.79 - 'MTU')) 7.80 + return self._VIF_get(vif_ref, 'MTU') 7.81 + 7.82 def VIF_get_MAC(self, session, vif_ref): 7.83 - xendom = XendDomain.instance() 7.84 - return xen_api_success(xendom.get_dev_property_by_uuid('vif', vif_ref, 7.85 - 'MAC')) 7.86 + return self._VIF_get(vif_ref, 'MAC') 7.87 7.88 def VIF_get_device(self, session, vif_ref): 7.89 - xendom = XendDomain.instance() 7.90 - return xen_api_success(xendom.get_dev_property_by_uuid('vif', vif_ref, 7.91 - 'device')) 7.92 + return self._VIF_get(vif_ref, 'device') 7.93 7.94 - def VIF_get_io_read_kbs(self, session, vif_ref): 7.95 - xendom = XendDomain.instance() 7.96 - return xen_api_success(xendom.get_dev_property_by_uuid('vif', vif_ref, 7.97 - 'io_read_kbs')) 7.98 - 7.99 - def VIF_get_io_write_kbs(self, session, vif_ref): 7.100 - xendom = XendDomain.instance() 7.101 - return xen_api_success(xendom.get_dev_property_by_uuid('vif', vif_ref, 7.102 - 'io_write_kbs')) 7.103 - 7.104 def VIF_get_all(self, session): 7.105 xendom = XendDomain.instance() 7.106 vifs = [d.get_vifs() for d in XendDomain.instance().list('all')] 7.107 @@ -1696,6 +1700,29 @@ class XendAPI(object): 7.108 return xen_api_success(vifs) 7.109 7.110 7.111 + # Xen API: Class VIF_metrics 7.112 + # ---------------------------------------------------------------- 7.113 + 7.114 + VIF_metrics_attr_ro = ['io_read_kbs', 7.115 + 'io_write_kbs'] 7.116 + VIF_metrics_attr_rw = [] 7.117 + VIF_methods = [] 7.118 + 7.119 + def VIF_metrics_get_record(self, _, ref): 7.120 + vm = XendDomain.instance().get_vm_with_dev_uuid('vif', ref) 7.121 + if not vm: 7.122 + return xen_api_error(['HANDLE_INVALID', 'VIF_metrics', ref]) 7.123 + return xen_api_success( 7.124 + { 'io_read_kbs' : vm.get_dev_property('vif', ref, 'io_read_kbs'), 7.125 + 'io_write_kbs' : vm.get_dev_property('vif', ref, 'io_write_kbs') }) 7.126 + 7.127 + def VIF_metrics_get_io_read_kbs(self, _, ref): 7.128 + return self._VIF_get(ref, 'io_read_kbs') 7.129 + 7.130 + def VIF_metrics_get_io_write_kbs(self, session, ref): 7.131 + return self._VIF_get(ref, 'io_write_kbs') 7.132 + 7.133 + 7.134 # Xen API: Class VDI 7.135 # ---------------------------------------------------------------- 7.136 VDI_attr_ro = ['VBDs',