From: Ewan Mellor Date: Tue, 30 Jan 2007 12:43:40 +0000 (+0000) Subject: Added modelling and C bindings for crashdumps, and suspend VDIs. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~15368^2~27 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=93775fde38d00446133a605ffab72862e00cadf1;p=xen.git Added modelling and C bindings for crashdumps, and suspend VDIs. Signed-off-by: Ewan Mellor --- diff --git a/docs/xen-api/xenapi-datamodel.tex b/docs/xen-api/xenapi-datamodel.tex index 6e123106a4..d4c71956ac 100644 --- a/docs/xen-api/xenapi-datamodel.tex +++ b/docs/xen-api/xenapi-datamodel.tex @@ -35,6 +35,7 @@ Name & Description \\ {\tt VDI} & A virtual disk image \\ {\tt VBD} & 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 \\ {\tt console} & A console \\ {\tt user} & A user of the system \\ @@ -51,7 +52,9 @@ Fields that are bound together are shown in the following table: host.PBDs & PBD.host & many-to-one\\ SR.PBDs & PBD.SR & many-to-one\\ VDI.VBDs & VBD.VDI & many-to-one\\ +VDI.crash\_dumps & crashdump.VDI & many-to-one\\ VBD.VM & VM.VBDs & one-to-many\\ +crashdump.VM & VM.crash\_dumps & one-to-many\\ VIF.VM & VM.VIFs & one-to-many\\ VIF.network & network.VIFs & one-to-many\\ PIF.metrics & PIF\_metrics.PIF & one-to-one\\ @@ -121,6 +124,8 @@ The following enumeration types are used: \hspace{0.5cm}{\tt system} & a disk that may be replaced on upgrade \\ \hspace{0.5cm}{\tt user} & a disk that is always preserved on upgrade \\ \hspace{0.5cm}{\tt ephemeral} & a disk that may be reformatted on upgrade \\ +\hspace{0.5cm}{\tt suspend} & a disk that stores a suspend image \\ +\hspace{0.5cm}{\tt crashdump} & a disk that stores VM crashdump information \\ \hline \end{longtable} @@ -1022,6 +1027,7 @@ $\mathit{RW}$ & {\tt name/description} & string & a notes field containg human- $\mathit{RW}$ & {\tt user\_version} & int & a user version number for this machine \\ $\mathit{RW}$ & {\tt is\_a\_template} & bool & true if this is a template. Template VMs can never be started, they are used only for cloning other VMs \\ $\mathit{RW}$ & {\tt auto\_power\_on} & bool & true if this VM should be started automatically after host boot \\ +$\mathit{RO}_\mathit{run}$ & {\tt suspend\_VDI} & VDI ref & The VDI that a suspend image is stored on. (Only has meaning if VM is currently suspended) \\ $\mathit{RO}_\mathit{run}$ & {\tt resident\_on} & host ref & the host the VM is currently resident on \\ $\mathit{RO}_\mathit{ins}$ & {\tt memory/static\_max} & int & Statically-set (i.e. absolute) maximum (bytes) \\ $\mathit{RW}$ & {\tt memory/dynamic\_max} & int & Dynamic maximum (bytes) \\ @@ -1038,6 +1044,7 @@ $\mathit{RW}$ & {\tt actions/after\_crash} & on\_crash\_behaviour & action to t $\mathit{RO}_\mathit{run}$ & {\tt consoles} & (console ref) Set & virtual console devices \\ $\mathit{RO}_\mathit{run}$ & {\tt VIFs} & (VIF ref) Set & virtual network interfaces \\ $\mathit{RO}_\mathit{run}$ & {\tt VBDs} & (VBD ref) Set & virtual block devices \\ +$\mathit{RO}_\mathit{run}$ & {\tt crash\_dumps} & (crashdump ref) Set & crash dumps associated with this VM \\ $\mathit{RO}_\mathit{run}$ & {\tt VTPMs} & (VTPM ref) Set & virtual TPMs \\ $\mathit{RW}$ & {\tt PV/bootloader} & string & name of or path to bootloader \\ $\mathit{RW}$ & {\tt PV/kernel} & string & path to the kernel \\ @@ -1832,6 +1839,38 @@ void +\vspace{0.3cm} +\vspace{0.3cm} +\vspace{0.3cm} +\subsubsection{RPC name:~get\_suspend\_VDI} + +{\bf Overview:} +Get the suspend\_VDI field of the given VM. + + \noindent {\bf Signature:} +\begin{verbatim} (VDI ref) get_suspend_VDI (session_id s, VM 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 VM 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} @@ -2615,6 +2654,38 @@ Get the VBDs field of the given VM. } +value of the field +\vspace{0.3cm} +\vspace{0.3cm} +\vspace{0.3cm} +\subsubsection{RPC name:~get\_crash\_dumps} + +{\bf Overview:} +Get the crash\_dumps field of the given VM. + + \noindent {\bf Signature:} +\begin{verbatim} ((crashdump ref) Set) get_crash_dumps (session_id s, VM 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 VM ref } & self & reference to the object \\ \hline + +\end{tabular} + +\vspace{0.3cm} + + \noindent {\bf Return Type:} +{\tt +(crashdump ref) Set +} + + value of the field \vspace{0.3cm} \vspace{0.3cm} @@ -3760,6 +3831,8 @@ $\mathit{RW}$ & {\tt other\_config} & (string $\rightarrow$ string) Map & addit $\mathit{RO}_\mathit{run}$ & {\tt resident\_VMs} & (VM ref) Set & list of VMs currently resident on host \\ $\mathit{RW}$ & {\tt logging} & (string $\rightarrow$ string) Map & logging configuration \\ $\mathit{RO}_\mathit{run}$ & {\tt PIFs} & (PIF ref) Set & physical network interfaces \\ +$\mathit{RW}$ & {\tt suspend\_image\_sr} & SR ref & The SR in which VDIs for suspend images are created \\ +$\mathit{RW}$ & {\tt crash\_dump\_sr} & SR ref & The SR in which VDIs for crash dumps are created \\ $\mathit{RO}_\mathit{run}$ & {\tt PBDs} & (PBD ref) Set & physical blockdevices \\ $\mathit{RO}_\mathit{run}$ & {\tt host\_CPUs} & (host\_cpu ref) Set & The physical CPUs on this host \\ \hline @@ -4448,6 +4521,138 @@ Get the PIFs field of the given host. value of the field +\vspace{0.3cm} +\vspace{0.3cm} +\vspace{0.3cm} +\subsubsection{RPC name:~get\_suspend\_image\_sr} + +{\bf Overview:} +Get the suspend\_image\_sr field of the given host. + + \noindent {\bf Signature:} +\begin{verbatim} (SR ref) get_suspend_image_sr (session_id s, host 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 host ref } & self & reference to the object \\ \hline + +\end{tabular} + +\vspace{0.3cm} + + \noindent {\bf Return Type:} +{\tt +SR ref +} + + +value of the field +\vspace{0.3cm} +\vspace{0.3cm} +\vspace{0.3cm} +\subsubsection{RPC name:~set\_suspend\_image\_sr} + +{\bf Overview:} +Set the suspend\_image\_sr field of the given host. + + \noindent {\bf Signature:} +\begin{verbatim} void set_suspend_image_sr (session_id s, host ref self, SR ref value)\end{verbatim} + + +\noindent{\bf Arguments:} + + +\vspace{0.3cm} +\begin{tabular}{|c|c|p{7cm}|} + \hline +{\bf type} & {\bf name} & {\bf description} \\ \hline +{\tt host ref } & self & reference to the object \\ \hline + +{\tt SR ref } & 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\_crash\_dump\_sr} + +{\bf Overview:} +Get the crash\_dump\_sr field of the given host. + + \noindent {\bf Signature:} +\begin{verbatim} (SR ref) get_crash_dump_sr (session_id s, host 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 host ref } & self & reference to the object \\ \hline + +\end{tabular} + +\vspace{0.3cm} + + \noindent {\bf Return Type:} +{\tt +SR ref +} + + +value of the field +\vspace{0.3cm} +\vspace{0.3cm} +\vspace{0.3cm} +\subsubsection{RPC name:~set\_crash\_dump\_sr} + +{\bf Overview:} +Set the crash\_dump\_sr field of the given host. + + \noindent {\bf Signature:} +\begin{verbatim} void set_crash_dump_sr (session_id s, host ref self, SR ref value)\end{verbatim} + + +\noindent{\bf Arguments:} + + +\vspace{0.3cm} +\begin{tabular}{|c|c|p{7cm}|} + \hline +{\bf type} & {\bf name} & {\bf description} \\ \hline +{\tt host ref } & self & reference to the object \\ \hline + +{\tt SR ref } & 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} @@ -7541,6 +7746,7 @@ $\mathit{RW}$ & {\tt name/label} & string & a human-readable name \\ $\mathit{RW}$ & {\tt name/description} & string & a notes field containg human-readable description \\ $\mathit{RW}$ & {\tt SR} & SR ref & storage repository in which the VDI resides \\ $\mathit{RO}_\mathit{run}$ & {\tt VBDs} & (VBD ref) Set & list of vbds that refer to this disk \\ +$\mathit{RO}_\mathit{run}$ & {\tt crash\_dumps} & (crashdump ref) Set & list of crash dumps that refer to this disk \\ $\mathit{RW}$ & {\tt virtual\_size} & int & size of disk as presented to the guest (in multiples of sector\_size field) \\ $\mathit{RO}_\mathit{run}$ & {\tt physical\_utilisation} & int & amount of physical space that the disk image is currently taking up on the storage repository (in bytes) \\ $\mathit{RO}_\mathit{ins}$ & {\tt sector\_size} & int & sector size of VDI (in bytes) \\ @@ -7875,6 +8081,38 @@ Get the VBDs field of the given VDI. } +value of the field +\vspace{0.3cm} +\vspace{0.3cm} +\vspace{0.3cm} +\subsubsection{RPC name:~get\_crash\_dumps} + +{\bf Overview:} +Get the crash\_dumps field of the given VDI. + + \noindent {\bf Signature:} +\begin{verbatim} ((crashdump ref) Set) get_crash_dumps (session_id s, VDI 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 VDI ref } & self & reference to the object \\ \hline + +\end{tabular} + +\vspace{0.3cm} + + \noindent {\bf Return Type:} +{\tt +(crashdump ref) Set +} + + value of the field \vspace{0.3cm} \vspace{0.3cm} @@ -9250,6 +9488,270 @@ PBD record } +all fields from the object +\vspace{0.3cm} +\vspace{0.3cm} +\vspace{0.3cm} + +\vspace{1cm} +\newpage +\section{Class: crashdump} +\subsection{Fields for class: crashdump} +\begin{longtable}{|lllp{0.38\textwidth}|} +\hline +\multicolumn{1}{|l}{Name} & \multicolumn{3}{l|}{\bf crashdump} \\ +\multicolumn{1}{|l}{Description} & \multicolumn{3}{l|}{\parbox{11cm}{\em A +VM crashdump.}} \\ +\hline +Quals & Field & Type & Description \\ +\hline +$\mathit{RO}_\mathit{run}$ & {\tt uuid} & string & unique identifier/object reference \\ +$\mathit{RO}_\mathit{ins}$ & {\tt VM} & VM ref & the virtual machine \\ +$\mathit{RO}_\mathit{ins}$ & {\tt VDI} & VDI ref & the virtual disk \\ +\hline +\end{longtable} +\subsection{Additional RPCs associated with class: crashdump} +\subsubsection{RPC name:~get\_all} + +{\bf Overview:} +Return a list of all the crashdumps known to the system. + + \noindent {\bf Signature:} +\begin{verbatim} ((crashdump ref) Set) get_all (session_id s)\end{verbatim} + + +\vspace{0.3cm} + + \noindent {\bf Return Type:} +{\tt +(crashdump ref) Set +} + + +references to all objects +\vspace{0.3cm} +\vspace{0.3cm} +\vspace{0.3cm} +\subsubsection{RPC name:~get\_uuid} + +{\bf Overview:} +Get the uuid field of the given crashdump. + + \noindent {\bf Signature:} +\begin{verbatim} string get_uuid (session_id s, crashdump 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 crashdump 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 crashdump. + + \noindent {\bf Signature:} +\begin{verbatim} (VM ref) get_VM (session_id s, crashdump 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 crashdump 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 crashdump. + + \noindent {\bf Signature:} +\begin{verbatim} (VDI ref) get_VDI (session_id s, crashdump 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 crashdump 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:~create} + +{\bf Overview:} +Create a new crashdump instance, and return its handle. + + \noindent {\bf Signature:} +\begin{verbatim} (crashdump ref) create (session_id s, crashdump 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 crashdump record } & args & All constructor arguments \\ \hline + +\end{tabular} + +\vspace{0.3cm} + + \noindent {\bf Return Type:} +{\tt +crashdump 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 crashdump instance. + + \noindent {\bf Signature:} +\begin{verbatim} void destroy (session_id s, crashdump 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 crashdump 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 crashdump instance with the specified UUID. + + \noindent {\bf Signature:} +\begin{verbatim} (crashdump 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 +crashdump 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 crashdump. + + \noindent {\bf Signature:} +\begin{verbatim} (crashdump record) get_record (session_id s, crashdump 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 crashdump ref } & self & reference to the object \\ \hline + +\end{tabular} + +\vspace{0.3cm} + + \noindent {\bf Return Type:} +{\tt +crashdump record +} + + all fields from the object \vspace{0.3cm} \vspace{0.3cm} @@ -9262,7 +9764,8 @@ all fields from the object \begin{longtable}{|lllp{0.38\textwidth}|} \hline \multicolumn{1}{|l}{Name} & \multicolumn{3}{l|}{\bf VTPM} \\ -\multicolumn{1}{|l}{Description} & \multicolumn{3}{l|}{\parbox{11cm}{\em A virtual TPM device}} \\ +\multicolumn{1}{|l}{Description} & \multicolumn{3}{l|}{\parbox{11cm}{\em A +virtual TPM device.}} \\ \hline Quals & Field & Type & Description \\ \hline diff --git a/tools/libxen/include/xen_crashdump.h b/tools/libxen/include/xen_crashdump.h new file mode 100644 index 0000000000..fff0a1a144 --- /dev/null +++ b/tools/libxen/include/xen_crashdump.h @@ -0,0 +1,206 @@ +/* + * Copyright (c) 2006, 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_CRASHDUMP_H +#define XEN_CRASHDUMP_H + +#include "xen_common.h" +#include "xen_crashdump_decl.h" +#include "xen_vdi_decl.h" +#include "xen_vm_decl.h" + + +/* + * The crashdump class. + * + * A VM crashdump. + */ + + +/** + * Free the given xen_crashdump. The given handle must have been + * allocated by this library. + */ +extern void +xen_crashdump_free(xen_crashdump crashdump); + + +typedef struct xen_crashdump_set +{ + size_t size; + xen_crashdump *contents[]; +} xen_crashdump_set; + +/** + * Allocate a xen_crashdump_set of the given size. + */ +extern xen_crashdump_set * +xen_crashdump_set_alloc(size_t size); + +/** + * Free the given xen_crashdump_set. The given set must have been + * allocated by this library. + */ +extern void +xen_crashdump_set_free(xen_crashdump_set *set); + + +typedef struct xen_crashdump_record +{ + xen_crashdump handle; + char *uuid; + struct xen_vm_record_opt *vm; + struct xen_vdi_record_opt *vdi; +} xen_crashdump_record; + +/** + * Allocate a xen_crashdump_record. + */ +extern xen_crashdump_record * +xen_crashdump_record_alloc(void); + +/** + * Free the given xen_crashdump_record, and all referenced values. The + * given record must have been allocated by this library. + */ +extern void +xen_crashdump_record_free(xen_crashdump_record *record); + + +typedef struct xen_crashdump_record_opt +{ + bool is_record; + union + { + xen_crashdump handle; + xen_crashdump_record *record; + } u; +} xen_crashdump_record_opt; + +/** + * Allocate a xen_crashdump_record_opt. + */ +extern xen_crashdump_record_opt * +xen_crashdump_record_opt_alloc(void); + +/** + * Free the given xen_crashdump_record_opt, and all referenced values. + * The given record_opt must have been allocated by this library. + */ +extern void +xen_crashdump_record_opt_free(xen_crashdump_record_opt *record_opt); + + +typedef struct xen_crashdump_record_set +{ + size_t size; + xen_crashdump_record *contents[]; +} xen_crashdump_record_set; + +/** + * Allocate a xen_crashdump_record_set of the given size. + */ +extern xen_crashdump_record_set * +xen_crashdump_record_set_alloc(size_t size); + +/** + * Free the given xen_crashdump_record_set, and all referenced values. + * The given set must have been allocated by this library. + */ +extern void +xen_crashdump_record_set_free(xen_crashdump_record_set *set); + + + +typedef struct xen_crashdump_record_opt_set +{ + size_t size; + xen_crashdump_record_opt *contents[]; +} xen_crashdump_record_opt_set; + +/** + * Allocate a xen_crashdump_record_opt_set of the given size. + */ +extern xen_crashdump_record_opt_set * +xen_crashdump_record_opt_set_alloc(size_t size); + +/** + * Free the given xen_crashdump_record_opt_set, and all referenced + * values. The given set must have been allocated by this library. + */ +extern void +xen_crashdump_record_opt_set_free(xen_crashdump_record_opt_set *set); + + +/** + * Get a record containing the current state of the given crashdump. + */ +extern bool +xen_crashdump_get_record(xen_session *session, xen_crashdump_record **result, xen_crashdump crashdump); + + +/** + * Get a reference to the crashdump instance with the specified UUID. + */ +extern bool +xen_crashdump_get_by_uuid(xen_session *session, xen_crashdump *result, char *uuid); + + +/** + * Create a new crashdump instance, and return its handle. + */ +extern bool +xen_crashdump_create(xen_session *session, xen_crashdump *result, xen_crashdump_record *record); + + +/** + * Destroy the specified crashdump instance. + */ +extern bool +xen_crashdump_destroy(xen_session *session, xen_crashdump crashdump); + + +/** + * Get the uuid field of the given crashdump. + */ +extern bool +xen_crashdump_get_uuid(xen_session *session, char **result, xen_crashdump crashdump); + + +/** + * Get the VM field of the given crashdump. + */ +extern bool +xen_crashdump_get_vm(xen_session *session, xen_vm *result, xen_crashdump crashdump); + + +/** + * Get the VDI field of the given crashdump. + */ +extern bool +xen_crashdump_get_vdi(xen_session *session, xen_vdi *result, xen_crashdump crashdump); + + +/** + * Return a list of all the crashdumps known to the system. + */ +extern bool +xen_crashdump_get_all(xen_session *session, struct xen_crashdump_set **result); + + +#endif diff --git a/tools/libxen/include/xen_crashdump_decl.h b/tools/libxen/include/xen_crashdump_decl.h new file mode 100644 index 0000000000..3087715c4f --- /dev/null +++ b/tools/libxen/include/xen_crashdump_decl.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2006, 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_CRASHDUMP_DECL_H +#define XEN_CRASHDUMP_DECL_H + +typedef void *xen_crashdump; + +struct xen_crashdump_set; +struct xen_crashdump_record; +struct xen_crashdump_record_set; +struct xen_crashdump_record_opt; +struct xen_crashdump_record_opt_set; + +#endif diff --git a/tools/libxen/include/xen_host.h b/tools/libxen/include/xen_host.h index d94a74ecb4..1e04a6cdb1 100644 --- a/tools/libxen/include/xen_host.h +++ b/tools/libxen/include/xen_host.h @@ -24,6 +24,7 @@ #include "xen_host_decl.h" #include "xen_pbd_decl.h" #include "xen_pif_decl.h" +#include "xen_sr_decl.h" #include "xen_string_string_map.h" #include "xen_vm_decl.h" @@ -74,6 +75,8 @@ typedef struct xen_host_record struct xen_vm_record_opt_set *resident_vms; xen_string_string_map *logging; struct xen_pif_record_opt_set *pifs; + struct xen_sr_record_opt *suspend_image_sr; + struct xen_sr_record_opt *crash_dump_sr; struct xen_pbd_record_opt_set *pbds; struct xen_host_cpu_record_opt_set *host_cpus; } xen_host_record; @@ -248,6 +251,20 @@ extern bool xen_host_get_pifs(xen_session *session, struct xen_pif_set **result, xen_host host); +/** + * Get the suspend_image_sr field of the given host. + */ +extern bool +xen_host_get_suspend_image_sr(xen_session *session, xen_sr *result, xen_host host); + + +/** + * Get the crash_dump_sr field of the given host. + */ +extern bool +xen_host_get_crash_dump_sr(xen_session *session, xen_sr *result, xen_host host); + + /** * Get the PBDs field of the given host. */ @@ -322,6 +339,20 @@ extern bool xen_host_remove_from_logging(xen_session *session, xen_host host, char *key); +/** + * Set the suspend_image_sr field of the given host. + */ +extern bool +xen_host_set_suspend_image_sr(xen_session *session, xen_host host, xen_sr suspend_image_sr); + + +/** + * Set the crash_dump_sr field of the given host. + */ +extern bool +xen_host_set_crash_dump_sr(xen_session *session, xen_host host, xen_sr crash_dump_sr); + + /** * Puts the host into a state in which no new VMs can be started. * Currently active VMs on the host continue to execute. diff --git a/tools/libxen/include/xen_vdi.h b/tools/libxen/include/xen_vdi.h index 7478085464..d72eceb001 100644 --- a/tools/libxen/include/xen_vdi.h +++ b/tools/libxen/include/xen_vdi.h @@ -20,6 +20,7 @@ #define XEN_VDI_H #include "xen_common.h" +#include "xen_crashdump_decl.h" #include "xen_sr_decl.h" #include "xen_vbd_decl.h" #include "xen_vdi_decl.h" @@ -69,6 +70,7 @@ typedef struct xen_vdi_record char *name_description; struct xen_sr_record_opt *sr; struct xen_vbd_record_opt_set *vbds; + struct xen_crashdump_record_opt_set *crash_dumps; int64_t virtual_size; int64_t physical_utilisation; int64_t sector_size; @@ -226,6 +228,13 @@ extern bool xen_vdi_get_vbds(xen_session *session, struct xen_vbd_set **result, xen_vdi vdi); +/** + * Get the crash_dumps field of the given VDI. + */ +extern bool +xen_vdi_get_crash_dumps(xen_session *session, struct xen_crashdump_set **result, xen_vdi vdi); + + /** * Get the virtual_size field of the given VDI. */ diff --git a/tools/libxen/include/xen_vdi_type.h b/tools/libxen/include/xen_vdi_type.h index 33ba7c61bf..01168491ee 100644 --- a/tools/libxen/include/xen_vdi_type.h +++ b/tools/libxen/include/xen_vdi_type.h @@ -38,7 +38,17 @@ enum xen_vdi_type /** * a disk that may be reformatted on upgrade */ - XEN_VDI_TYPE_EPHEMERAL + XEN_VDI_TYPE_EPHEMERAL, + + /** + * a disk that stores a suspend image + */ + XEN_VDI_TYPE_SUSPEND, + + /** + * a disk that stores VM crashdump information + */ + XEN_VDI_TYPE_CRASHDUMP }; diff --git a/tools/libxen/include/xen_vm.h b/tools/libxen/include/xen_vm.h index 0ef8c4eb7e..8cbd786d69 100644 --- a/tools/libxen/include/xen_vm.h +++ b/tools/libxen/include/xen_vm.h @@ -21,12 +21,14 @@ #include "xen_common.h" #include "xen_console_decl.h" +#include "xen_crashdump_decl.h" #include "xen_host_decl.h" #include "xen_int_float_map.h" #include "xen_on_crash_behaviour.h" #include "xen_on_normal_exit.h" #include "xen_string_string_map.h" #include "xen_vbd_decl.h" +#include "xen_vdi_decl.h" #include "xen_vif_decl.h" #include "xen_vm_decl.h" #include "xen_vm_power_state.h" @@ -108,6 +110,7 @@ typedef struct xen_vm_record int64_t user_version; bool is_a_template; bool auto_power_on; + struct xen_vdi_record_opt *suspend_vdi; struct xen_host_record_opt *resident_on; int64_t memory_static_max; int64_t memory_dynamic_max; @@ -124,6 +127,7 @@ typedef struct xen_vm_record struct xen_console_record_opt_set *consoles; struct xen_vif_record_opt_set *vifs; struct xen_vbd_record_opt_set *vbds; + struct xen_crashdump_record_opt_set *crash_dumps; struct xen_vtpm_record_opt_set *vtpms; char *pv_bootloader; char *pv_kernel; @@ -306,6 +310,13 @@ extern bool xen_vm_get_auto_power_on(xen_session *session, bool *result, xen_vm vm); +/** + * Get the suspend_VDI field of the given VM. + */ +extern bool +xen_vm_get_suspend_vdi(xen_session *session, xen_vdi *result, xen_vm vm); + + /** * Get the resident_on field of the given VM. */ @@ -418,6 +429,13 @@ extern bool xen_vm_get_vbds(xen_session *session, struct xen_vbd_set **result, xen_vm vm); +/** + * Get the crash_dumps field of the given VM. + */ +extern bool +xen_vm_get_crash_dumps(xen_session *session, struct xen_crashdump_set **result, xen_vm vm); + + /** * Get the VTPMs field of the given VM. */ diff --git a/tools/libxen/src/xen_crashdump.c b/tools/libxen/src/xen_crashdump.c new file mode 100644 index 0000000000..53504ba249 --- /dev/null +++ b/tools/libxen/src/xen_crashdump.c @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2006, 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 +#include + +#include "xen_common.h" +#include "xen_crashdump.h" +#include "xen_internal.h" +#include "xen_vdi.h" +#include "xen_vm.h" + + +XEN_FREE(xen_crashdump) +XEN_SET_ALLOC_FREE(xen_crashdump) +XEN_ALLOC(xen_crashdump_record) +XEN_SET_ALLOC_FREE(xen_crashdump_record) +XEN_ALLOC(xen_crashdump_record_opt) +XEN_RECORD_OPT_FREE(xen_crashdump) +XEN_SET_ALLOC_FREE(xen_crashdump_record_opt) + + +static const struct_member xen_crashdump_record_struct_members[] = + { + { .key = "uuid", + .type = &abstract_type_string, + .offset = offsetof(xen_crashdump_record, uuid) }, + { .key = "VM", + .type = &abstract_type_ref, + .offset = offsetof(xen_crashdump_record, vm) }, + { .key = "VDI", + .type = &abstract_type_ref, + .offset = offsetof(xen_crashdump_record, vdi) } + }; + +const abstract_type xen_crashdump_record_abstract_type_ = + { + .typename = STRUCT, + .struct_size = sizeof(xen_crashdump_record), + .member_count = + sizeof(xen_crashdump_record_struct_members) / sizeof(struct_member), + .members = xen_crashdump_record_struct_members + }; + + +void +xen_crashdump_record_free(xen_crashdump_record *record) +{ + if (record == NULL) + { + return; + } + free(record->handle); + free(record->uuid); + xen_vm_record_opt_free(record->vm); + xen_vdi_record_opt_free(record->vdi); + free(record); +} + + +bool +xen_crashdump_get_record(xen_session *session, xen_crashdump_record **result, xen_crashdump crashdump) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = crashdump } + }; + + abstract_type result_type = xen_crashdump_record_abstract_type_; + + *result = NULL; + XEN_CALL_("crashdump.get_record"); + + if (session->ok) + { + (*result)->handle = xen_strdup_((*result)->uuid); + } + + return session->ok; +} + + +bool +xen_crashdump_get_by_uuid(xen_session *session, xen_crashdump *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_("crashdump.get_by_uuid"); + return session->ok; +} + + +bool +xen_crashdump_create(xen_session *session, xen_crashdump *result, xen_crashdump_record *record) +{ + abstract_value param_values[] = + { + { .type = &xen_crashdump_record_abstract_type_, + .u.struct_val = record } + }; + + abstract_type result_type = abstract_type_string; + + *result = NULL; + XEN_CALL_("crashdump.create"); + return session->ok; +} + + +bool +xen_crashdump_destroy(xen_session *session, xen_crashdump crashdump) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = crashdump } + }; + + xen_call_(session, "crashdump.destroy", param_values, 1, NULL, NULL); + return session->ok; +} + + +bool +xen_crashdump_get_vm(xen_session *session, xen_vm *result, xen_crashdump crashdump) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = crashdump } + }; + + abstract_type result_type = abstract_type_string; + + *result = NULL; + XEN_CALL_("crashdump.get_VM"); + return session->ok; +} + + +bool +xen_crashdump_get_vdi(xen_session *session, xen_vdi *result, xen_crashdump crashdump) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = crashdump } + }; + + abstract_type result_type = abstract_type_string; + + *result = NULL; + XEN_CALL_("crashdump.get_VDI"); + return session->ok; +} + + +bool +xen_crashdump_get_all(xen_session *session, struct xen_crashdump_set **result) +{ + + abstract_type result_type = abstract_type_string_set; + + *result = NULL; + xen_call_(session, "crashdump.get_all", NULL, 0, &result_type, result); + return session->ok; +} + + +bool +xen_crashdump_get_uuid(xen_session *session, char **result, xen_crashdump crashdump) +{ + *result = session->ok ? xen_strdup_((char *)crashdump) : NULL; + return session->ok; +} diff --git a/tools/libxen/src/xen_host.c b/tools/libxen/src/xen_host.c index f511579c20..8939664101 100644 --- a/tools/libxen/src/xen_host.c +++ b/tools/libxen/src/xen_host.c @@ -26,6 +26,7 @@ #include "xen_internal.h" #include "xen_pbd.h" #include "xen_pif.h" +#include "xen_sr.h" #include "xen_string_string_map.h" #include "xen_vm.h" @@ -65,6 +66,12 @@ static const struct_member xen_host_record_struct_members[] = { .key = "PIFs", .type = &abstract_type_ref_set, .offset = offsetof(xen_host_record, pifs) }, + { .key = "suspend_image_sr", + .type = &abstract_type_ref, + .offset = offsetof(xen_host_record, suspend_image_sr) }, + { .key = "crash_dump_sr", + .type = &abstract_type_ref, + .offset = offsetof(xen_host_record, crash_dump_sr) }, { .key = "PBDs", .type = &abstract_type_ref_set, .offset = offsetof(xen_host_record, pbds) }, @@ -99,6 +106,8 @@ xen_host_record_free(xen_host_record *record) xen_vm_record_opt_set_free(record->resident_vms); xen_string_string_map_free(record->logging); xen_pif_record_opt_set_free(record->pifs); + xen_sr_record_opt_free(record->suspend_image_sr); + xen_sr_record_opt_free(record->crash_dump_sr); xen_pbd_record_opt_set_free(record->pbds); xen_host_cpu_record_opt_set_free(record->host_cpus); free(record); @@ -312,6 +321,40 @@ xen_host_get_pifs(xen_session *session, struct xen_pif_set **result, xen_host ho } +bool +xen_host_get_suspend_image_sr(xen_session *session, xen_sr *result, xen_host host) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = host } + }; + + abstract_type result_type = abstract_type_string; + + *result = NULL; + XEN_CALL_("host.get_suspend_image_sr"); + return session->ok; +} + + +bool +xen_host_get_crash_dump_sr(xen_session *session, xen_sr *result, xen_host host) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = host } + }; + + abstract_type result_type = abstract_type_string; + + *result = NULL; + XEN_CALL_("host.get_crash_dump_sr"); + return session->ok; +} + + bool xen_host_get_pbds(xen_session *session, struct xen_pbd_set **result, xen_host host) { @@ -478,6 +521,38 @@ xen_host_remove_from_logging(xen_session *session, xen_host host, char *key) } +bool +xen_host_set_suspend_image_sr(xen_session *session, xen_host host, xen_sr suspend_image_sr) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = host }, + { .type = &abstract_type_string, + .u.string_val = suspend_image_sr } + }; + + xen_call_(session, "host.set_suspend_image_sr", param_values, 2, NULL, NULL); + return session->ok; +} + + +bool +xen_host_set_crash_dump_sr(xen_session *session, xen_host host, xen_sr crash_dump_sr) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = host }, + { .type = &abstract_type_string, + .u.string_val = crash_dump_sr } + }; + + xen_call_(session, "host.set_crash_dump_sr", param_values, 2, NULL, NULL); + return session->ok; +} + + bool xen_host_disable(xen_session *session, xen_host host) { diff --git a/tools/libxen/src/xen_vdi.c b/tools/libxen/src/xen_vdi.c index ea15c408d2..b2eddbcafb 100644 --- a/tools/libxen/src/xen_vdi.c +++ b/tools/libxen/src/xen_vdi.c @@ -21,6 +21,7 @@ #include #include "xen_common.h" +#include "xen_crashdump.h" #include "xen_internal.h" #include "xen_sr.h" #include "xen_vbd.h" @@ -54,6 +55,9 @@ static const struct_member xen_vdi_record_struct_members[] = { .key = "VBDs", .type = &abstract_type_ref_set, .offset = offsetof(xen_vdi_record, vbds) }, + { .key = "crash_dumps", + .type = &abstract_type_ref_set, + .offset = offsetof(xen_vdi_record, crash_dumps) }, { .key = "virtual_size", .type = &abstract_type_int, .offset = offsetof(xen_vdi_record, virtual_size) }, @@ -97,6 +101,7 @@ xen_vdi_record_free(xen_vdi_record *record) free(record->name_description); xen_sr_record_opt_free(record->sr); xen_vbd_record_opt_set_free(record->vbds); + xen_crashdump_record_opt_set_free(record->crash_dumps); free(record); } @@ -257,6 +262,23 @@ xen_vdi_get_vbds(xen_session *session, struct xen_vbd_set **result, xen_vdi vdi) } +bool +xen_vdi_get_crash_dumps(xen_session *session, struct xen_crashdump_set **result, xen_vdi vdi) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = vdi } + }; + + abstract_type result_type = abstract_type_string_set; + + *result = NULL; + XEN_CALL_("VDI.get_crash_dumps"); + return session->ok; +} + + bool xen_vdi_get_virtual_size(xen_session *session, int64_t *result, xen_vdi vdi) { @@ -315,9 +337,7 @@ xen_vdi_get_type(xen_session *session, enum xen_vdi_type *result, xen_vdi vdi) }; abstract_type result_type = xen_vdi_type_abstract_type_; - char *result_str = NULL; XEN_CALL_("VDI.get_type"); - *result = xen_vdi_type_from_string(session, result_str); return session->ok; } diff --git a/tools/libxen/src/xen_vdi_type.c b/tools/libxen/src/xen_vdi_type.c index 90cfe8c820..79e855fa59 100644 --- a/tools/libxen/src/xen_vdi_type.c +++ b/tools/libxen/src/xen_vdi_type.c @@ -30,7 +30,9 @@ static const char *lookup_table[] = { "system", "user", - "ephemeral" + "ephemeral", + "suspend", + "crashdump" }; diff --git a/tools/libxen/src/xen_vm.c b/tools/libxen/src/xen_vm.c index ef26a68366..ad295984cc 100644 --- a/tools/libxen/src/xen_vm.c +++ b/tools/libxen/src/xen_vm.c @@ -22,6 +22,7 @@ #include "xen_common.h" #include "xen_console.h" +#include "xen_crashdump.h" #include "xen_host.h" #include "xen_int_float_map.h" #include "xen_internal.h" @@ -29,6 +30,7 @@ #include "xen_on_normal_exit_internal.h" #include "xen_string_string_map.h" #include "xen_vbd.h" +#include "xen_vdi.h" #include "xen_vif.h" #include "xen_vm.h" #include "xen_vm_power_state_internal.h" @@ -67,6 +69,9 @@ static const struct_member xen_vm_record_struct_members[] = { .key = "auto_power_on", .type = &abstract_type_bool, .offset = offsetof(xen_vm_record, auto_power_on) }, + { .key = "suspend_VDI", + .type = &abstract_type_ref, + .offset = offsetof(xen_vm_record, suspend_vdi) }, { .key = "resident_on", .type = &abstract_type_ref, .offset = offsetof(xen_vm_record, resident_on) }, @@ -115,6 +120,9 @@ static const struct_member xen_vm_record_struct_members[] = { .key = "VBDs", .type = &abstract_type_ref_set, .offset = offsetof(xen_vm_record, vbds) }, + { .key = "crash_dumps", + .type = &abstract_type_ref_set, + .offset = offsetof(xen_vm_record, crash_dumps) }, { .key = "VTPMs", .type = &abstract_type_ref_set, .offset = offsetof(xen_vm_record, vtpms) }, @@ -183,6 +191,7 @@ xen_vm_record_free(xen_vm_record *record) free(record->uuid); free(record->name_label); free(record->name_description); + xen_vdi_record_opt_free(record->suspend_vdi); xen_host_record_opt_free(record->resident_on); free(record->vcpus_policy); free(record->vcpus_params); @@ -190,6 +199,7 @@ xen_vm_record_free(xen_vm_record *record) xen_console_record_opt_set_free(record->consoles); xen_vif_record_opt_set_free(record->vifs); xen_vbd_record_opt_set_free(record->vbds); + xen_crashdump_record_opt_set_free(record->crash_dumps); xen_vtpm_record_opt_set_free(record->vtpms); free(record->pv_bootloader); free(record->pv_kernel); @@ -390,6 +400,23 @@ xen_vm_get_auto_power_on(xen_session *session, bool *result, xen_vm vm) } +bool +xen_vm_get_suspend_vdi(xen_session *session, xen_vdi *result, xen_vm vm) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = vm } + }; + + abstract_type result_type = abstract_type_string; + + *result = NULL; + XEN_CALL_("VM.get_suspend_VDI"); + return session->ok; +} + + bool xen_vm_get_resident_on(xen_session *session, xen_host *result, xen_vm vm) { @@ -650,6 +677,23 @@ xen_vm_get_vbds(xen_session *session, struct xen_vbd_set **result, xen_vm vm) } +bool +xen_vm_get_crash_dumps(xen_session *session, struct xen_crashdump_set **result, xen_vm vm) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = vm } + }; + + abstract_type result_type = abstract_type_string_set; + + *result = NULL; + XEN_CALL_("VM.get_crash_dumps"); + return session->ok; +} + + bool xen_vm_get_vtpms(xen_session *session, struct xen_vtpm_set **result, xen_vm vm) {