# HG changeset patch
# User Ewan Mellor <ewan@xxxxxxxxxxxxx>
# Date 1172006899 0
# Node ID 7819d9332fbaa1b6d003a6e75b9aba2a50607068
# Parent 988b90c6b4f3b628430a73b5562e65c859953173
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@xxxxxxxxxxxxx>
---
docs/xen-api/xenapi-datamodel.tex | 1141 +++++++++++++++------------
tools/libxen/include/xen_vbd.h | 41
tools/libxen/include/xen_vbd_metrics.h | 183 ++++
tools/libxen/include/xen_vbd_metrics_decl.h | 30
tools/libxen/include/xen_vbd_type.h | 77 +
tools/libxen/include/xen_vbd_type_internal.h | 37
tools/libxen/src/xen_vbd.c | 99 +-
tools/libxen/src/xen_vbd_metrics.c | 150 +++
tools/libxen/src/xen_vbd_type.c | 81 +
tools/python/xen/xend/XendAPI.py | 54 +
10 files changed, 1329 insertions(+), 564 deletions(-)
diff -r 988b90c6b4f3 -r 7819d9332fba docs/xen-api/xenapi-datamodel.tex
--- a/docs/xen-api/xenapi-datamodel.tex Tue Feb 20 19:38:24 2007 +0000
+++ b/docs/xen-api/xenapi-datamodel.tex Tue Feb 20 21:28:19 2007 +0000
@@ -36,6 +36,7 @@ Name & Description \\
{\tt SR} & A storage repository \\
{\tt VDI} & A virtual disk image \\
{\tt VBD} & A virtual block device \\
+{\tt VBD\_metrics} & The metrics associated with a virtual block device \\
{\tt PBD} & The physical block devices through which hosts access SRs \\
{\tt crashdump} & A VM crashdump \\
{\tt VTPM} & A virtual TPM device \\
@@ -9462,63 +9463,601 @@ Quals & Field & Type & Description \\
$\mathit{RW}$ & {\tt bootable} & bool & true if this VBD is bootable \\
$\mathit{RW}$ & {\tt mode} & vbd\_mode & the mode the VBD should be mounted
with \\
$\mathit{RW}$ & {\tt type} & vbd\_type & how the VBD will appear to the guest
(e.g. disk or CD) \\
+$\mathit{RO}_\mathit{run}$ & {\tt metrics} & VBD\_metrics ref & metrics
associated with this VBD. \\
+\hline
+\end{longtable}
+\subsection{Additional RPCs associated with class: VBD}
+\subsubsection{RPC name:~media\_change}
+
+{\bf Overview:}
+Change the media in the device for CDROM-like devices only. For other
+devices, detach the VBD and attach a new one.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} void media_change (session_id s, VBD ref vbd, VDI ref
vdi)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VBD ref } & vbd & The vbd representing the CDROM-like device \\ \hline
+
+{\tt VDI ref } & vdi & The new VDI to 'insert' \\ \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\_uuid}
+
+{\bf Overview:}
+Get the uuid field of the given VBD.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} string get_uuid (session_id s, VBD 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 VBD 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\_VM}
+
+{\bf Overview:}
+Get the VM field of the given VBD.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} (VM ref) get_VM (session_id s, VBD 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 VBD ref } & self & reference to the object \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+VM ref
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_VDI}
+
+{\bf Overview:}
+Get the VDI field of the given VBD.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} (VDI ref) get_VDI (session_id s, VBD 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 VBD ref } & self & reference to the object \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+VDI ref
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_device}
+
+{\bf Overview:}
+Get the device field of the given VBD.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} string get_device (session_id s, VBD 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 VBD 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:~set\_device}
+
+{\bf Overview:}
+Set the device field of the given VBD.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} void set_device (session_id s, VBD ref self, string
value)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VBD ref } & self & reference to the object \\ \hline
+
+{\tt string } & value & New value to set \\ \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\_bootable}
+
+{\bf Overview:}
+Get the bootable field of the given VBD.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} bool get_bootable (session_id s, VBD 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 VBD ref } & self & reference to the object \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+bool
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~set\_bootable}
+
+{\bf Overview:}
+Set the bootable field of the given VBD.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} void set_bootable (session_id s, VBD ref self, bool
value)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VBD ref } & self & reference to the object \\ \hline
+
+{\tt bool } & value & New value to set \\ \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\_mode}
+
+{\bf Overview:}
+Get the mode field of the given VBD.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} (vbd_mode) get_mode (session_id s, VBD 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 VBD ref } & self & reference to the object \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+vbd\_mode
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~set\_mode}
+
+{\bf Overview:}
+Set the mode field of the given VBD.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} void set_mode (session_id s, VBD ref self, vbd_mode
value)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VBD ref } & self & reference to the object \\ \hline
+
+{\tt vbd\_mode } & value & New value to set \\ \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\_type}
+
+{\bf Overview:}
+Get the type field of the given VBD.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} (vbd_type) get_type (session_id s, VBD 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 VBD ref } & self & reference to the object \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+vbd\_type
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~set\_type}
+
+{\bf Overview:}
+Set the type field of the given VBD.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} void set_type (session_id s, VBD ref self, vbd_type
value)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VBD ref } & self & reference to the object \\ \hline
+
+{\tt vbd\_type } & value & New value to set \\ \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\_metrics}
+
+{\bf Overview:}
+Get the metrics field of the given VBD.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} (VBD_metrics ref) get_metrics (session_id s, VBD 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 VBD ref } & self & reference to the object \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+VBD\_metrics ref
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~create}
+
+{\bf Overview:}
+Create a new VBD instance, and return its handle.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} (VBD ref) create (session_id s, VBD 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 VBD record } & args & All constructor arguments \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+VBD 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 VBD instance.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} void destroy (session_id s, VBD 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 VBD 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 VBD instance with the specified UUID.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} (VBD 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
+VBD 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 VBD.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} (VBD record) get_record (session_id s, VBD 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 VBD ref } & self & reference to the object \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+VBD record
+}
+
+
+all fields from the object
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+
+\vspace{1cm}
+\newpage
+\section{Class: VBD\_metrics}
+\subsection{Fields for class: VBD\_metrics}
+\begin{longtable}{|lllp{0.38\textwidth}|}
+\hline
+\multicolumn{1}{|l}{Name} & \multicolumn{3}{l|}{\bf VBD\_metrics} \\
+\multicolumn{1}{|l}{Description} & \multicolumn{3}{l|}{\parbox{11cm}{\em
+The metrics associated with a virtual block 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: VBD}
-\subsubsection{RPC name:~media\_change}
-
-{\bf Overview:}
-Change the media in the device for CDROM-like devices only. For other
-devices, detach the VBD and attach a new one.
-
- \noindent {\bf Signature:}
-\begin{verbatim} void media_change (session_id s, VBD ref vbd, VDI ref
vdi)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
-
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt VBD ref } & vbd & The vbd representing the CDROM-like device \\ \hline
-
-{\tt VDI ref } & vdi & The new VDI to 'insert' \\ \hline
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:}
-{\tt
-void
-}
-
-
-
-\vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
+\subsection{Additional RPCs associated with class: VBD\_metrics}
\subsubsection{RPC name:~get\_uuid}
{\bf Overview:}
-Get the uuid field of the given VBD.
-
- \noindent {\bf Signature:}
-\begin{verbatim} string get_uuid (session_id s, VBD 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 VBD ref } & self & reference to the object \\ \hline
+Get the uuid field of the given VBD\_metrics.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} string get_uuid (session_id s, VBD_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 VBD\_metrics ref } & self & reference to the object \\ \hline
\end{tabular}
@@ -9534,351 +10073,23 @@ value of the field
\vspace{0.3cm}
\vspace{0.3cm}
\vspace{0.3cm}
-\subsubsection{RPC name:~get\_VM}
-
-{\bf Overview:}
-Get the VM field of the given VBD.
-
- \noindent {\bf Signature:}
-\begin{verbatim} (VM ref) get_VM (session_id s, VBD 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 VBD ref } & self & reference to the object \\ \hline
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:}
-{\tt
-VM ref
-}
-
-
-value of the field
-\vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
-\subsubsection{RPC name:~get\_VDI}
-
-{\bf Overview:}
-Get the VDI field of the given VBD.
-
- \noindent {\bf Signature:}
-\begin{verbatim} (VDI ref) get_VDI (session_id s, VBD 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 VBD ref } & self & reference to the object \\ \hline
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:}
-{\tt
-VDI ref
-}
-
-
-value of the field
-\vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
-\subsubsection{RPC name:~get\_device}
-
-{\bf Overview:}
-Get the device field of the given VBD.
-
- \noindent {\bf Signature:}
-\begin{verbatim} string get_device (session_id s, VBD 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 VBD 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:~set\_device}
-
-{\bf Overview:}
-Set the device field of the given VBD.
-
- \noindent {\bf Signature:}
-\begin{verbatim} void set_device (session_id s, VBD ref self, string
value)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
-
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt VBD ref } & self & reference to the object \\ \hline
-
-{\tt string } & value & New value to set \\ \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\_bootable}
-
-{\bf Overview:}
-Get the bootable field of the given VBD.
-
- \noindent {\bf Signature:}
-\begin{verbatim} bool get_bootable (session_id s, VBD 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 VBD ref } & self & reference to the object \\ \hline
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:}
-{\tt
-bool
-}
-
-
-value of the field
-\vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
-\subsubsection{RPC name:~set\_bootable}
-
-{\bf Overview:}
-Set the bootable field of the given VBD.
-
- \noindent {\bf Signature:}
-\begin{verbatim} void set_bootable (session_id s, VBD ref self, bool
value)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
-
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt VBD ref } & self & reference to the object \\ \hline
-
-{\tt bool } & value & New value to set \\ \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\_mode}
-
-{\bf Overview:}
-Get the mode field of the given VBD.
-
- \noindent {\bf Signature:}
-\begin{verbatim} (vbd_mode) get_mode (session_id s, VBD 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 VBD ref } & self & reference to the object \\ \hline
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:}
-{\tt
-vbd\_mode
-}
-
-
-value of the field
-\vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
-\subsubsection{RPC name:~set\_mode}
-
-{\bf Overview:}
-Set the mode field of the given VBD.
-
- \noindent {\bf Signature:}
-\begin{verbatim} void set_mode (session_id s, VBD ref self, vbd_mode
value)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
-
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt VBD ref } & self & reference to the object \\ \hline
-
-{\tt vbd\_mode } & value & New value to set \\ \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\_type}
-
-{\bf Overview:}
-Get the type field of the given VBD.
-
- \noindent {\bf Signature:}
-\begin{verbatim} (vbd_type) get_type (session_id s, VBD 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 VBD ref } & self & reference to the object \\ \hline
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:}
-{\tt
-vbd\_type
-}
-
-
-value of the field
-\vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
-\subsubsection{RPC name:~set\_type}
-
-{\bf Overview:}
-Set the type field of the given VBD.
-
- \noindent {\bf Signature:}
-\begin{verbatim} void set_type (session_id s, VBD ref self, vbd_type
value)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
-
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt VBD ref } & self & reference to the object \\ \hline
-
-{\tt vbd\_type } & value & New value to set \\ \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\_io\_read\_kbs}
{\bf Overview:}
-Get the io/read\_kbs field of the given VBD.
-
- \noindent {\bf Signature:}
-\begin{verbatim} float get_io_read_kbs (session_id s, VBD 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 VBD ref } & self & reference to the object \\ \hline
+Get the io/read\_kbs field of the given VBD\_metrics.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} float get_io_read_kbs (session_id s, VBD_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 VBD\_metrics ref } & self & reference to the object \\ \hline
\end{tabular}
@@ -9897,20 +10108,20 @@ value of the field
\subsubsection{RPC name:~get\_io\_write\_kbs}
{\bf Overview:}
-Get the io/write\_kbs field of the given VBD.
-
- \noindent {\bf Signature:}
-\begin{verbatim} float get_io_write_kbs (session_id s, VBD 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 VBD ref } & self & reference to the object \\ \hline
+Get the io/write\_kbs field of the given VBD\_metrics.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} float get_io_write_kbs (session_id s, VBD_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 VBD\_metrics ref } & self & reference to the object \\ \hline
\end{tabular}
@@ -9926,77 +10137,13 @@ value of the field
\vspace{0.3cm}
\vspace{0.3cm}
\vspace{0.3cm}
-\subsubsection{RPC name:~create}
-
-{\bf Overview:}
-Create a new VBD instance, and return its handle.
-
- \noindent {\bf Signature:}
-\begin{verbatim} (VBD ref) create (session_id s, VBD 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 VBD record } & args & All constructor arguments \\ \hline
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:}
-{\tt
-VBD 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 VBD instance.
-
- \noindent {\bf Signature:}
-\begin{verbatim} void destroy (session_id s, VBD 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 VBD 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 VBD instance with the specified UUID.
-
- \noindent {\bf Signature:}
-\begin{verbatim} (VBD ref) get_by_uuid (session_id s, string
uuid)\end{verbatim}
+Get a reference to the VBD\_metrics instance with the specified UUID.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} (VBD_metrics ref) get_by_uuid (session_id s, string
uuid)\end{verbatim}
\noindent{\bf Arguments:}
@@ -10014,7 +10161,7 @@ Get a reference to the VBD instance with
\noindent {\bf Return Type:}
{\tt
-VBD ref
+VBD\_metrics ref
}
@@ -10025,28 +10172,28 @@ reference to the object
\subsubsection{RPC name:~get\_record}
{\bf Overview:}
-Get a record containing the current state of the given VBD.
-
- \noindent {\bf Signature:}
-\begin{verbatim} (VBD record) get_record (session_id s, VBD 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 VBD ref } & self & reference to the object \\ \hline
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:}
-{\tt
-VBD record
+Get a record containing the current state of the given VBD\_metrics.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} (VBD_metrics record) get_record (session_id s, VBD_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 VBD\_metrics ref } & self & reference to the object \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+VBD\_metrics record
}
diff -r 988b90c6b4f3 -r 7819d9332fba tools/libxen/include/xen_vbd.h
--- a/tools/libxen/include/xen_vbd.h Tue Feb 20 19:38:24 2007 +0000
+++ b/tools/libxen/include/xen_vbd.h Tue Feb 20 21:28:19 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
@@ -21,7 +21,9 @@
#include "xen_common.h"
#include "xen_vbd_decl.h"
+#include "xen_vbd_metrics_decl.h"
#include "xen_vbd_mode.h"
+#include "xen_vbd_type.h"
#include "xen_vdi_decl.h"
#include "xen_vm_decl.h"
@@ -71,8 +73,8 @@ typedef struct xen_vbd_record
char *image;
bool bootable;
enum xen_vbd_mode mode;
- double io_read_kbs;
- double io_write_kbs;
+ enum xen_vbd_type type;
+ struct xen_vbd_metrics_record_opt *metrics;
} xen_vbd_record;
/**
@@ -155,14 +157,14 @@ xen_vbd_record_opt_set_free(xen_vbd_reco
/**
- * Get the current state of the given VBD. !!!
+ * Get a record containing the current state of the given VBD.
*/
extern bool
xen_vbd_get_record(xen_session *session, xen_vbd_record **result, xen_vbd vbd);
/**
- * Get a reference to the object with the specified UUID. !!!
+ * Get a reference to the VBD instance with the specified UUID.
*/
extern bool
xen_vbd_get_by_uuid(xen_session *session, xen_vbd *result, char *uuid);
@@ -225,17 +227,17 @@ xen_vbd_get_mode(xen_session *session, e
/**
- * Get the io/read_kbs field of the given VBD.
- */
-extern bool
-xen_vbd_get_io_read_kbs(xen_session *session, double *result, xen_vbd vbd);
-
-
-/**
- * Get the io/write_kbs field of the given VBD.
- */
-extern bool
-xen_vbd_get_io_write_kbs(xen_session *session, double *result, xen_vbd vbd);
+ * Get the type field of the given VBD.
+ */
+extern bool
+xen_vbd_get_type(xen_session *session, enum xen_vbd_type *result, xen_vbd vbd);
+
+
+/**
+ * Get the metrics field of the given VBD.
+ */
+extern bool
+xen_vbd_get_metrics(xen_session *session, xen_vbd_metrics *result, xen_vbd
vbd);
/**
@@ -257,6 +259,13 @@ xen_vbd_set_bootable(xen_session *sessio
*/
extern bool
xen_vbd_set_mode(xen_session *session, xen_vbd vbd, enum xen_vbd_mode mode);
+
+
+/**
+ * Set the type field of the given VBD.
+ */
+extern bool
+xen_vbd_set_type(xen_session *session, xen_vbd vbd, enum xen_vbd_type type);
/**
diff -r 988b90c6b4f3 -r 7819d9332fba tools/libxen/include/xen_vbd_metrics.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxen/include/xen_vbd_metrics.h Tue Feb 20 21:28:19 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_VBD_METRICS_H
+#define XEN_VBD_METRICS_H
+
+#include "xen_common.h"
+#include "xen_vbd_metrics_decl.h"
+
+
+/*
+ * The VBD_metrics class.
+ *
+ * The metrics associated with a virtual block device.
+ */
+
+
+/**
+ * Free the given xen_vbd_metrics. The given handle must have been
+ * allocated by this library.
+ */
+extern void
+xen_vbd_metrics_free(xen_vbd_metrics vbd_metrics);
+
+
+typedef struct xen_vbd_metrics_set
+{
+ size_t size;
+ xen_vbd_metrics *contents[];
+} xen_vbd_metrics_set;
+
+/**
+ * Allocate a xen_vbd_metrics_set of the given size.
+ */
+extern xen_vbd_metrics_set *
+xen_vbd_metrics_set_alloc(size_t size);
+
+/**
+ * Free the given xen_vbd_metrics_set. The given set must have been
+ * allocated by this library.
+ */
+extern void
+xen_vbd_metrics_set_free(xen_vbd_metrics_set *set);
+
+
+typedef struct xen_vbd_metrics_record
+{
+ xen_vbd_metrics handle;
+ char *uuid;
+ double io_read_kbs;
+ double io_write_kbs;
+} xen_vbd_metrics_record;
+
+/**
+ * Allocate a xen_vbd_metrics_record.
+ */
+extern xen_vbd_metrics_record *
+xen_vbd_metrics_record_alloc(void);
+
+/**
+ * Free the given xen_vbd_metrics_record, and all referenced values.
+ * The given record must have been allocated by this library.
+ */
+extern void
+xen_vbd_metrics_record_free(xen_vbd_metrics_record *record);
+
+
+typedef struct xen_vbd_metrics_record_opt
+{
+ bool is_record;
+ union
+ {
+ xen_vbd_metrics handle;
+ xen_vbd_metrics_record *record;
+ } u;
+} xen_vbd_metrics_record_opt;
+
+/**
+ * Allocate a xen_vbd_metrics_record_opt.
+ */
+extern xen_vbd_metrics_record_opt *
+xen_vbd_metrics_record_opt_alloc(void);
+
+/**
+ * Free the given xen_vbd_metrics_record_opt, and all referenced
+ * values. The given record_opt must have been allocated by this library.
+ */
+extern void
+xen_vbd_metrics_record_opt_free(xen_vbd_metrics_record_opt *record_opt);
+
+
+typedef struct xen_vbd_metrics_record_set
+{
+ size_t size;
+ xen_vbd_metrics_record *contents[];
+} xen_vbd_metrics_record_set;
+
+/**
+ * Allocate a xen_vbd_metrics_record_set of the given size.
+ */
+extern xen_vbd_metrics_record_set *
+xen_vbd_metrics_record_set_alloc(size_t size);
+
+/**
+ * Free the given xen_vbd_metrics_record_set, and all referenced
+ * values. The given set must have been allocated by this library.
+ */
+extern void
+xen_vbd_metrics_record_set_free(xen_vbd_metrics_record_set *set);
+
+
+
+typedef struct xen_vbd_metrics_record_opt_set
+{
+ size_t size;
+ xen_vbd_metrics_record_opt *contents[];
+} xen_vbd_metrics_record_opt_set;
+
+/**
+ * Allocate a xen_vbd_metrics_record_opt_set of the given size.
+ */
+extern xen_vbd_metrics_record_opt_set *
+xen_vbd_metrics_record_opt_set_alloc(size_t size);
+
+/**
+ * Free the given xen_vbd_metrics_record_opt_set, and all referenced
+ * values. The given set must have been allocated by this library.
+ */
+extern void
+xen_vbd_metrics_record_opt_set_free(xen_vbd_metrics_record_opt_set *set);
+
+
+/**
+ * Get a record containing the current state of the given VBD_metrics.
+ */
+extern bool
+xen_vbd_metrics_get_record(xen_session *session, xen_vbd_metrics_record
**result, xen_vbd_metrics vbd_metrics);
+
+
+/**
+ * Get a reference to the VBD_metrics instance with the specified UUID.
+ */
+extern bool
+xen_vbd_metrics_get_by_uuid(xen_session *session, xen_vbd_metrics *result,
char *uuid);
+
+
+/**
+ * Get the uuid field of the given VBD_metrics.
+ */
+extern bool
+xen_vbd_metrics_get_uuid(xen_session *session, char **result, xen_vbd_metrics
vbd_metrics);
+
+
+/**
+ * Get the io/read_kbs field of the given VBD_metrics.
+ */
+extern bool
+xen_vbd_metrics_get_io_read_kbs(xen_session *session, double *result,
xen_vbd_metrics vbd_metrics);
+
+
+/**
+ * Get the io/write_kbs field of the given VBD_metrics.
+ */
+extern bool
+xen_vbd_metrics_get_io_write_kbs(xen_session *session, double *result,
xen_vbd_metrics vbd_metrics);
+
+
+#endif
diff -r 988b90c6b4f3 -r 7819d9332fba tools/libxen/include/xen_vbd_metrics_decl.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxen/include/xen_vbd_metrics_decl.h Tue Feb 20 21:28:19
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_VBD_METRICS_DECL_H
+#define XEN_VBD_METRICS_DECL_H
+
+typedef void *xen_vbd_metrics;
+
+struct xen_vbd_metrics_set;
+struct xen_vbd_metrics_record;
+struct xen_vbd_metrics_record_set;
+struct xen_vbd_metrics_record_opt;
+struct xen_vbd_metrics_record_opt_set;
+
+#endif
diff -r 988b90c6b4f3 -r 7819d9332fba tools/libxen/include/xen_vbd_type.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxen/include/xen_vbd_type.h Tue Feb 20 21:28:19 2007 +0000
@@ -0,0 +1,77 @@
+/*
+ * 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_VBD_TYPE_H
+#define XEN_VBD_TYPE_H
+
+
+#include "xen_common.h"
+
+
+enum xen_vbd_type
+{
+ /**
+ * VBD will appear to guest as CD
+ */
+ XEN_VBD_TYPE_CD,
+
+ /**
+ * VBD will appear to guest as disk
+ */
+ XEN_VBD_TYPE_DISK
+};
+
+
+typedef struct xen_vbd_type_set
+{
+ size_t size;
+ enum xen_vbd_type contents[];
+} xen_vbd_type_set;
+
+/**
+ * Allocate a xen_vbd_type_set of the given size.
+ */
+extern xen_vbd_type_set *
+xen_vbd_type_set_alloc(size_t size);
+
+/**
+ * Free the given xen_vbd_type_set. The given set must have been
+ * allocated by this library.
+ */
+extern void
+xen_vbd_type_set_free(xen_vbd_type_set *set);
+
+
+/**
+ * Return the name corresponding to the given code. This string must
+ * not be modified or freed.
+ */
+extern const char *
+xen_vbd_type_to_string(enum xen_vbd_type val);
+
+
+/**
+ * Return the correct code for the given string, or set the session
+ * object to failure and return an undefined value if the given string does
+ * not match a known code.
+ */
+extern enum xen_vbd_type
+xen_vbd_type_from_string(xen_session *session, const char *str);
+
+
+#endif
diff -r 988b90c6b4f3 -r 7819d9332fba
tools/libxen/include/xen_vbd_type_internal.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxen/include/xen_vbd_type_internal.h Tue Feb 20 21:28:19
2007 +0000
@@ -0,0 +1,37 @@
+/*
+ * 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
+ */
+
+
+/*
+ * Declarations of the abstract types used during demarshalling of enum
+ * xen_vbd_type. Internal to this library -- do not use from outside.
+ */
+
+
+#ifndef XEN_VBD_TYPE_INTERNAL_H
+#define XEN_VBD_TYPE_INTERNAL_H
+
+
+#include "xen_internal.h"
+
+
+extern const abstract_type xen_vbd_type_abstract_type_;
+extern const abstract_type xen_vbd_type_set_abstract_type_;
+
+
+#endif
diff -r 988b90c6b4f3 -r 7819d9332fba tools/libxen/src/xen_vbd.c
--- a/tools/libxen/src/xen_vbd.c Tue Feb 20 19:38:24 2007 +0000
+++ b/tools/libxen/src/xen_vbd.c Tue Feb 20 21:28:19 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
@@ -23,7 +23,9 @@
#include "xen_common.h"
#include "xen_internal.h"
#include "xen_vbd.h"
+#include "xen_vbd_metrics.h"
#include "xen_vbd_mode_internal.h"
+#include "xen_vbd_type_internal.h"
#include "xen_vdi.h"
#include "xen_vm.h"
@@ -60,12 +62,12 @@ static const struct_member xen_vbd_recor
{ .key = "mode",
.type = &xen_vbd_mode_abstract_type_,
.offset = offsetof(xen_vbd_record, mode) },
- { .key = "io_read_kbs",
- .type = &abstract_type_float,
- .offset = offsetof(xen_vbd_record, io_read_kbs) },
- { .key = "io_write_kbs",
- .type = &abstract_type_float,
- .offset = offsetof(xen_vbd_record, io_write_kbs) }
+ { .key = "type",
+ .type = &xen_vbd_type_abstract_type_,
+ .offset = offsetof(xen_vbd_record, type) },
+ { .key = "metrics",
+ .type = &abstract_type_ref,
+ .offset = offsetof(xen_vbd_record, metrics) }
};
const abstract_type xen_vbd_record_abstract_type_ =
@@ -90,6 +92,7 @@ xen_vbd_record_free(xen_vbd_record *reco
xen_vm_record_opt_free(record->vm);
xen_vdi_record_opt_free(record->vdi);
free(record->device);
+ xen_vbd_metrics_record_opt_free(record->metrics);
free(record);
}
@@ -242,41 +245,39 @@ xen_vbd_get_mode(xen_session *session, e
};
abstract_type result_type = xen_vbd_mode_abstract_type_;
- char *result_str = NULL;
XEN_CALL_("VBD.get_mode");
- *result = xen_vbd_mode_from_string(session, result_str);
- return session->ok;
-}
-
-
-bool
-xen_vbd_get_io_read_kbs(xen_session *session, double *result, xen_vbd vbd)
-{
- abstract_value param_values[] =
- {
- { .type = &abstract_type_string,
- .u.string_val = vbd }
- };
-
- abstract_type result_type = abstract_type_float;
-
- XEN_CALL_("VBD.get_io_read_kbs");
- return session->ok;
-}
-
-
-bool
-xen_vbd_get_io_write_kbs(xen_session *session, double *result, xen_vbd vbd)
-{
- abstract_value param_values[] =
- {
- { .type = &abstract_type_string,
- .u.string_val = vbd }
- };
-
- abstract_type result_type = abstract_type_float;
-
- XEN_CALL_("VBD.get_io_write_kbs");
+ return session->ok;
+}
+
+
+bool
+xen_vbd_get_type(xen_session *session, enum xen_vbd_type *result, xen_vbd vbd)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vbd }
+ };
+
+ abstract_type result_type = xen_vbd_type_abstract_type_;
+ XEN_CALL_("VBD.get_type");
+ return session->ok;
+}
+
+
+bool
+xen_vbd_get_metrics(xen_session *session, xen_vbd_metrics *result, xen_vbd vbd)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vbd }
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("VBD.get_metrics");
return session->ok;
}
@@ -330,6 +331,22 @@ xen_vbd_set_mode(xen_session *session, x
bool
+xen_vbd_set_type(xen_session *session, xen_vbd vbd, enum xen_vbd_type type)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vbd },
+ { .type = &xen_vbd_type_abstract_type_,
+ .u.string_val = xen_vbd_type_to_string(type) }
+ };
+
+ xen_call_(session, "VBD.set_type", param_values, 2, NULL, NULL);
+ return session->ok;
+}
+
+
+bool
xen_vbd_media_change(xen_session *session, xen_vbd vbd, xen_vdi vdi)
{
abstract_value param_values[] =
diff -r 988b90c6b4f3 -r 7819d9332fba tools/libxen/src/xen_vbd_metrics.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxen/src/xen_vbd_metrics.c Tue Feb 20 21:28:19 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_vbd_metrics.h"
+
+
+XEN_FREE(xen_vbd_metrics)
+XEN_SET_ALLOC_FREE(xen_vbd_metrics)
+XEN_ALLOC(xen_vbd_metrics_record)
+XEN_SET_ALLOC_FREE(xen_vbd_metrics_record)
+XEN_ALLOC(xen_vbd_metrics_record_opt)
+XEN_RECORD_OPT_FREE(xen_vbd_metrics)
+XEN_SET_ALLOC_FREE(xen_vbd_metrics_record_opt)
+
+
+static const struct_member xen_vbd_metrics_record_struct_members[] =
+ {
+ { .key = "uuid",
+ .type = &abstract_type_string,
+ .offset = offsetof(xen_vbd_metrics_record, uuid) },
+ { .key = "io_read_kbs",
+ .type = &abstract_type_float,
+ .offset = offsetof(xen_vbd_metrics_record, io_read_kbs) },
+ { .key = "io_write_kbs",
+ .type = &abstract_type_float,
+ .offset = offsetof(xen_vbd_metrics_record, io_write_kbs) }
+ };
+
+const abstract_type xen_vbd_metrics_record_abstract_type_ =
+ {
+ .typename = STRUCT,
+ .struct_size = sizeof(xen_vbd_metrics_record),
+ .member_count =
+ sizeof(xen_vbd_metrics_record_struct_members) /
sizeof(struct_member),
+ .members = xen_vbd_metrics_record_struct_members
+ };
+
+
+void
+xen_vbd_metrics_record_free(xen_vbd_metrics_record *record)
+{
+ if (record == NULL)
+ {
+ return;
+ }
+ free(record->handle);
+ free(record->uuid);
+ free(record);
+}
+
+
+bool
+xen_vbd_metrics_get_record(xen_session *session, xen_vbd_metrics_record
**result, xen_vbd_metrics vbd_metrics)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vbd_metrics }
+ };
+
+ abstract_type result_type = xen_vbd_metrics_record_abstract_type_;
+
+ *result = NULL;
+ XEN_CALL_("VBD_metrics.get_record");
+
+ if (session->ok)
+ {
+ (*result)->handle = xen_strdup_((*result)->uuid);
+ }
+
+ return session->ok;
+}
+
+
+bool
+xen_vbd_metrics_get_by_uuid(xen_session *session, xen_vbd_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_("VBD_metrics.get_by_uuid");
+ return session->ok;
+}
+
+
+bool
+xen_vbd_metrics_get_io_read_kbs(xen_session *session, double *result,
xen_vbd_metrics vbd_metrics)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vbd_metrics }
+ };
+
+ abstract_type result_type = abstract_type_float;
+
+ XEN_CALL_("VBD_metrics.get_io_read_kbs");
+ return session->ok;
+}
+
+
+bool
+xen_vbd_metrics_get_io_write_kbs(xen_session *session, double *result,
xen_vbd_metrics vbd_metrics)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vbd_metrics }
+ };
+
+ abstract_type result_type = abstract_type_float;
+
+ XEN_CALL_("VBD_metrics.get_io_write_kbs");
+ return session->ok;
+}
+
+
+bool
+xen_vbd_metrics_get_uuid(xen_session *session, char **result, xen_vbd_metrics
vbd_metrics)
+{
+ *result = session->ok ? xen_strdup_((char *)vbd_metrics) : NULL;
+ return session->ok;
+}
diff -r 988b90c6b4f3 -r 7819d9332fba tools/libxen/src/xen_vbd_type.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxen/src/xen_vbd_type.c Tue Feb 20 21:28:19 2007 +0000
@@ -0,0 +1,81 @@
+/*
+ * 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 <string.h>
+
+#include "xen_internal.h"
+#include "xen_vbd_type.h"
+#include "xen_vbd_type_internal.h"
+
+
+/*
+ * Maintain this in the same order as the enum declaration!
+ */
+static const char *lookup_table[] =
+{
+ "CD",
+ "Disk"
+};
+
+
+extern xen_vbd_type_set *
+xen_vbd_type_set_alloc(size_t size)
+{
+ return calloc(1, sizeof(xen_vbd_type_set) +
+ size * sizeof(enum xen_vbd_type));
+}
+
+
+extern void
+xen_vbd_type_set_free(xen_vbd_type_set *set)
+{
+ free(set);
+}
+
+
+const char *
+xen_vbd_type_to_string(enum xen_vbd_type val)
+{
+ return lookup_table[val];
+}
+
+
+extern enum xen_vbd_type
+xen_vbd_type_from_string(xen_session *session, const char *str)
+{
+ return ENUM_LOOKUP(session, str, lookup_table);
+}
+
+
+const abstract_type xen_vbd_type_abstract_type_ =
+ {
+ .typename = ENUM,
+ .enum_marshaller =
+ (const char *(*)(int))&xen_vbd_type_to_string,
+ .enum_demarshaller =
+ (int (*)(xen_session *, const char *))&xen_vbd_type_from_string
+ };
+
+
+const abstract_type xen_vbd_type_set_abstract_type_ =
+ {
+ .typename = SET,
+ .child = &xen_vbd_type_abstract_type_
+ };
+
+
diff -r 988b90c6b4f3 -r 7819d9332fba tools/python/xen/xend/XendAPI.py
--- a/tools/python/xen/xend/XendAPI.py Tue Feb 20 19:38:24 2007 +0000
+++ b/tools/python/xen/xend/XendAPI.py Tue Feb 20 21:28:19 2007 +0000
@@ -209,6 +209,16 @@ def valid_vbd(func):
_check_ref(lambda r: XendDomain.instance().is_valid_dev('vbd', r),
'VBD', func, *args, **kwargs)
+def valid_vbd_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('vbd', r),
+ 'VBD_metrics', func, *args, **kwargs)
+
def valid_vif(func):
"""Decorator to verify if vif_ref is valid before calling method.
@@ -378,6 +388,7 @@ class XendAPI(object):
'network' : valid_network,
'VM' : valid_vm,
'VBD' : valid_vbd,
+ 'VBD_metrics' : valid_vbd_metrics,
'VIF' : valid_vif,
'VDI' : valid_vdi,
'VTPM' : valid_vtpm,
@@ -1450,8 +1461,7 @@ class XendAPI(object):
# Xen API: Class VBD
# ----------------------------------------------------------------
- VBD_attr_ro = ['io_read_kbs',
- 'io_write_kbs']
+ VBD_attr_ro = ['metrics']
VBD_attr_rw = ['VM',
'VDI',
'device',
@@ -1481,7 +1491,9 @@ class XendAPI(object):
for k in cfg.keys():
if k in valid_vbd_keys:
return_cfg[k] = cfg[k]
-
+
+ return_cfg['metrics'] = vbd_ref
+
return xen_api_success(return_cfg)
def VBD_media_change(self, session, vbd_ref, vdi_ref):
@@ -1521,12 +1533,16 @@ class XendAPI(object):
XendTask.log_progress(0, 100, vm.destroy_vbd, vbd_ref)
return xen_api_success_void()
- # attributes (rw)
def _VBD_get(self, vbd_ref, prop):
return xen_api_success(
XendDomain.instance().get_dev_property_by_uuid(
'vbd', vbd_ref, prop))
+ # attributes (ro)
+ def VBD_get_metrics(self, _, vbd_ref):
+ return xen_api_success(vbd_ref)
+
+ # attributes (rw)
def VBD_get_VM(self, session, vbd_ref):
return self._VBD_get(vbd_ref, 'VM')
@@ -1544,12 +1560,6 @@ class XendAPI(object):
def VBD_get_type(self, session, vbd_ref):
return self._VBD_get(vbd_ref, 'type')
-
- def VBD_get_io_read_kbs(self, session, vbd_ref):
- return self._VBD_get(vbd_ref, 'io_read_kbs')
-
- def VBD_get_io_write_kbs(self, session, vbd_ref):
- return self._VBD_get(vbd_ref, 'io_write_kbs')
def VBD_set_bootable(self, session, vbd_ref, bootable):
bootable = bool(bootable)
@@ -1564,6 +1574,30 @@ class XendAPI(object):
vbds = [d.get_vbds() for d in XendDomain.instance().list('all')]
vbds = reduce(lambda x, y: x + y, vbds)
return xen_api_success(vbds)
+
+
+ # Xen API: Class VBD_metrics
+ # ----------------------------------------------------------------
+
+ VBD_metrics_attr_ro = ['io_read_kbs',
+ 'io_write_kbs']
+ VBD_metrics_attr_rw = []
+ VBD_methods = []
+
+ def VBD_metrics_get_record(self, _, ref):
+ vm = XendDomain.instance().get_vm_with_dev_uuid('vbd', ref)
+ if not vm:
+ return xen_api_error(['HANDLE_INVALID', 'VBD_metrics', ref])
+ return xen_api_success(
+ { '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):
+ return self._VBD_get(ref, 'io_read_kbs')
+
+ def VBD_metrics_get_io_write_kbs(self, session, vbd_ref):
+ return self._VBD_get(ref, 'io_write_kbs')
+
# Xen API: Class VIF
# ----------------------------------------------------------------
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|