[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] New modelling for consoles -- have them as separate classes attached to the
# HG changeset patch # User Ewan Mellor <ewan@xxxxxxxxxxxxx> # Node ID 5e9812e53300c29690d78914d31ad3a9f42edcbc # Parent 463bda1677151dd4b588c838a2cd2f5ad2669c82 New modelling for consoles -- have them as separate classes attached to the VM, much like the arrangements for devices. Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx> --- docs/xen-api/xenapi-datamodel.tex | 320 +++++++++++++++++++ tools/libxen/include/xen_console.h | 207 ++++++++++++ tools/libxen/include/xen_console_decl.h | 30 + tools/libxen/include/xen_console_protocol.h | 82 ++++ tools/libxen/include/xen_console_protocol_internal.h | 37 ++ tools/libxen/include/xen_vm.h | 9 tools/libxen/src/xen_console.c | 207 ++++++++++++ tools/libxen/src/xen_console_protocol.c | 82 ++++ tools/libxen/src/xen_vm.c | 22 + 9 files changed, 996 insertions(+) diff -r 463bda167715 -r 5e9812e53300 docs/xen-api/xenapi-datamodel.tex --- a/docs/xen-api/xenapi-datamodel.tex Wed Nov 29 12:43:11 2006 +0000 +++ b/docs/xen-api/xenapi-datamodel.tex Wed Nov 29 23:31:07 2006 +0000 @@ -34,6 +34,7 @@ Name & Description \\ {\tt VDI} & A virtual disk image \\ {\tt VBD} & A virtual block device \\ {\tt VTPM} & A virtual TPM device \\ +{\tt console} & A console \\ {\tt user} & A user of the system \\ {\tt debug} & A basic class for testing \\ \hline @@ -54,6 +55,7 @@ PIF.network & network.PIFs & one-to-many PIF.network & network.PIFs & one-to-many\\ SR.VDIs & VDI.SR & many-to-one\\ VTPM.VM & VM.VTPMs & one-to-many\\ +console.VM & VM.consoles & one-to-many\\ host.resident\_VMs & VM.resident\_on & many-to-one\\ host.host\_CPUs & host\_cpu.host & many-to-one\\ \hline @@ -96,6 +98,16 @@ Map (a $\rightarrow$ b) & a table mappin \end{tabular}\end{center} \subsection{Enumeration types} The following enumeration types are used: + +\begin{longtable}{|ll|} +\hline +{\tt enum console\_protocol} & \\ +\hline +\hspace{0.5cm}{\tt vt100} & VT100 terminal \\ +\hspace{0.5cm}{\tt rfb} & Remote FrameBuffer protocol (as used in VNC) \\ +\hspace{0.5cm}{\tt rdp} & Remote Desktop Protocol \\ +\hline +\end{longtable} \begin{longtable}{|ll|} \hline @@ -947,6 +959,7 @@ Quals & Field & Type & Description \\ $\mathit{RW}$ & {\tt actions/after\_reboot} & on\_normal\_exit & action to take after the guest has rebooted itself \\ $\mathit{RW}$ & {\tt actions/after\_suspend} & on\_normal\_exit & action to take after the guest has suspended itself \\ $\mathit{RW}$ & {\tt actions/after\_crash} & on\_crash\_behaviour & action to take if the guest crashes \\ +$\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 VTPMs} & (VTPM ref) Set & virtual TPMs \\ @@ -2628,6 +2641,38 @@ void +\vspace{0.3cm} +\vspace{0.3cm} +\vspace{0.3cm} +\subsubsection{RPC name:~get\_consoles} + +{\bf Overview:} +Get the consoles field of the given VM. + + \noindent {\bf Signature:} +\begin{verbatim} ((console ref) Set) get_consoles (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 & object instance \\ \hline + +\end{tabular} + +\vspace{0.3cm} + + \noindent {\bf Return Type:} +{\tt +(console ref) Set +} + + +value of the field \vspace{0.3cm} \vspace{0.3cm} \vspace{0.3cm} @@ -9187,6 +9232,281 @@ all fields from the object \vspace{1cm} \newpage +\section{Class: console} +\subsection{Fields for class: console} +\begin{longtable}{|lllp{0.38\textwidth}|} +\hline +\multicolumn{1}{|l}{Name} & \multicolumn{3}{l|}{\bf console} \\ +\multicolumn{1}{|l}{Description} & \multicolumn{3}{l|}{\parbox{11cm}{\em A console}} \\ +\hline +Quals & Field & Type & Description \\ +\hline +$\mathit{RO}_\mathit{run}$ & {\tt uuid} & string & unique identifier/object reference \\ +$\mathit{RO}_\mathit{run}$ & {\tt protocol} & console\_protocol & the protocol used by this console \\ +$\mathit{RO}_\mathit{run}$ & {\tt uri} & string & URI for the console service \\ +$\mathit{RO}_\mathit{run}$ & {\tt VM} & VM ref & VM to which this console is attached \\ +\hline +\end{longtable} +\subsection{Additional RPCs associated with class: console} +\subsubsection{RPC name:~get\_record} + +{\bf Overview:} +Get the current state of the given console. + + \noindent {\bf Signature:} +\begin{verbatim} (console record) get_record (session_id s, console 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 console ref } & self & reference to the object \\ \hline + +\end{tabular} + +\vspace{0.3cm} + + \noindent {\bf Return Type:} +{\tt +console record +} + + +all fields from the object +\vspace{0.3cm} +\vspace{0.3cm} +\vspace{0.3cm} +\subsubsection{RPC name:~get\_by\_uuid} + +{\bf Overview:} +Get a reference to the object with the specified UUID. + + \noindent {\bf Signature:} +\begin{verbatim} (console 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 +console ref +} + + +reference to the object +\vspace{0.3cm} +\vspace{0.3cm} +\vspace{0.3cm} +\subsubsection{RPC name:~create} + +{\bf Overview:} +Create a new console instance, and return its handle. + + \noindent {\bf Signature:} +\begin{verbatim} (console ref) create (session_id s, console 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 console record } & args & All constructor arguments \\ \hline + +\end{tabular} + +\vspace{0.3cm} + + \noindent {\bf Return Type:} +{\tt +console 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 console instance. + + \noindent {\bf Signature:} +\begin{verbatim} void destroy (session_id s, console 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 console ref } & self & object instance \\ \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 console. + + \noindent {\bf Signature:} +\begin{verbatim} string get_uuid (session_id s, console 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 console ref } & self & object instance \\ \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\_protocol} + +{\bf Overview:} +Get the protocol field of the given console. + + \noindent {\bf Signature:} +\begin{verbatim} (console_protocol) get_protocol (session_id s, console 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 console ref } & self & object instance \\ \hline + +\end{tabular} + +\vspace{0.3cm} + + \noindent {\bf Return Type:} +{\tt +console\_protocol +} + + +value of the field +\vspace{0.3cm} +\vspace{0.3cm} +\vspace{0.3cm} +\subsubsection{RPC name:~get\_uri} + +{\bf Overview:} +Get the uri field of the given console. + + \noindent {\bf Signature:} +\begin{verbatim} string get_uri (session_id s, console 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 console ref } & self & object instance \\ \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 console. + + \noindent {\bf Signature:} +\begin{verbatim} (VM ref) get_VM (session_id s, console 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 console ref } & self & object instance \\ \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} + +\vspace{1cm} +\newpage \section{Class: user} \subsection{Fields for class: user} \begin{longtable}{|lllp{0.38\textwidth}|} diff -r 463bda167715 -r 5e9812e53300 tools/libxen/include/xen_vm.h --- a/tools/libxen/include/xen_vm.h Wed Nov 29 12:43:11 2006 +0000 +++ b/tools/libxen/include/xen_vm.h Wed Nov 29 23:31:07 2006 +0000 @@ -21,6 +21,7 @@ #include "xen_boot_type.h" #include "xen_common.h" +#include "xen_console_decl.h" #include "xen_cpu_feature.h" #include "xen_host_decl.h" #include "xen_int_float_map.h" @@ -96,6 +97,7 @@ typedef struct xen_vm_record enum xen_on_normal_exit actions_after_reboot; enum xen_on_normal_exit actions_after_suspend; enum xen_on_crash_behaviour actions_after_crash; + struct xen_console_record_opt_set *consoles; struct xen_vif_record_opt_set *vifs; struct xen_vbd_record_opt_set *vbds; struct xen_vtpm_record_opt_set *vtpms; @@ -401,6 +403,13 @@ xen_vm_get_actions_after_crash(xen_sessi /** + * Get the consoles field of the given VM. + */ +extern bool +xen_vm_get_consoles(xen_session *session, struct xen_console_set **result, xen_vm vm); + + +/** * Get the VIFs field of the given VM. */ extern bool diff -r 463bda167715 -r 5e9812e53300 tools/libxen/src/xen_vm.c --- a/tools/libxen/src/xen_vm.c Wed Nov 29 12:43:11 2006 +0000 +++ b/tools/libxen/src/xen_vm.c Wed Nov 29 23:31:07 2006 +0000 @@ -22,6 +22,7 @@ #include "xen_boot_type_internal.h" #include "xen_common.h" +#include "xen_console.h" #include "xen_cpu_feature.h" #include "xen_cpu_feature_internal.h" #include "xen_host.h" @@ -120,6 +121,9 @@ static const struct_member xen_vm_record { .key = "actions_after_crash", .type = &xen_on_crash_behaviour_abstract_type_, .offset = offsetof(xen_vm_record, actions_after_crash) }, + { .key = "consoles", + .type = &abstract_type_ref_set, + .offset = offsetof(xen_vm_record, consoles) }, { .key = "VIFs", .type = &abstract_type_ref_set, .offset = offsetof(xen_vm_record, vifs) }, @@ -205,6 +209,7 @@ xen_vm_record_free(xen_vm_record *record xen_cpu_feature_set_free(record->vcpus_features_can_use); xen_cpu_feature_set_free(record->vcpus_features_force_on); xen_cpu_feature_set_free(record->vcpus_features_force_off); + 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_vtpm_record_opt_set_free(record->vtpms); @@ -694,6 +699,23 @@ xen_vm_get_actions_after_crash(xen_sessi bool +xen_vm_get_consoles(xen_session *session, struct xen_console_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_consoles"); + return session->ok; +} + + +bool xen_vm_get_vifs(xen_session *session, struct xen_vif_set **result, xen_vm vm) { abstract_value param_values[] = diff -r 463bda167715 -r 5e9812e53300 tools/libxen/include/xen_console.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/libxen/include/xen_console.h Wed Nov 29 23:31:07 2006 +0000 @@ -0,0 +1,207 @@ +/* + * 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_CONSOLE_H +#define XEN_CONSOLE_H + +#include "xen_common.h" +#include "xen_console_decl.h" +#include "xen_console_protocol.h" +#include "xen_vm_decl.h" + + +/* + * The console class. + * + * A console. + */ + + +/** + * Free the given xen_console. The given handle must have been + * allocated by this library. + */ +extern void +xen_console_free(xen_console console); + + +typedef struct xen_console_set +{ + size_t size; + xen_console *contents[]; +} xen_console_set; + +/** + * Allocate a xen_console_set of the given size. + */ +extern xen_console_set * +xen_console_set_alloc(size_t size); + +/** + * Free the given xen_console_set. The given set must have been + * allocated by this library. + */ +extern void +xen_console_set_free(xen_console_set *set); + + +typedef struct xen_console_record +{ + xen_console handle; + char *uuid; + enum xen_console_protocol protocol; + char *uri; + struct xen_vm_record_opt *vm; +} xen_console_record; + +/** + * Allocate a xen_console_record. + */ +extern xen_console_record * +xen_console_record_alloc(void); + +/** + * Free the given xen_console_record, and all referenced values. The + * given record must have been allocated by this library. + */ +extern void +xen_console_record_free(xen_console_record *record); + + +typedef struct xen_console_record_opt +{ + bool is_record; + union + { + xen_console handle; + xen_console_record *record; + } u; +} xen_console_record_opt; + +/** + * Allocate a xen_console_record_opt. + */ +extern xen_console_record_opt * +xen_console_record_opt_alloc(void); + +/** + * Free the given xen_console_record_opt, and all referenced values. + * The given record_opt must have been allocated by this library. + */ +extern void +xen_console_record_opt_free(xen_console_record_opt *record_opt); + + +typedef struct xen_console_record_set +{ + size_t size; + xen_console_record *contents[]; +} xen_console_record_set; + +/** + * Allocate a xen_console_record_set of the given size. + */ +extern xen_console_record_set * +xen_console_record_set_alloc(size_t size); + +/** + * Free the given xen_console_record_set, and all referenced values. + * The given set must have been allocated by this library. + */ +extern void +xen_console_record_set_free(xen_console_record_set *set); + + + +typedef struct xen_console_record_opt_set +{ + size_t size; + xen_console_record_opt *contents[]; +} xen_console_record_opt_set; + +/** + * Allocate a xen_console_record_opt_set of the given size. + */ +extern xen_console_record_opt_set * +xen_console_record_opt_set_alloc(size_t size); + +/** + * Free the given xen_console_record_opt_set, and all referenced + * values. The given set must have been allocated by this library. + */ +extern void +xen_console_record_opt_set_free(xen_console_record_opt_set *set); + + +/** + * Get the current state of the given console. + */ +extern bool +xen_console_get_record(xen_session *session, xen_console_record **result, xen_console console); + + +/** + * Get a reference to the object with the specified UUID. + */ +extern bool +xen_console_get_by_uuid(xen_session *session, xen_console *result, char *uuid); + + +/** + * Create a new console instance, and return its handle. + */ +extern bool +xen_console_create(xen_session *session, xen_console *result, xen_console_record *record); + + +/** + * Destroy the specified console instance. + */ +extern bool +xen_console_destroy(xen_session *session, xen_console console); + + +/** + * Get the uuid field of the given console. + */ +extern bool +xen_console_get_uuid(xen_session *session, char **result, xen_console console); + + +/** + * Get the protocol field of the given console. + */ +extern bool +xen_console_get_protocol(xen_session *session, enum xen_console_protocol *result, xen_console console); + + +/** + * Get the uri field of the given console. + */ +extern bool +xen_console_get_uri(xen_session *session, char **result, xen_console console); + + +/** + * Get the VM field of the given console. + */ +extern bool +xen_console_get_vm(xen_session *session, xen_vm *result, xen_console console); + + +#endif diff -r 463bda167715 -r 5e9812e53300 tools/libxen/include/xen_console_decl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/libxen/include/xen_console_decl.h Wed Nov 29 23:31:07 2006 +0000 @@ -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_CONSOLE_DECL_H +#define XEN_CONSOLE_DECL_H + +typedef void *xen_console; + +struct xen_console_set; +struct xen_console_record; +struct xen_console_record_set; +struct xen_console_record_opt; +struct xen_console_record_opt_set; + +#endif diff -r 463bda167715 -r 5e9812e53300 tools/libxen/include/xen_console_protocol.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/libxen/include/xen_console_protocol.h Wed Nov 29 23:31:07 2006 +0000 @@ -0,0 +1,82 @@ +/* + * 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_CONSOLE_PROTOCOL_H +#define XEN_CONSOLE_PROTOCOL_H + + +#include "xen_common.h" + + +enum xen_console_protocol +{ + /** + * VT100 terminal + */ + XEN_CONSOLE_PROTOCOL_VT100, + + /** + * Remote FrameBuffer protocol (as used in VNC) + */ + XEN_CONSOLE_PROTOCOL_RFB, + + /** + * Remote Desktop Protocol + */ + XEN_CONSOLE_PROTOCOL_RDP +}; + + +typedef struct xen_console_protocol_set +{ + size_t size; + enum xen_console_protocol contents[]; +} xen_console_protocol_set; + +/** + * Allocate a xen_console_protocol_set of the given size. + */ +extern xen_console_protocol_set * +xen_console_protocol_set_alloc(size_t size); + +/** + * Free the given xen_console_protocol_set. The given set must have + * been allocated by this library. + */ +extern void +xen_console_protocol_set_free(xen_console_protocol_set *set); + + +/** + * Return the name corresponding to the given code. This string must + * not be modified or freed. + */ +extern const char * +xen_console_protocol_to_string(enum xen_console_protocol 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_console_protocol +xen_console_protocol_from_string(xen_session *session, const char *str); + + +#endif diff -r 463bda167715 -r 5e9812e53300 tools/libxen/include/xen_console_protocol_internal.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/libxen/include/xen_console_protocol_internal.h Wed Nov 29 23:31:07 2006 +0000 @@ -0,0 +1,37 @@ +/* + * 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 + */ + + +/* + * Declarations of the abstract types used during demarshalling of enum + * xen_console_protocol. Internal to this library -- do not use from outside. + */ + + +#ifndef XEN_CONSOLE_PROTOCOL_INTERNAL_H +#define XEN_CONSOLE_PROTOCOL_INTERNAL_H + + +#include "xen_internal.h" + + +extern const abstract_type xen_console_protocol_abstract_type_; +extern const abstract_type xen_console_protocol_set_abstract_type_; + + +#endif diff -r 463bda167715 -r 5e9812e53300 tools/libxen/src/xen_console.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/libxen/src/xen_console.c Wed Nov 29 23:31:07 2006 +0000 @@ -0,0 +1,207 @@ +/* + * 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 <stddef.h> +#include <stdlib.h> + +#include "xen_common.h" +#include "xen_console.h" +#include "xen_console_protocol_internal.h" +#include "xen_internal.h" +#include "xen_vm.h" + + +XEN_FREE(xen_console) +XEN_SET_ALLOC_FREE(xen_console) +XEN_ALLOC(xen_console_record) +XEN_SET_ALLOC_FREE(xen_console_record) +XEN_ALLOC(xen_console_record_opt) +XEN_RECORD_OPT_FREE(xen_console) +XEN_SET_ALLOC_FREE(xen_console_record_opt) + + +static const struct_member xen_console_record_struct_members[] = + { + { .key = "uuid", + .type = &abstract_type_string, + .offset = offsetof(xen_console_record, uuid) }, + { .key = "protocol", + .type = &xen_console_protocol_abstract_type_, + .offset = offsetof(xen_console_record, protocol) }, + { .key = "uri", + .type = &abstract_type_string, + .offset = offsetof(xen_console_record, uri) }, + { .key = "VM", + .type = &abstract_type_ref, + .offset = offsetof(xen_console_record, vm) } + }; + +const abstract_type xen_console_record_abstract_type_ = + { + .typename = STRUCT, + .struct_size = sizeof(xen_console_record), + .member_count = + sizeof(xen_console_record_struct_members) / sizeof(struct_member), + .members = xen_console_record_struct_members + }; + + +void +xen_console_record_free(xen_console_record *record) +{ + if (record == NULL) + { + return; + } + free(record->handle); + free(record->uuid); + free(record->uri); + xen_vm_record_opt_free(record->vm); + free(record); +} + + +bool +xen_console_get_record(xen_session *session, xen_console_record **result, xen_console console) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = console } + }; + + abstract_type result_type = xen_console_record_abstract_type_; + + *result = NULL; + XEN_CALL_("console.get_record"); + + if (session->ok) + { + (*result)->handle = xen_strdup_((*result)->uuid); + } + + return session->ok; +} + + +bool +xen_console_get_by_uuid(xen_session *session, xen_console *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_("console.get_by_uuid"); + return session->ok; +} + + +bool +xen_console_create(xen_session *session, xen_console *result, xen_console_record *record) +{ + abstract_value param_values[] = + { + { .type = &xen_console_record_abstract_type_, + .u.struct_val = record } + }; + + abstract_type result_type = abstract_type_string; + + *result = NULL; + XEN_CALL_("console.create"); + return session->ok; +} + + +bool +xen_console_destroy(xen_session *session, xen_console console) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = console } + }; + + xen_call_(session, "console.destroy", param_values, 1, NULL, NULL); + return session->ok; +} + + +bool +xen_console_get_protocol(xen_session *session, enum xen_console_protocol *result, xen_console console) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = console } + }; + + abstract_type result_type = xen_console_protocol_abstract_type_; + char *result_str = NULL; + XEN_CALL_("console.get_protocol"); + *result = xen_console_protocol_from_string(session, result_str); + return session->ok; +} + + +bool +xen_console_get_uri(xen_session *session, char **result, xen_console console) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = console } + }; + + abstract_type result_type = abstract_type_string; + + *result = NULL; + XEN_CALL_("console.get_uri"); + return session->ok; +} + + +bool +xen_console_get_vm(xen_session *session, xen_vm *result, xen_console console) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = console } + }; + + abstract_type result_type = abstract_type_string; + + *result = NULL; + XEN_CALL_("console.get_VM"); + return session->ok; +} + + +bool +xen_console_get_uuid(xen_session *session, char **result, xen_console console) +{ + *result = session->ok ? xen_strdup_((char *)console) : NULL; + return session->ok; +} diff -r 463bda167715 -r 5e9812e53300 tools/libxen/src/xen_console_protocol.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/libxen/src/xen_console_protocol.c Wed Nov 29 23:31:07 2006 +0000 @@ -0,0 +1,82 @@ +/* + * 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 <string.h> + +#include "xen_internal.h" +#include "xen_console_protocol.h" +#include "xen_console_protocol_internal.h" + + +/* + * Maintain this in the same order as the enum declaration! + */ +static const char *lookup_table[] = +{ + "vt100", + "rfb", + "rdp" +}; + + +extern xen_console_protocol_set * +xen_console_protocol_set_alloc(size_t size) +{ + return calloc(1, sizeof(xen_console_protocol_set) + + size * sizeof(enum xen_console_protocol)); +} + + +extern void +xen_console_protocol_set_free(xen_console_protocol_set *set) +{ + free(set); +} + + +const char * +xen_console_protocol_to_string(enum xen_console_protocol val) +{ + return lookup_table[val]; +} + + +extern enum xen_console_protocol +xen_console_protocol_from_string(xen_session *session, const char *str) +{ + return ENUM_LOOKUP(session, str, lookup_table); +} + + +const abstract_type xen_console_protocol_abstract_type_ = + { + .typename = ENUM, + .enum_marshaller = + (const char *(*)(int))&xen_console_protocol_to_string, + .enum_demarshaller = + (int (*)(xen_session *, const char *))&xen_console_protocol_from_string + }; + + +const abstract_type xen_console_protocol_set_abstract_type_ = + { + .typename = SET, + .child = &xen_console_protocol_abstract_type_ + }; + + _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |