WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] Split the VIF I/O statistics fields out i

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Split the VIF I/O statistics fields out into a VIF_metrics class. Implement
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 20 Feb 2007 19:30:17 -0800
Delivery-date: Tue, 20 Feb 2007 19:30:55 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ewan Mellor <ewan@xxxxxxxxxxxxx>
# Date 1172008511 0
# Node ID 0aa6755159d54fc1217bfde847befd3d3df78711
# Parent  7819d9332fbaa1b6d003a6e75b9aba2a50607068
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@xxxxxxxxxxxxx>
---
 docs/xen-api/xenapi-datamodel.tex           |  389 +++++++++++++++++++---------
 tools/libxen/include/xen_vif.h              |   21 -
 tools/libxen/include/xen_vif_metrics.h      |  183 +++++++++++++
 tools/libxen/include/xen_vif_metrics_decl.h |   30 ++
 tools/libxen/src/xen_vif.c                  |   52 +--
 tools/libxen/src/xen_vif_metrics.c          |  150 ++++++++++
 tools/python/xen/xend/XendAPI.py            |   73 +++--
 7 files changed, 706 insertions(+), 192 deletions(-)

diff -r 7819d9332fba -r 0aa6755159d5 docs/xen-api/xenapi-datamodel.tex
--- a/docs/xen-api/xenapi-datamodel.tex Tue Feb 20 21:28:19 2007 +0000
+++ b/docs/xen-api/xenapi-datamodel.tex Tue Feb 20 21:55:11 2007 +0000
@@ -31,6 +31,7 @@ Name & Description \\
 {\tt host\_cpu} & A physical CPU \\
 {\tt network} & A virtual network \\
 {\tt VIF} & A virtual network interface \\
+{\tt VIF\_metrics} & The metrics associated with a virtual network device \\
 {\tt PIF} & A physical network interface (note separate VLANs are represented 
as several PIFs) \\
 {\tt PIF\_metrics} & The metrics associated with a physical network interface 
\\
 {\tt SR} & A storage repository \\
@@ -6709,8 +6710,7 @@ Quals & Field & Type & Description \\
 $\mathit{RO}_\mathit{ins}$ &  {\tt VM} & VM ref & virtual machine to which 
this vif is connected \\
 $\mathit{RW}$ &  {\tt MAC} & string & ethernet MAC address of virtual 
interface, as exposed to guest \\
 $\mathit{RW}$ &  {\tt MTU} & int & MTU in octets \\
-$\mathit{RO}_\mathit{run}$ &  {\tt io/read\_kbs} & float & Read bandwidth 
(KiB/s) \\
-$\mathit{RO}_\mathit{run}$ &  {\tt io/write\_kbs} & float & Write bandwidth 
(KiB/s) \\
+$\mathit{RO}_\mathit{run}$ &  {\tt metrics} & VIF\_metrics ref & metrics 
associated with this VIF. \\
 \hline
 \end{longtable}
 \subsection{Additional RPCs associated with class: VIF}
@@ -7008,23 +7008,234 @@ void
 \vspace{0.3cm}
 \vspace{0.3cm}
 \vspace{0.3cm}
+\subsubsection{RPC name:~get\_metrics}
+
+{\bf Overview:} 
+Get the metrics field of the given VIF.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} (VIF_metrics ref) get_metrics (session_id s, VIF ref 
self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VIF ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+VIF\_metrics ref
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~create}
+
+{\bf Overview:} 
+Create a new VIF instance, and return its handle.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} (VIF ref) create (session_id s, VIF record args)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VIF record } & args & All constructor arguments \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+VIF ref
+}
+
+
+reference to the newly created object
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~destroy}
+
+{\bf Overview:} 
+Destroy the specified VIF instance.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} void destroy (session_id s, VIF ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VIF ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+void
+}
+
+
+
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_by\_uuid}
+
+{\bf Overview:} 
+Get a reference to the VIF instance with the specified UUID.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} (VIF ref) get_by_uuid (session_id s, string 
uuid)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt string } & uuid & UUID of object to return \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+VIF ref
+}
+
+
+reference to the object
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_record}
+
+{\bf Overview:} 
+Get a record containing the current state of the given VIF.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} (VIF record) get_record (session_id s, VIF ref 
self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VIF ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+VIF record
+}
+
+
+all fields from the object
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+
+\vspace{1cm}
+\newpage
+\section{Class: VIF\_metrics}
+\subsection{Fields for class: VIF\_metrics}
+\begin{longtable}{|lllp{0.38\textwidth}|}
+\hline
+\multicolumn{1}{|l}{Name} & \multicolumn{3}{l|}{\bf VIF\_metrics} \\
+\multicolumn{1}{|l}{Description} & \multicolumn{3}{l|}{\parbox{11cm}{\em
+The metrics associated with a virtual network device.}} \\
+\hline
+Quals & Field & Type & Description \\
+\hline
+$\mathit{RO}_\mathit{run}$ &  {\tt uuid} & string & unique identifier/object 
reference \\
+$\mathit{RO}_\mathit{run}$ &  {\tt io/read\_kbs} & float & Read bandwidth 
(KiB/s) \\
+$\mathit{RO}_\mathit{run}$ &  {\tt io/write\_kbs} & float & Write bandwidth 
(KiB/s) \\
+\hline
+\end{longtable}
+\subsection{Additional RPCs associated with class: VIF\_metrics}
+\subsubsection{RPC name:~get\_uuid}
+
+{\bf Overview:} 
+Get the uuid field of the given VIF\_metrics.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} string get_uuid (session_id s, VIF_metrics ref 
self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VIF\_metrics ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+string
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
 \subsubsection{RPC name:~get\_io\_read\_kbs}
 
 {\bf Overview:} 
-Get the io/read\_kbs field of the given VIF.
-
- \noindent {\bf Signature:} 
-\begin{verbatim} float get_io_read_kbs (session_id s, VIF ref 
self)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
- 
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt VIF ref } & self & reference to the object \\ \hline 
+Get the io/read\_kbs field of the given VIF\_metrics.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} float get_io_read_kbs (session_id s, VIF_metrics ref 
self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VIF\_metrics ref } & self & reference to the object \\ \hline 
 
 \end{tabular}
 
@@ -7043,20 +7254,20 @@ value of the field
 \subsubsection{RPC name:~get\_io\_write\_kbs}
 
 {\bf Overview:} 
-Get the io/write\_kbs field of the given VIF.
-
- \noindent {\bf Signature:} 
-\begin{verbatim} float get_io_write_kbs (session_id s, VIF ref 
self)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
- 
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt VIF ref } & self & reference to the object \\ \hline 
+Get the io/write\_kbs field of the given VIF\_metrics.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} float get_io_write_kbs (session_id s, VIF_metrics ref 
self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VIF\_metrics ref } & self & reference to the object \\ \hline 
 
 \end{tabular}
 
@@ -7072,77 +7283,13 @@ value of the field
 \vspace{0.3cm}
 \vspace{0.3cm}
 \vspace{0.3cm}
-\subsubsection{RPC name:~create}
-
-{\bf Overview:} 
-Create a new VIF instance, and return its handle.
-
- \noindent {\bf Signature:} 
-\begin{verbatim} (VIF ref) create (session_id s, VIF record args)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
- 
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt VIF record } & args & All constructor arguments \\ \hline 
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:} 
-{\tt 
-VIF ref
-}
-
-
-reference to the newly created object
-\vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
-\subsubsection{RPC name:~destroy}
-
-{\bf Overview:} 
-Destroy the specified VIF instance.
-
- \noindent {\bf Signature:} 
-\begin{verbatim} void destroy (session_id s, VIF ref self)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
- 
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt VIF ref } & self & reference to the object \\ \hline 
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:} 
-{\tt 
-void
-}
-
-
-
-\vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
 \subsubsection{RPC name:~get\_by\_uuid}
 
 {\bf Overview:} 
-Get a reference to the VIF instance with the specified UUID.
-
- \noindent {\bf Signature:} 
-\begin{verbatim} (VIF ref) get_by_uuid (session_id s, string 
uuid)\end{verbatim}
+Get a reference to the VIF\_metrics instance with the specified UUID.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} (VIF_metrics ref) get_by_uuid (session_id s, string 
uuid)\end{verbatim}
 
 
 \noindent{\bf Arguments:}
@@ -7160,7 +7307,7 @@ Get a reference to the VIF instance with
 
  \noindent {\bf Return Type:} 
 {\tt 
-VIF ref
+VIF\_metrics ref
 }
 
 
@@ -7171,28 +7318,28 @@ reference to the object
 \subsubsection{RPC name:~get\_record}
 
 {\bf Overview:} 
-Get a record containing the current state of the given VIF.
-
- \noindent {\bf Signature:} 
-\begin{verbatim} (VIF record) get_record (session_id s, VIF ref 
self)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
- 
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt VIF ref } & self & reference to the object \\ \hline 
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:} 
-{\tt 
-VIF record
+Get a record containing the current state of the given VIF\_metrics.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} (VIF_metrics record) get_record (session_id s, VIF_metrics 
ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VIF\_metrics ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+VIF\_metrics record
 }
 
 
diff -r 7819d9332fba -r 0aa6755159d5 tools/libxen/include/xen_vif.h
--- a/tools/libxen/include/xen_vif.h    Tue Feb 20 21:28:19 2007 +0000
+++ b/tools/libxen/include/xen_vif.h    Tue Feb 20 21:55:11 2007 +0000
@@ -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
@@ -22,6 +22,7 @@
 #include "xen_common.h"
 #include "xen_network_decl.h"
 #include "xen_vif_decl.h"
+#include "xen_vif_metrics_decl.h"
 #include "xen_vm_decl.h"
 
 
@@ -69,8 +70,7 @@ typedef struct xen_vif_record
     struct xen_vm_record_opt *vm;
     char *mac;
     int64_t mtu;
-    double io_read_kbs;
-    double io_write_kbs;
+    struct xen_vif_metrics_record_opt *metrics;
 } xen_vif_record;
 
 /**
@@ -223,17 +223,10 @@ xen_vif_get_mtu(xen_session *session, in
 
 
 /**
- * Get the io/read_kbs field of the given VIF.
- */
-extern bool
-xen_vif_get_io_read_kbs(xen_session *session, double *result, xen_vif vif);
-
-
-/**
- * Get the io/write_kbs field of the given VIF.
- */
-extern bool
-xen_vif_get_io_write_kbs(xen_session *session, double *result, xen_vif vif);
+ * Get the metrics field of the given VIF.
+ */
+extern bool
+xen_vif_get_metrics(xen_session *session, xen_vif_metrics *result, xen_vif 
vif);
 
 
 /**
diff -r 7819d9332fba -r 0aa6755159d5 tools/libxen/include/xen_vif_metrics.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxen/include/xen_vif_metrics.h    Tue Feb 20 21:55:11 2007 +0000
@@ -0,0 +1,183 @@
+/*
+ * 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ */
+
+#ifndef XEN_VIF_METRICS_H
+#define XEN_VIF_METRICS_H
+
+#include "xen_common.h"
+#include "xen_vif_metrics_decl.h"
+
+
+/*
+ * The VIF_metrics class.
+ * 
+ * The metrics associated with a virtual network device.
+ */
+
+
+/**
+ * Free the given xen_vif_metrics.  The given handle must have been
+ * allocated by this library.
+ */
+extern void
+xen_vif_metrics_free(xen_vif_metrics vif_metrics);
+
+
+typedef struct xen_vif_metrics_set
+{
+    size_t size;
+    xen_vif_metrics *contents[];
+} xen_vif_metrics_set;
+
+/**
+ * Allocate a xen_vif_metrics_set of the given size.
+ */
+extern xen_vif_metrics_set *
+xen_vif_metrics_set_alloc(size_t size);
+
+/**
+ * Free the given xen_vif_metrics_set.  The given set must have been
+ * allocated by this library.
+ */
+extern void
+xen_vif_metrics_set_free(xen_vif_metrics_set *set);
+
+
+typedef struct xen_vif_metrics_record
+{
+    xen_vif_metrics handle;
+    char *uuid;
+    double io_read_kbs;
+    double io_write_kbs;
+} xen_vif_metrics_record;
+
+/**
+ * Allocate a xen_vif_metrics_record.
+ */
+extern xen_vif_metrics_record *
+xen_vif_metrics_record_alloc(void);
+
+/**
+ * Free the given xen_vif_metrics_record, and all referenced values. 
+ * The given record must have been allocated by this library.
+ */
+extern void
+xen_vif_metrics_record_free(xen_vif_metrics_record *record);
+
+
+typedef struct xen_vif_metrics_record_opt
+{
+    bool is_record;
+    union
+    {
+        xen_vif_metrics handle;
+        xen_vif_metrics_record *record;
+    } u;
+} xen_vif_metrics_record_opt;
+
+/**
+ * Allocate a xen_vif_metrics_record_opt.
+ */
+extern xen_vif_metrics_record_opt *
+xen_vif_metrics_record_opt_alloc(void);
+
+/**
+ * Free the given xen_vif_metrics_record_opt, and all referenced
+ * values.  The given record_opt must have been allocated by this library.
+ */
+extern void
+xen_vif_metrics_record_opt_free(xen_vif_metrics_record_opt *record_opt);
+
+
+typedef struct xen_vif_metrics_record_set
+{
+    size_t size;
+    xen_vif_metrics_record *contents[];
+} xen_vif_metrics_record_set;
+
+/**
+ * Allocate a xen_vif_metrics_record_set of the given size.
+ */
+extern xen_vif_metrics_record_set *
+xen_vif_metrics_record_set_alloc(size_t size);
+
+/**
+ * Free the given xen_vif_metrics_record_set, and all referenced
+ * values.  The given set must have been allocated by this library.
+ */
+extern void
+xen_vif_metrics_record_set_free(xen_vif_metrics_record_set *set);
+
+
+
+typedef struct xen_vif_metrics_record_opt_set
+{
+    size_t size;
+    xen_vif_metrics_record_opt *contents[];
+} xen_vif_metrics_record_opt_set;
+
+/**
+ * Allocate a xen_vif_metrics_record_opt_set of the given size.
+ */
+extern xen_vif_metrics_record_opt_set *
+xen_vif_metrics_record_opt_set_alloc(size_t size);
+
+/**
+ * Free the given xen_vif_metrics_record_opt_set, and all referenced
+ * values.  The given set must have been allocated by this library.
+ */
+extern void
+xen_vif_metrics_record_opt_set_free(xen_vif_metrics_record_opt_set *set);
+
+
+/**
+ * Get a record containing the current state of the given VIF_metrics.
+ */
+extern bool
+xen_vif_metrics_get_record(xen_session *session, xen_vif_metrics_record 
**result, xen_vif_metrics vif_metrics);
+
+
+/**
+ * Get a reference to the VIF_metrics instance with the specified UUID.
+ */
+extern bool
+xen_vif_metrics_get_by_uuid(xen_session *session, xen_vif_metrics *result, 
char *uuid);
+
+
+/**
+ * Get the uuid field of the given VIF_metrics.
+ */
+extern bool
+xen_vif_metrics_get_uuid(xen_session *session, char **result, xen_vif_metrics 
vif_metrics);
+
+
+/**
+ * Get the io/read_kbs field of the given VIF_metrics.
+ */
+extern bool
+xen_vif_metrics_get_io_read_kbs(xen_session *session, double *result, 
xen_vif_metrics vif_metrics);
+
+
+/**
+ * Get the io/write_kbs field of the given VIF_metrics.
+ */
+extern bool
+xen_vif_metrics_get_io_write_kbs(xen_session *session, double *result, 
xen_vif_metrics vif_metrics);
+
+
+#endif
diff -r 7819d9332fba -r 0aa6755159d5 tools/libxen/include/xen_vif_metrics_decl.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxen/include/xen_vif_metrics_decl.h       Tue Feb 20 21:55:11 
2007 +0000
@@ -0,0 +1,30 @@
+/*
+ * 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ */
+
+#ifndef XEN_VIF_METRICS_DECL_H
+#define XEN_VIF_METRICS_DECL_H
+
+typedef void *xen_vif_metrics;
+
+struct xen_vif_metrics_set;
+struct xen_vif_metrics_record;
+struct xen_vif_metrics_record_set;
+struct xen_vif_metrics_record_opt;
+struct xen_vif_metrics_record_opt_set;
+
+#endif
diff -r 7819d9332fba -r 0aa6755159d5 tools/libxen/src/xen_vif.c
--- a/tools/libxen/src/xen_vif.c        Tue Feb 20 21:28:19 2007 +0000
+++ b/tools/libxen/src/xen_vif.c        Tue Feb 20 21:55:11 2007 +0000
@@ -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
@@ -24,6 +24,7 @@
 #include "xen_internal.h"
 #include "xen_network.h"
 #include "xen_vif.h"
+#include "xen_vif_metrics.h"
 #include "xen_vm.h"
 
 
@@ -56,12 +57,9 @@ static const struct_member xen_vif_recor
         { .key = "MTU",
           .type = &abstract_type_int,
           .offset = offsetof(xen_vif_record, mtu) },
-        { .key = "io_read_kbs",
-          .type = &abstract_type_float,
-          .offset = offsetof(xen_vif_record, io_read_kbs) },
-        { .key = "io_write_kbs",
-          .type = &abstract_type_float,
-          .offset = offsetof(xen_vif_record, io_write_kbs) }
+        { .key = "metrics",
+          .type = &abstract_type_ref,
+          .offset = offsetof(xen_vif_record, metrics) }
     };
 
 const abstract_type xen_vif_record_abstract_type_ =
@@ -87,6 +85,7 @@ xen_vif_record_free(xen_vif_record *reco
     xen_network_record_opt_free(record->network);
     xen_vm_record_opt_free(record->vm);
     free(record->mac);
+    xen_vif_metrics_record_opt_free(record->metrics);
     free(record);
 }
 
@@ -247,33 +246,18 @@ xen_vif_get_mtu(xen_session *session, in
 
 
 bool
-xen_vif_get_io_read_kbs(xen_session *session, double *result, xen_vif vif)
-{
-    abstract_value param_values[] =
-        {
-            { .type = &abstract_type_string,
-              .u.string_val = vif }
-        };
-
-    abstract_type result_type = abstract_type_float;
-
-    XEN_CALL_("VIF.get_io_read_kbs");
-    return session->ok;
-}
-
-
-bool
-xen_vif_get_io_write_kbs(xen_session *session, double *result, xen_vif vif)
-{
-    abstract_value param_values[] =
-        {
-            { .type = &abstract_type_string,
-              .u.string_val = vif }
-        };
-
-    abstract_type result_type = abstract_type_float;
-
-    XEN_CALL_("VIF.get_io_write_kbs");
+xen_vif_get_metrics(xen_session *session, xen_vif_metrics *result, xen_vif vif)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = vif }
+        };
+
+    abstract_type result_type = abstract_type_string;
+
+    *result = NULL;
+    XEN_CALL_("VIF.get_metrics");
     return session->ok;
 }
 
diff -r 7819d9332fba -r 0aa6755159d5 tools/libxen/src/xen_vif_metrics.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxen/src/xen_vif_metrics.c        Tue Feb 20 21:55:11 2007 +0000
@@ -0,0 +1,150 @@
+/*
+ * 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ */
+
+
+#include <stddef.h>
+#include <stdlib.h>
+
+#include "xen_common.h"
+#include "xen_internal.h"
+#include "xen_vif_metrics.h"
+
+
+XEN_FREE(xen_vif_metrics)
+XEN_SET_ALLOC_FREE(xen_vif_metrics)
+XEN_ALLOC(xen_vif_metrics_record)
+XEN_SET_ALLOC_FREE(xen_vif_metrics_record)
+XEN_ALLOC(xen_vif_metrics_record_opt)
+XEN_RECORD_OPT_FREE(xen_vif_metrics)
+XEN_SET_ALLOC_FREE(xen_vif_metrics_record_opt)
+
+
+static const struct_member xen_vif_metrics_record_struct_members[] =
+    {
+        { .key = "uuid",
+          .type = &abstract_type_string,
+          .offset = offsetof(xen_vif_metrics_record, uuid) },
+        { .key = "io_read_kbs",
+          .type = &abstract_type_float,
+          .offset = offsetof(xen_vif_metrics_record, io_read_kbs) },
+        { .key = "io_write_kbs",
+          .type = &abstract_type_float,
+          .offset = offsetof(xen_vif_metrics_record, io_write_kbs) }
+    };
+
+const abstract_type xen_vif_metrics_record_abstract_type_ =
+    {
+       .typename = STRUCT,
+       .struct_size = sizeof(xen_vif_metrics_record),
+       .member_count =
+           sizeof(xen_vif_metrics_record_struct_members) / 
sizeof(struct_member),
+       .members = xen_vif_metrics_record_struct_members
+    };
+
+
+void
+xen_vif_metrics_record_free(xen_vif_metrics_record *record)
+{
+    if (record == NULL)
+    {
+        return;
+    }
+    free(record->handle);
+    free(record->uuid);
+    free(record);
+}
+
+
+bool
+xen_vif_metrics_get_record(xen_session *session, xen_vif_metrics_record 
**result, xen_vif_metrics vif_metrics)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = vif_metrics }
+        };
+
+    abstract_type result_type = xen_vif_metrics_record_abstract_type_;
+
+    *result = NULL;
+    XEN_CALL_("VIF_metrics.get_record");
+
+    if (session->ok)
+    {
+       (*result)->handle = xen_strdup_((*result)->uuid);
+    }
+
+    return session->ok;
+}
+
+
+bool
+xen_vif_metrics_get_by_uuid(xen_session *session, xen_vif_metrics *result, 
char *uuid)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = uuid }
+        };
+
+    abstract_type result_type = abstract_type_string;
+
+    *result = NULL;
+    XEN_CALL_("VIF_metrics.get_by_uuid");
+    return session->ok;
+}
+
+
+bool
+xen_vif_metrics_get_io_read_kbs(xen_session *session, double *result, 
xen_vif_metrics vif_metrics)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = vif_metrics }
+        };
+
+    abstract_type result_type = abstract_type_float;
+
+    XEN_CALL_("VIF_metrics.get_io_read_kbs");
+    return session->ok;
+}
+
+
+bool
+xen_vif_metrics_get_io_write_kbs(xen_session *session, double *result, 
xen_vif_metrics vif_metrics)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = vif_metrics }
+        };
+
+    abstract_type result_type = abstract_type_float;
+
+    XEN_CALL_("VIF_metrics.get_io_write_kbs");
+    return session->ok;
+}
+
+
+bool
+xen_vif_metrics_get_uuid(xen_session *session, char **result, xen_vif_metrics 
vif_metrics)
+{
+    *result = session->ok ? xen_strdup_((char *)vif_metrics) : NULL;
+    return session->ok;
+}
diff -r 7819d9332fba -r 0aa6755159d5 tools/python/xen/xend/XendAPI.py
--- a/tools/python/xen/xend/XendAPI.py  Tue Feb 20 21:28:19 2007 +0000
+++ b/tools/python/xen/xend/XendAPI.py  Tue Feb 20 21:55:11 2007 +0000
@@ -229,6 +229,16 @@ def valid_vif(func):
            _check_ref(lambda r: XendDomain.instance().is_valid_dev('vif', r),
                       'VIF', func, *args, **kwargs)
 
+def valid_vif_metrics(func):
+    """Decorator to verify if ref is valid before calling method.
+
+    @param func: function with params: (self, session, ref, ...)
+    @rtype: callable object
+    """    
+    return lambda *args, **kwargs: \
+           _check_ref(lambda r: XendDomain.instance().is_valid_dev('vif', r),
+                      'VIF_metrics', func, *args, **kwargs)
+
 def valid_vdi(func):
     """Decorator to verify if vdi_ref is valid before calling method.
 
@@ -390,6 +400,7 @@ class XendAPI(object):
             'VBD'          : valid_vbd,
             'VBD_metrics'  : valid_vbd_metrics,
             'VIF'          : valid_vif,
+            'VIF_metrics'  : valid_vif_metrics,
             'VDI'          : valid_vdi,
             'VTPM'         : valid_vtpm,
             'console'      : valid_console,
@@ -1592,18 +1603,17 @@ class XendAPI(object):
             { 'io_read_kbs'  : vm.get_dev_property('vbd', ref, 'io_read_kbs'),
               'io_write_kbs' : vm.get_dev_property('vbd', ref, 'io_write_kbs') 
})
 
-    def VBD_metrics_get_io_write_kbs(self, _, ref):
+    def VBD_metrics_get_io_read_kbs(self, _, ref):
         return self._VBD_get(ref, 'io_read_kbs')
     
-    def VBD_metrics_get_io_write_kbs(self, session, vbd_ref):
+    def VBD_metrics_get_io_write_kbs(self, session, ref):
         return self._VBD_get(ref, 'io_write_kbs')
 
 
     # Xen API: Class VIF
     # ----------------------------------------------------------------
 
-    VIF_attr_ro = ['io_read_kbs',
-                   'io_write_kbs']
+    VIF_attr_ro = ['metrics']
     VIF_attr_rw = ['device',
                    'network',
                    'VM',
@@ -1633,6 +1643,8 @@ class XendAPI(object):
             if k in valid_vif_keys:
                 return_cfg[k] = cfg[k]
             
+        return_cfg['metrics'] = vif_ref
+
         return xen_api_success(return_cfg)
 
     # class methods
@@ -1659,36 +1671,28 @@ class XendAPI(object):
         vm.destroy_vif(vif_ref)
         return xen_api_success_void()
 
+    def _VIF_get(self, ref, prop):
+        return xen_api_success(
+            XendDomain.instance().get_dev_property_by_uuid('vif', ref, prop))
+
     # getters/setters
+    def VIF_get_metrics(self, _, vif_ref):
+        return xen_api_success(vif_ref)
+
     def VIF_get_VM(self, session, vif_ref):
         xendom = XendDomain.instance()        
         vm = xendom.get_vm_with_dev_uuid('vif', vif_ref)        
         return xen_api_success(vm.get_uuid())
     
     def VIF_get_MTU(self, session, vif_ref):
-        xendom = XendDomain.instance()
-        return xen_api_success(xendom.get_dev_property_by_uuid('vif', vif_ref,
-                                                               'MTU'))
+        return self._VIF_get(vif_ref, 'MTU')
+    
     def VIF_get_MAC(self, session, vif_ref):
-        xendom = XendDomain.instance()
-        return xen_api_success(xendom.get_dev_property_by_uuid('vif', vif_ref,
-                                                               'MAC'))
+        return self._VIF_get(vif_ref, 'MAC')
 
     def VIF_get_device(self, session, vif_ref):
-        xendom = XendDomain.instance()
-        return xen_api_success(xendom.get_dev_property_by_uuid('vif', vif_ref,
-                                                               'device'))
+        return self._VIF_get(vif_ref, 'device')
  
-    def VIF_get_io_read_kbs(self, session, vif_ref):
-        xendom = XendDomain.instance()
-        return xen_api_success(xendom.get_dev_property_by_uuid('vif', vif_ref,
-                                                               'io_read_kbs'))
-
-    def VIF_get_io_write_kbs(self, session, vif_ref):
-        xendom = XendDomain.instance()
-        return xen_api_success(xendom.get_dev_property_by_uuid('vif', vif_ref,
-                                                               'io_write_kbs'))
-
     def VIF_get_all(self, session):
         xendom = XendDomain.instance()
         vifs = [d.get_vifs() for d in XendDomain.instance().list('all')]
@@ -1696,6 +1700,29 @@ class XendAPI(object):
         return xen_api_success(vifs)
 
     
+    # Xen API: Class VIF_metrics
+    # ----------------------------------------------------------------
+
+    VIF_metrics_attr_ro = ['io_read_kbs',
+                           'io_write_kbs']
+    VIF_metrics_attr_rw = []
+    VIF_methods = []
+
+    def VIF_metrics_get_record(self, _, ref):
+        vm = XendDomain.instance().get_vm_with_dev_uuid('vif', ref)
+        if not vm:
+            return xen_api_error(['HANDLE_INVALID', 'VIF_metrics', ref])
+        return xen_api_success(
+            { 'io_read_kbs'  : vm.get_dev_property('vif', ref, 'io_read_kbs'),
+              'io_write_kbs' : vm.get_dev_property('vif', ref, 'io_write_kbs') 
})
+
+    def VIF_metrics_get_io_read_kbs(self, _, ref):
+        return self._VIF_get(ref, 'io_read_kbs')
+    
+    def VIF_metrics_get_io_write_kbs(self, session, ref):
+        return self._VIF_get(ref, 'io_write_kbs')
+
+
     # Xen API: Class VDI
     # ----------------------------------------------------------------
     VDI_attr_ro = ['VBDs',

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] Split the VIF I/O statistics fields out into a VIF_metrics class. Implement, Xen patchbot-unstable <=