ia64/xen-unstable

changeset 12672:5e9812e53300

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@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Wed Nov 29 23:31:07 2006 +0000 (2006-11-29)
parents 463bda167715
children 884c25ba7d26
files docs/xen-api/xenapi-datamodel.tex tools/libxen/include/xen_console.h tools/libxen/include/xen_console_decl.h tools/libxen/include/xen_console_protocol.h tools/libxen/include/xen_console_protocol_internal.h tools/libxen/include/xen_vm.h tools/libxen/src/xen_console.c tools/libxen/src/xen_console_protocol.c tools/libxen/src/xen_vm.c
line diff
     1.1 --- a/docs/xen-api/xenapi-datamodel.tex	Wed Nov 29 12:43:11 2006 +0000
     1.2 +++ b/docs/xen-api/xenapi-datamodel.tex	Wed Nov 29 23:31:07 2006 +0000
     1.3 @@ -34,6 +34,7 @@ Name & Description \\
     1.4  {\tt VDI} & A virtual disk image \\
     1.5  {\tt VBD} & A virtual block device \\
     1.6  {\tt VTPM} & A virtual TPM device \\
     1.7 +{\tt console} & A console \\
     1.8  {\tt user} & A user of the system \\
     1.9  {\tt debug} & A basic class for testing \\
    1.10  \hline
    1.11 @@ -54,6 +55,7 @@ PIF.host & host.PIFs & one-to-many\\
    1.12  PIF.network & network.PIFs & one-to-many\\
    1.13  SR.VDIs & VDI.SR & many-to-one\\
    1.14  VTPM.VM & VM.VTPMs & one-to-many\\
    1.15 +console.VM & VM.consoles & one-to-many\\
    1.16  host.resident\_VMs & VM.resident\_on & many-to-one\\
    1.17  host.host\_CPUs & host\_cpu.host & many-to-one\\
    1.18  \hline
    1.19 @@ -99,6 +101,16 @@ The following enumeration types are used
    1.20  
    1.21  \begin{longtable}{|ll|}
    1.22  \hline
    1.23 +{\tt enum console\_protocol} & \\
    1.24 +\hline
    1.25 +\hspace{0.5cm}{\tt vt100} & VT100 terminal \\
    1.26 +\hspace{0.5cm}{\tt rfb} & Remote FrameBuffer protocol (as used in VNC) \\
    1.27 +\hspace{0.5cm}{\tt rdp} & Remote Desktop Protocol \\
    1.28 +\hline
    1.29 +\end{longtable}
    1.30 +
    1.31 +\begin{longtable}{|ll|}
    1.32 +\hline
    1.33  {\tt enum vdi\_type} & \\
    1.34  \hline
    1.35  \hspace{0.5cm}{\tt system} & a disk that may be replaced on upgrade \\
    1.36 @@ -947,6 +959,7 @@ Quals & Field & Type & Description \\
    1.37  $\mathit{RW}$ &  {\tt actions/after\_reboot} & on\_normal\_exit & action to take after the guest has rebooted itself \\
    1.38  $\mathit{RW}$ &  {\tt actions/after\_suspend} & on\_normal\_exit & action to take after the guest has suspended itself \\
    1.39  $\mathit{RW}$ &  {\tt actions/after\_crash} & on\_crash\_behaviour & action to take if the guest crashes \\
    1.40 +$\mathit{RO}_\mathit{run}$ &  {\tt consoles} & (console ref) Set & virtual console devices \\
    1.41  $\mathit{RO}_\mathit{run}$ &  {\tt VIFs} & (VIF ref) Set & virtual network interfaces \\
    1.42  $\mathit{RO}_\mathit{run}$ &  {\tt VBDs} & (VBD ref) Set & virtual block devices \\
    1.43  $\mathit{RO}_\mathit{run}$ &  {\tt VTPMs} & (VTPM ref) Set & virtual TPMs \\
    1.44 @@ -2631,6 +2644,38 @@ void
    1.45  \vspace{0.3cm}
    1.46  \vspace{0.3cm}
    1.47  \vspace{0.3cm}
    1.48 +\subsubsection{RPC name:~get\_consoles}
    1.49 +
    1.50 +{\bf Overview:} 
    1.51 +Get the consoles field of the given VM.
    1.52 +
    1.53 + \noindent {\bf Signature:} 
    1.54 +\begin{verbatim} ((console ref) Set) get_consoles (session_id s, VM ref self)\end{verbatim}
    1.55 +
    1.56 +
    1.57 +\noindent{\bf Arguments:}
    1.58 +
    1.59 + 
    1.60 +\vspace{0.3cm}
    1.61 +\begin{tabular}{|c|c|p{7cm}|}
    1.62 + \hline
    1.63 +{\bf type} & {\bf name} & {\bf description} \\ \hline
    1.64 +{\tt VM ref } & self & object instance \\ \hline 
    1.65 +
    1.66 +\end{tabular}
    1.67 +
    1.68 +\vspace{0.3cm}
    1.69 +
    1.70 + \noindent {\bf Return Type:} 
    1.71 +{\tt 
    1.72 +(console ref) Set
    1.73 +}
    1.74 +
    1.75 +
    1.76 +value of the field
    1.77 +\vspace{0.3cm}
    1.78 +\vspace{0.3cm}
    1.79 +\vspace{0.3cm}
    1.80  \subsubsection{RPC name:~get\_VIFs}
    1.81  
    1.82  {\bf Overview:} 
    1.83 @@ -9187,6 +9232,281 @@ all fields from the object
    1.84  
    1.85  \vspace{1cm}
    1.86  \newpage
    1.87 +\section{Class: console}
    1.88 +\subsection{Fields for class: console}
    1.89 +\begin{longtable}{|lllp{0.38\textwidth}|}
    1.90 +\hline
    1.91 +\multicolumn{1}{|l}{Name} & \multicolumn{3}{l|}{\bf console} \\
    1.92 +\multicolumn{1}{|l}{Description} & \multicolumn{3}{l|}{\parbox{11cm}{\em A console}} \\
    1.93 +\hline
    1.94 +Quals & Field & Type & Description \\
    1.95 +\hline
    1.96 +$\mathit{RO}_\mathit{run}$ &  {\tt uuid} & string & unique identifier/object reference \\
    1.97 +$\mathit{RO}_\mathit{run}$ &  {\tt protocol} & console\_protocol & the protocol used by this console \\
    1.98 +$\mathit{RO}_\mathit{run}$ &  {\tt uri} & string & URI for the console service \\
    1.99 +$\mathit{RO}_\mathit{run}$ &  {\tt VM} & VM ref & VM to which this console is attached \\
   1.100 +\hline
   1.101 +\end{longtable}
   1.102 +\subsection{Additional RPCs associated with class: console}
   1.103 +\subsubsection{RPC name:~get\_record}
   1.104 +
   1.105 +{\bf Overview:} 
   1.106 +Get the current state of the given console.
   1.107 +
   1.108 + \noindent {\bf Signature:} 
   1.109 +\begin{verbatim} (console record) get_record (session_id s, console ref self)\end{verbatim}
   1.110 +
   1.111 +
   1.112 +\noindent{\bf Arguments:}
   1.113 +
   1.114 + 
   1.115 +\vspace{0.3cm}
   1.116 +\begin{tabular}{|c|c|p{7cm}|}
   1.117 + \hline
   1.118 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.119 +{\tt console ref } & self & reference to the object \\ \hline 
   1.120 +
   1.121 +\end{tabular}
   1.122 +
   1.123 +\vspace{0.3cm}
   1.124 +
   1.125 + \noindent {\bf Return Type:} 
   1.126 +{\tt 
   1.127 +console record
   1.128 +}
   1.129 +
   1.130 +
   1.131 +all fields from the object
   1.132 +\vspace{0.3cm}
   1.133 +\vspace{0.3cm}
   1.134 +\vspace{0.3cm}
   1.135 +\subsubsection{RPC name:~get\_by\_uuid}
   1.136 +
   1.137 +{\bf Overview:} 
   1.138 +Get a reference to the object with the specified UUID.
   1.139 +
   1.140 + \noindent {\bf Signature:} 
   1.141 +\begin{verbatim} (console ref) get_by_uuid (session_id s, string uuid)\end{verbatim}
   1.142 +
   1.143 +
   1.144 +\noindent{\bf Arguments:}
   1.145 +
   1.146 + 
   1.147 +\vspace{0.3cm}
   1.148 +\begin{tabular}{|c|c|p{7cm}|}
   1.149 + \hline
   1.150 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.151 +{\tt string } & uuid & UUID of object to return \\ \hline 
   1.152 +
   1.153 +\end{tabular}
   1.154 +
   1.155 +\vspace{0.3cm}
   1.156 +
   1.157 + \noindent {\bf Return Type:} 
   1.158 +{\tt 
   1.159 +console ref
   1.160 +}
   1.161 +
   1.162 +
   1.163 +reference to the object
   1.164 +\vspace{0.3cm}
   1.165 +\vspace{0.3cm}
   1.166 +\vspace{0.3cm}
   1.167 +\subsubsection{RPC name:~create}
   1.168 +
   1.169 +{\bf Overview:} 
   1.170 +Create a new console instance, and return its handle.
   1.171 +
   1.172 + \noindent {\bf Signature:} 
   1.173 +\begin{verbatim} (console ref) create (session_id s, console record args)\end{verbatim}
   1.174 +
   1.175 +
   1.176 +\noindent{\bf Arguments:}
   1.177 +
   1.178 + 
   1.179 +\vspace{0.3cm}
   1.180 +\begin{tabular}{|c|c|p{7cm}|}
   1.181 + \hline
   1.182 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.183 +{\tt console record } & args & All constructor arguments \\ \hline 
   1.184 +
   1.185 +\end{tabular}
   1.186 +
   1.187 +\vspace{0.3cm}
   1.188 +
   1.189 + \noindent {\bf Return Type:} 
   1.190 +{\tt 
   1.191 +console ref
   1.192 +}
   1.193 +
   1.194 +
   1.195 +reference to the newly created object
   1.196 +\vspace{0.3cm}
   1.197 +\vspace{0.3cm}
   1.198 +\vspace{0.3cm}
   1.199 +\subsubsection{RPC name:~destroy}
   1.200 +
   1.201 +{\bf Overview:} 
   1.202 +Destroy the specified console instance.
   1.203 +
   1.204 + \noindent {\bf Signature:} 
   1.205 +\begin{verbatim} void destroy (session_id s, console ref self)\end{verbatim}
   1.206 +
   1.207 +
   1.208 +\noindent{\bf Arguments:}
   1.209 +
   1.210 + 
   1.211 +\vspace{0.3cm}
   1.212 +\begin{tabular}{|c|c|p{7cm}|}
   1.213 + \hline
   1.214 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.215 +{\tt console ref } & self & object instance \\ \hline 
   1.216 +
   1.217 +\end{tabular}
   1.218 +
   1.219 +\vspace{0.3cm}
   1.220 +
   1.221 + \noindent {\bf Return Type:} 
   1.222 +{\tt 
   1.223 +void
   1.224 +}
   1.225 +
   1.226 +
   1.227 +
   1.228 +\vspace{0.3cm}
   1.229 +\vspace{0.3cm}
   1.230 +\vspace{0.3cm}
   1.231 +\subsubsection{RPC name:~get\_uuid}
   1.232 +
   1.233 +{\bf Overview:} 
   1.234 +Get the uuid field of the given console.
   1.235 +
   1.236 + \noindent {\bf Signature:} 
   1.237 +\begin{verbatim} string get_uuid (session_id s, console ref self)\end{verbatim}
   1.238 +
   1.239 +
   1.240 +\noindent{\bf Arguments:}
   1.241 +
   1.242 + 
   1.243 +\vspace{0.3cm}
   1.244 +\begin{tabular}{|c|c|p{7cm}|}
   1.245 + \hline
   1.246 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.247 +{\tt console ref } & self & object instance \\ \hline 
   1.248 +
   1.249 +\end{tabular}
   1.250 +
   1.251 +\vspace{0.3cm}
   1.252 +
   1.253 + \noindent {\bf Return Type:} 
   1.254 +{\tt 
   1.255 +string
   1.256 +}
   1.257 +
   1.258 +
   1.259 +value of the field
   1.260 +\vspace{0.3cm}
   1.261 +\vspace{0.3cm}
   1.262 +\vspace{0.3cm}
   1.263 +\subsubsection{RPC name:~get\_protocol}
   1.264 +
   1.265 +{\bf Overview:} 
   1.266 +Get the protocol field of the given console.
   1.267 +
   1.268 + \noindent {\bf Signature:} 
   1.269 +\begin{verbatim} (console_protocol) get_protocol (session_id s, console ref self)\end{verbatim}
   1.270 +
   1.271 +
   1.272 +\noindent{\bf Arguments:}
   1.273 +
   1.274 + 
   1.275 +\vspace{0.3cm}
   1.276 +\begin{tabular}{|c|c|p{7cm}|}
   1.277 + \hline
   1.278 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.279 +{\tt console ref } & self & object instance \\ \hline 
   1.280 +
   1.281 +\end{tabular}
   1.282 +
   1.283 +\vspace{0.3cm}
   1.284 +
   1.285 + \noindent {\bf Return Type:} 
   1.286 +{\tt 
   1.287 +console\_protocol
   1.288 +}
   1.289 +
   1.290 +
   1.291 +value of the field
   1.292 +\vspace{0.3cm}
   1.293 +\vspace{0.3cm}
   1.294 +\vspace{0.3cm}
   1.295 +\subsubsection{RPC name:~get\_uri}
   1.296 +
   1.297 +{\bf Overview:} 
   1.298 +Get the uri field of the given console.
   1.299 +
   1.300 + \noindent {\bf Signature:} 
   1.301 +\begin{verbatim} string get_uri (session_id s, console ref self)\end{verbatim}
   1.302 +
   1.303 +
   1.304 +\noindent{\bf Arguments:}
   1.305 +
   1.306 + 
   1.307 +\vspace{0.3cm}
   1.308 +\begin{tabular}{|c|c|p{7cm}|}
   1.309 + \hline
   1.310 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.311 +{\tt console ref } & self & object instance \\ \hline 
   1.312 +
   1.313 +\end{tabular}
   1.314 +
   1.315 +\vspace{0.3cm}
   1.316 +
   1.317 + \noindent {\bf Return Type:} 
   1.318 +{\tt 
   1.319 +string
   1.320 +}
   1.321 +
   1.322 +
   1.323 +value of the field
   1.324 +\vspace{0.3cm}
   1.325 +\vspace{0.3cm}
   1.326 +\vspace{0.3cm}
   1.327 +\subsubsection{RPC name:~get\_VM}
   1.328 +
   1.329 +{\bf Overview:} 
   1.330 +Get the VM field of the given console.
   1.331 +
   1.332 + \noindent {\bf Signature:} 
   1.333 +\begin{verbatim} (VM ref) get_VM (session_id s, console ref self)\end{verbatim}
   1.334 +
   1.335 +
   1.336 +\noindent{\bf Arguments:}
   1.337 +
   1.338 + 
   1.339 +\vspace{0.3cm}
   1.340 +\begin{tabular}{|c|c|p{7cm}|}
   1.341 + \hline
   1.342 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   1.343 +{\tt console ref } & self & object instance \\ \hline 
   1.344 +
   1.345 +\end{tabular}
   1.346 +
   1.347 +\vspace{0.3cm}
   1.348 +
   1.349 + \noindent {\bf Return Type:} 
   1.350 +{\tt 
   1.351 +VM ref
   1.352 +}
   1.353 +
   1.354 +
   1.355 +value of the field
   1.356 +\vspace{0.3cm}
   1.357 +\vspace{0.3cm}
   1.358 +\vspace{0.3cm}
   1.359 +
   1.360 +\vspace{1cm}
   1.361 +\newpage
   1.362  \section{Class: user}
   1.363  \subsection{Fields for class: user}
   1.364  \begin{longtable}{|lllp{0.38\textwidth}|}
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/tools/libxen/include/xen_console.h	Wed Nov 29 23:31:07 2006 +0000
     2.3 @@ -0,0 +1,207 @@
     2.4 +/*
     2.5 + * Copyright (c) 2006, XenSource Inc.
     2.6 + *
     2.7 + * This library is free software; you can redistribute it and/or
     2.8 + * modify it under the terms of the GNU Lesser General Public
     2.9 + * License as published by the Free Software Foundation; either
    2.10 + * version 2.1 of the License, or (at your option) any later version.
    2.11 + *
    2.12 + * This library is distributed in the hope that it will be useful,
    2.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    2.15 + * Lesser General Public License for more details.
    2.16 + *
    2.17 + * You should have received a copy of the GNU Lesser General Public
    2.18 + * License along with this library; if not, write to the Free Software
    2.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
    2.20 + */
    2.21 +
    2.22 +#ifndef XEN_CONSOLE_H
    2.23 +#define XEN_CONSOLE_H
    2.24 +
    2.25 +#include "xen_common.h"
    2.26 +#include "xen_console_decl.h"
    2.27 +#include "xen_console_protocol.h"
    2.28 +#include "xen_vm_decl.h"
    2.29 +
    2.30 +
    2.31 +/*
    2.32 + * The console class. 
    2.33 + *  
    2.34 + * A console.
    2.35 + */
    2.36 +
    2.37 +
    2.38 +/**
    2.39 + * Free the given xen_console.  The given handle must have been
    2.40 + * allocated by this library.
    2.41 + */
    2.42 +extern void
    2.43 +xen_console_free(xen_console console);
    2.44 +
    2.45 +
    2.46 +typedef struct xen_console_set
    2.47 +{
    2.48 +    size_t size;
    2.49 +    xen_console *contents[];
    2.50 +} xen_console_set;
    2.51 +
    2.52 +/**
    2.53 + * Allocate a xen_console_set of the given size.
    2.54 + */
    2.55 +extern xen_console_set *
    2.56 +xen_console_set_alloc(size_t size);
    2.57 +
    2.58 +/**
    2.59 + * Free the given xen_console_set.  The given set must have been
    2.60 + * allocated by this library.
    2.61 + */
    2.62 +extern void
    2.63 +xen_console_set_free(xen_console_set *set);
    2.64 +
    2.65 +
    2.66 +typedef struct xen_console_record
    2.67 +{
    2.68 +    xen_console handle;
    2.69 +    char *uuid;
    2.70 +    enum xen_console_protocol protocol;
    2.71 +    char *uri;
    2.72 +    struct xen_vm_record_opt *vm;
    2.73 +} xen_console_record;
    2.74 +
    2.75 +/**
    2.76 + * Allocate a xen_console_record.
    2.77 + */
    2.78 +extern xen_console_record *
    2.79 +xen_console_record_alloc(void);
    2.80 +
    2.81 +/**
    2.82 + * Free the given xen_console_record, and all referenced values.  The
    2.83 + * given record must have been allocated by this library.
    2.84 + */
    2.85 +extern void
    2.86 +xen_console_record_free(xen_console_record *record);
    2.87 +
    2.88 +
    2.89 +typedef struct xen_console_record_opt
    2.90 +{
    2.91 +    bool is_record;
    2.92 +    union
    2.93 +    {
    2.94 +        xen_console handle;
    2.95 +        xen_console_record *record;
    2.96 +    } u;
    2.97 +} xen_console_record_opt;
    2.98 +
    2.99 +/**
   2.100 + * Allocate a xen_console_record_opt.
   2.101 + */
   2.102 +extern xen_console_record_opt *
   2.103 +xen_console_record_opt_alloc(void);
   2.104 +
   2.105 +/**
   2.106 + * Free the given xen_console_record_opt, and all referenced values. 
   2.107 + * The given record_opt must have been allocated by this library.
   2.108 + */
   2.109 +extern void
   2.110 +xen_console_record_opt_free(xen_console_record_opt *record_opt);
   2.111 +
   2.112 +
   2.113 +typedef struct xen_console_record_set
   2.114 +{
   2.115 +    size_t size;
   2.116 +    xen_console_record *contents[];
   2.117 +} xen_console_record_set;
   2.118 +
   2.119 +/**
   2.120 + * Allocate a xen_console_record_set of the given size.
   2.121 + */
   2.122 +extern xen_console_record_set *
   2.123 +xen_console_record_set_alloc(size_t size);
   2.124 +
   2.125 +/**
   2.126 + * Free the given xen_console_record_set, and all referenced values. 
   2.127 + * The given set must have been allocated by this library.
   2.128 + */
   2.129 +extern void
   2.130 +xen_console_record_set_free(xen_console_record_set *set);
   2.131 +
   2.132 +
   2.133 +
   2.134 +typedef struct xen_console_record_opt_set
   2.135 +{
   2.136 +    size_t size;
   2.137 +    xen_console_record_opt *contents[];
   2.138 +} xen_console_record_opt_set;
   2.139 +
   2.140 +/**
   2.141 + * Allocate a xen_console_record_opt_set of the given size.
   2.142 + */
   2.143 +extern xen_console_record_opt_set *
   2.144 +xen_console_record_opt_set_alloc(size_t size);
   2.145 +
   2.146 +/**
   2.147 + * Free the given xen_console_record_opt_set, and all referenced
   2.148 + * values.  The given set must have been allocated by this library.
   2.149 + */
   2.150 +extern void
   2.151 +xen_console_record_opt_set_free(xen_console_record_opt_set *set);
   2.152 +
   2.153 +
   2.154 +/**
   2.155 + * Get the current state of the given console.
   2.156 + */
   2.157 +extern bool
   2.158 +xen_console_get_record(xen_session *session, xen_console_record **result, xen_console console);
   2.159 +
   2.160 +
   2.161 +/**
   2.162 + * Get a reference to the object with the specified UUID.
   2.163 + */
   2.164 +extern bool
   2.165 +xen_console_get_by_uuid(xen_session *session, xen_console *result, char *uuid);
   2.166 +
   2.167 +
   2.168 +/**
   2.169 + * Create a new console instance, and return its handle.
   2.170 + */
   2.171 +extern bool
   2.172 +xen_console_create(xen_session *session, xen_console *result, xen_console_record *record);
   2.173 +
   2.174 +
   2.175 +/**
   2.176 + * Destroy the specified console instance.
   2.177 + */
   2.178 +extern bool
   2.179 +xen_console_destroy(xen_session *session, xen_console console);
   2.180 +
   2.181 +
   2.182 +/**
   2.183 + * Get the uuid field of the given console.
   2.184 + */
   2.185 +extern bool
   2.186 +xen_console_get_uuid(xen_session *session, char **result, xen_console console);
   2.187 +
   2.188 +
   2.189 +/**
   2.190 + * Get the protocol field of the given console.
   2.191 + */
   2.192 +extern bool
   2.193 +xen_console_get_protocol(xen_session *session, enum xen_console_protocol *result, xen_console console);
   2.194 +
   2.195 +
   2.196 +/**
   2.197 + * Get the uri field of the given console.
   2.198 + */
   2.199 +extern bool
   2.200 +xen_console_get_uri(xen_session *session, char **result, xen_console console);
   2.201 +
   2.202 +
   2.203 +/**
   2.204 + * Get the VM field of the given console.
   2.205 + */
   2.206 +extern bool
   2.207 +xen_console_get_vm(xen_session *session, xen_vm *result, xen_console console);
   2.208 +
   2.209 +
   2.210 +#endif
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/tools/libxen/include/xen_console_decl.h	Wed Nov 29 23:31:07 2006 +0000
     3.3 @@ -0,0 +1,30 @@
     3.4 +/*
     3.5 + * Copyright (c) 2006, XenSource Inc.
     3.6 + *
     3.7 + * This library is free software; you can redistribute it and/or
     3.8 + * modify it under the terms of the GNU Lesser General Public
     3.9 + * License as published by the Free Software Foundation; either
    3.10 + * version 2.1 of the License, or (at your option) any later version.
    3.11 + *
    3.12 + * This library is distributed in the hope that it will be useful,
    3.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    3.15 + * Lesser General Public License for more details.
    3.16 + *
    3.17 + * You should have received a copy of the GNU Lesser General Public
    3.18 + * License along with this library; if not, write to the Free Software
    3.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
    3.20 + */
    3.21 +
    3.22 +#ifndef XEN_CONSOLE_DECL_H
    3.23 +#define XEN_CONSOLE_DECL_H
    3.24 +
    3.25 +typedef void *xen_console;
    3.26 +
    3.27 +struct xen_console_set;
    3.28 +struct xen_console_record;
    3.29 +struct xen_console_record_set;
    3.30 +struct xen_console_record_opt;
    3.31 +struct xen_console_record_opt_set;
    3.32 +
    3.33 +#endif
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/tools/libxen/include/xen_console_protocol.h	Wed Nov 29 23:31:07 2006 +0000
     4.3 @@ -0,0 +1,82 @@
     4.4 +/*
     4.5 + * Copyright (c) 2006, XenSource Inc.
     4.6 + *
     4.7 + * This library is free software; you can redistribute it and/or
     4.8 + * modify it under the terms of the GNU Lesser General Public
     4.9 + * License as published by the Free Software Foundation; either
    4.10 + * version 2.1 of the License, or (at your option) any later version.
    4.11 + *
    4.12 + * This library is distributed in the hope that it will be useful,
    4.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    4.15 + * Lesser General Public License for more details.
    4.16 + *
    4.17 + * You should have received a copy of the GNU Lesser General Public
    4.18 + * License along with this library; if not, write to the Free Software
    4.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
    4.20 + */
    4.21 +
    4.22 +#ifndef XEN_CONSOLE_PROTOCOL_H
    4.23 +#define XEN_CONSOLE_PROTOCOL_H
    4.24 +
    4.25 +
    4.26 +#include "xen_common.h"
    4.27 +
    4.28 +
    4.29 +enum xen_console_protocol
    4.30 +{
    4.31 +    /**
    4.32 +     * VT100 terminal
    4.33 +     */
    4.34 +    XEN_CONSOLE_PROTOCOL_VT100,
    4.35 +
    4.36 +    /**
    4.37 +     * Remote FrameBuffer protocol (as used in VNC)
    4.38 +     */
    4.39 +    XEN_CONSOLE_PROTOCOL_RFB,
    4.40 +
    4.41 +    /**
    4.42 +     * Remote Desktop Protocol
    4.43 +     */
    4.44 +    XEN_CONSOLE_PROTOCOL_RDP
    4.45 +};
    4.46 +
    4.47 +
    4.48 +typedef struct xen_console_protocol_set
    4.49 +{
    4.50 +    size_t size;
    4.51 +    enum xen_console_protocol contents[];
    4.52 +} xen_console_protocol_set;
    4.53 +
    4.54 +/**
    4.55 + * Allocate a xen_console_protocol_set of the given size.
    4.56 + */
    4.57 +extern xen_console_protocol_set *
    4.58 +xen_console_protocol_set_alloc(size_t size);
    4.59 +
    4.60 +/**
    4.61 + * Free the given xen_console_protocol_set.  The given set must have
    4.62 + * been allocated by this library.
    4.63 + */
    4.64 +extern void
    4.65 +xen_console_protocol_set_free(xen_console_protocol_set *set);
    4.66 +
    4.67 +
    4.68 +/**
    4.69 + * Return the name corresponding to the given code.  This string must
    4.70 + * not be modified or freed.
    4.71 + */
    4.72 +extern const char *
    4.73 +xen_console_protocol_to_string(enum xen_console_protocol val);
    4.74 +
    4.75 +
    4.76 +/**
    4.77 + * Return the correct code for the given string, or set the session
    4.78 + * object to failure and return an undefined value if the given string does
    4.79 + * not match a known code.
    4.80 + */
    4.81 +extern enum xen_console_protocol
    4.82 +xen_console_protocol_from_string(xen_session *session, const char *str);
    4.83 +
    4.84 +
    4.85 +#endif
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/tools/libxen/include/xen_console_protocol_internal.h	Wed Nov 29 23:31:07 2006 +0000
     5.3 @@ -0,0 +1,37 @@
     5.4 +/*
     5.5 + * Copyright (c) 2006, XenSource Inc.
     5.6 + *
     5.7 + * This library is free software; you can redistribute it and/or
     5.8 + * modify it under the terms of the GNU Lesser General Public
     5.9 + * License as published by the Free Software Foundation; either
    5.10 + * version 2.1 of the License, or (at your option) any later version.
    5.11 + *
    5.12 + * This library is distributed in the hope that it will be useful,
    5.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    5.15 + * Lesser General Public License for more details.
    5.16 + *
    5.17 + * You should have received a copy of the GNU Lesser General Public
    5.18 + * License along with this library; if not, write to the Free Software
    5.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
    5.20 + */
    5.21 +
    5.22 +
    5.23 +/*
    5.24 + * Declarations of the abstract types used during demarshalling of enum
    5.25 + * xen_console_protocol.  Internal to this library -- do not use from outside.
    5.26 + */
    5.27 +
    5.28 +
    5.29 +#ifndef XEN_CONSOLE_PROTOCOL_INTERNAL_H
    5.30 +#define XEN_CONSOLE_PROTOCOL_INTERNAL_H
    5.31 +
    5.32 +
    5.33 +#include "xen_internal.h"
    5.34 +
    5.35 +
    5.36 +extern const abstract_type xen_console_protocol_abstract_type_;
    5.37 +extern const abstract_type xen_console_protocol_set_abstract_type_;
    5.38 +
    5.39 +
    5.40 +#endif
     6.1 --- a/tools/libxen/include/xen_vm.h	Wed Nov 29 12:43:11 2006 +0000
     6.2 +++ b/tools/libxen/include/xen_vm.h	Wed Nov 29 23:31:07 2006 +0000
     6.3 @@ -21,6 +21,7 @@
     6.4  
     6.5  #include "xen_boot_type.h"
     6.6  #include "xen_common.h"
     6.7 +#include "xen_console_decl.h"
     6.8  #include "xen_cpu_feature.h"
     6.9  #include "xen_host_decl.h"
    6.10  #include "xen_int_float_map.h"
    6.11 @@ -96,6 +97,7 @@ typedef struct xen_vm_record
    6.12      enum xen_on_normal_exit actions_after_reboot;
    6.13      enum xen_on_normal_exit actions_after_suspend;
    6.14      enum xen_on_crash_behaviour actions_after_crash;
    6.15 +    struct xen_console_record_opt_set *consoles;
    6.16      struct xen_vif_record_opt_set *vifs;
    6.17      struct xen_vbd_record_opt_set *vbds;
    6.18      struct xen_vtpm_record_opt_set *vtpms;
    6.19 @@ -401,6 +403,13 @@ xen_vm_get_actions_after_crash(xen_sessi
    6.20  
    6.21  
    6.22  /**
    6.23 + * Get the consoles field of the given VM.
    6.24 + */
    6.25 +extern bool
    6.26 +xen_vm_get_consoles(xen_session *session, struct xen_console_set **result, xen_vm vm);
    6.27 +
    6.28 +
    6.29 +/**
    6.30   * Get the VIFs field of the given VM.
    6.31   */
    6.32  extern bool
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/tools/libxen/src/xen_console.c	Wed Nov 29 23:31:07 2006 +0000
     7.3 @@ -0,0 +1,207 @@
     7.4 +/*
     7.5 + * Copyright (c) 2006, XenSource Inc.
     7.6 + *
     7.7 + * This library is free software; you can redistribute it and/or
     7.8 + * modify it under the terms of the GNU Lesser General Public
     7.9 + * License as published by the Free Software Foundation; either
    7.10 + * version 2.1 of the License, or (at your option) any later version.
    7.11 + *
    7.12 + * This library is distributed in the hope that it will be useful,
    7.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    7.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    7.15 + * Lesser General Public License for more details.
    7.16 + *
    7.17 + * You should have received a copy of the GNU Lesser General Public
    7.18 + * License along with this library; if not, write to the Free Software
    7.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
    7.20 + */
    7.21 +
    7.22 +
    7.23 +#include <stddef.h>
    7.24 +#include <stdlib.h>
    7.25 +
    7.26 +#include "xen_common.h"
    7.27 +#include "xen_console.h"
    7.28 +#include "xen_console_protocol_internal.h"
    7.29 +#include "xen_internal.h"
    7.30 +#include "xen_vm.h"
    7.31 +
    7.32 +
    7.33 +XEN_FREE(xen_console)
    7.34 +XEN_SET_ALLOC_FREE(xen_console)
    7.35 +XEN_ALLOC(xen_console_record)
    7.36 +XEN_SET_ALLOC_FREE(xen_console_record)
    7.37 +XEN_ALLOC(xen_console_record_opt)
    7.38 +XEN_RECORD_OPT_FREE(xen_console)
    7.39 +XEN_SET_ALLOC_FREE(xen_console_record_opt)
    7.40 +
    7.41 +
    7.42 +static const struct_member xen_console_record_struct_members[] =
    7.43 +    {
    7.44 +        { .key = "uuid",
    7.45 +          .type = &abstract_type_string,
    7.46 +          .offset = offsetof(xen_console_record, uuid) },
    7.47 +        { .key = "protocol",
    7.48 +          .type = &xen_console_protocol_abstract_type_,
    7.49 +          .offset = offsetof(xen_console_record, protocol) },
    7.50 +        { .key = "uri",
    7.51 +          .type = &abstract_type_string,
    7.52 +          .offset = offsetof(xen_console_record, uri) },
    7.53 +        { .key = "VM",
    7.54 +          .type = &abstract_type_ref,
    7.55 +          .offset = offsetof(xen_console_record, vm) }
    7.56 +    };
    7.57 +
    7.58 +const abstract_type xen_console_record_abstract_type_ =
    7.59 +    {
    7.60 +       .typename = STRUCT,
    7.61 +       .struct_size = sizeof(xen_console_record),
    7.62 +       .member_count =
    7.63 +           sizeof(xen_console_record_struct_members) / sizeof(struct_member),
    7.64 +       .members = xen_console_record_struct_members
    7.65 +    };
    7.66 +
    7.67 +
    7.68 +void
    7.69 +xen_console_record_free(xen_console_record *record)
    7.70 +{
    7.71 +    if (record == NULL)
    7.72 +    {
    7.73 +        return;
    7.74 +    }
    7.75 +    free(record->handle);
    7.76 +    free(record->uuid);
    7.77 +    free(record->uri);
    7.78 +    xen_vm_record_opt_free(record->vm);
    7.79 +    free(record);
    7.80 +}
    7.81 +
    7.82 +
    7.83 +bool
    7.84 +xen_console_get_record(xen_session *session, xen_console_record **result, xen_console console)
    7.85 +{
    7.86 +    abstract_value param_values[] =
    7.87 +        {
    7.88 +            { .type = &abstract_type_string,
    7.89 +              .u.string_val = console }
    7.90 +        };
    7.91 +
    7.92 +    abstract_type result_type = xen_console_record_abstract_type_;
    7.93 +
    7.94 +    *result = NULL;
    7.95 +    XEN_CALL_("console.get_record");
    7.96 +
    7.97 +    if (session->ok)
    7.98 +    {
    7.99 +       (*result)->handle = xen_strdup_((*result)->uuid);
   7.100 +    }
   7.101 +
   7.102 +    return session->ok;
   7.103 +}
   7.104 +
   7.105 +
   7.106 +bool
   7.107 +xen_console_get_by_uuid(xen_session *session, xen_console *result, char *uuid)
   7.108 +{
   7.109 +    abstract_value param_values[] =
   7.110 +        {
   7.111 +            { .type = &abstract_type_string,
   7.112 +              .u.string_val = uuid }
   7.113 +        };
   7.114 +
   7.115 +    abstract_type result_type = abstract_type_string;
   7.116 +
   7.117 +    *result = NULL;
   7.118 +    XEN_CALL_("console.get_by_uuid");
   7.119 +    return session->ok;
   7.120 +}
   7.121 +
   7.122 +
   7.123 +bool
   7.124 +xen_console_create(xen_session *session, xen_console *result, xen_console_record *record)
   7.125 +{
   7.126 +    abstract_value param_values[] =
   7.127 +        {
   7.128 +            { .type = &xen_console_record_abstract_type_,
   7.129 +              .u.struct_val = record }
   7.130 +        };
   7.131 +
   7.132 +    abstract_type result_type = abstract_type_string;
   7.133 +
   7.134 +    *result = NULL;
   7.135 +    XEN_CALL_("console.create");
   7.136 +    return session->ok;
   7.137 +}
   7.138 +
   7.139 +
   7.140 +bool
   7.141 +xen_console_destroy(xen_session *session, xen_console console)
   7.142 +{
   7.143 +    abstract_value param_values[] =
   7.144 +        {
   7.145 +            { .type = &abstract_type_string,
   7.146 +              .u.string_val = console }
   7.147 +        };
   7.148 +
   7.149 +    xen_call_(session, "console.destroy", param_values, 1, NULL, NULL);
   7.150 +    return session->ok;
   7.151 +}
   7.152 +
   7.153 +
   7.154 +bool
   7.155 +xen_console_get_protocol(xen_session *session, enum xen_console_protocol *result, xen_console console)
   7.156 +{
   7.157 +    abstract_value param_values[] =
   7.158 +        {
   7.159 +            { .type = &abstract_type_string,
   7.160 +              .u.string_val = console }
   7.161 +        };
   7.162 +
   7.163 +    abstract_type result_type = xen_console_protocol_abstract_type_;
   7.164 +    char *result_str = NULL;
   7.165 +    XEN_CALL_("console.get_protocol");
   7.166 +    *result = xen_console_protocol_from_string(session, result_str);
   7.167 +    return session->ok;
   7.168 +}
   7.169 +
   7.170 +
   7.171 +bool
   7.172 +xen_console_get_uri(xen_session *session, char **result, xen_console console)
   7.173 +{
   7.174 +    abstract_value param_values[] =
   7.175 +        {
   7.176 +            { .type = &abstract_type_string,
   7.177 +              .u.string_val = console }
   7.178 +        };
   7.179 +
   7.180 +    abstract_type result_type = abstract_type_string;
   7.181 +
   7.182 +    *result = NULL;
   7.183 +    XEN_CALL_("console.get_uri");
   7.184 +    return session->ok;
   7.185 +}
   7.186 +
   7.187 +
   7.188 +bool
   7.189 +xen_console_get_vm(xen_session *session, xen_vm *result, xen_console console)
   7.190 +{
   7.191 +    abstract_value param_values[] =
   7.192 +        {
   7.193 +            { .type = &abstract_type_string,
   7.194 +              .u.string_val = console }
   7.195 +        };
   7.196 +
   7.197 +    abstract_type result_type = abstract_type_string;
   7.198 +
   7.199 +    *result = NULL;
   7.200 +    XEN_CALL_("console.get_VM");
   7.201 +    return session->ok;
   7.202 +}
   7.203 +
   7.204 +
   7.205 +bool
   7.206 +xen_console_get_uuid(xen_session *session, char **result, xen_console console)
   7.207 +{
   7.208 +    *result = session->ok ? xen_strdup_((char *)console) : NULL;
   7.209 +    return session->ok;
   7.210 +}
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/tools/libxen/src/xen_console_protocol.c	Wed Nov 29 23:31:07 2006 +0000
     8.3 @@ -0,0 +1,82 @@
     8.4 +/*
     8.5 + * Copyright (c) 2006, XenSource Inc.
     8.6 + *
     8.7 + * This library is free software; you can redistribute it and/or
     8.8 + * modify it under the terms of the GNU Lesser General Public
     8.9 + * License as published by the Free Software Foundation; either
    8.10 + * version 2.1 of the License, or (at your option) any later version.
    8.11 + *
    8.12 + * This library is distributed in the hope that it will be useful,
    8.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    8.15 + * Lesser General Public License for more details.
    8.16 + *
    8.17 + * You should have received a copy of the GNU Lesser General Public
    8.18 + * License along with this library; if not, write to the Free Software
    8.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
    8.20 + */
    8.21 +
    8.22 +#include <string.h>
    8.23 +
    8.24 +#include "xen_internal.h"
    8.25 +#include "xen_console_protocol.h"
    8.26 +#include "xen_console_protocol_internal.h"
    8.27 +
    8.28 +
    8.29 +/*
    8.30 + * Maintain this in the same order as the enum declaration!
    8.31 + */
    8.32 +static const char *lookup_table[] =
    8.33 +{
    8.34 +    "vt100",
    8.35 +    "rfb",
    8.36 +    "rdp"
    8.37 +};
    8.38 +
    8.39 +
    8.40 +extern xen_console_protocol_set *
    8.41 +xen_console_protocol_set_alloc(size_t size)
    8.42 +{
    8.43 +    return calloc(1, sizeof(xen_console_protocol_set) +
    8.44 +                  size * sizeof(enum xen_console_protocol));
    8.45 +}
    8.46 +
    8.47 +
    8.48 +extern void
    8.49 +xen_console_protocol_set_free(xen_console_protocol_set *set)
    8.50 +{
    8.51 +    free(set);
    8.52 +}
    8.53 +
    8.54 +
    8.55 +const char *
    8.56 +xen_console_protocol_to_string(enum xen_console_protocol val)
    8.57 +{
    8.58 +    return lookup_table[val];
    8.59 +}
    8.60 +
    8.61 +
    8.62 +extern enum xen_console_protocol
    8.63 +xen_console_protocol_from_string(xen_session *session, const char *str)
    8.64 +{
    8.65 +    return ENUM_LOOKUP(session, str, lookup_table);
    8.66 +}
    8.67 +
    8.68 +
    8.69 +const abstract_type xen_console_protocol_abstract_type_ =
    8.70 +    {
    8.71 +        .typename = ENUM,
    8.72 +        .enum_marshaller =
    8.73 +             (const char *(*)(int))&xen_console_protocol_to_string,
    8.74 +        .enum_demarshaller =
    8.75 +             (int (*)(xen_session *, const char *))&xen_console_protocol_from_string
    8.76 +    };
    8.77 +
    8.78 +
    8.79 +const abstract_type xen_console_protocol_set_abstract_type_ =
    8.80 +    {
    8.81 +        .typename = SET,
    8.82 +        .child = &xen_console_protocol_abstract_type_
    8.83 +    };
    8.84 +
    8.85 +
     9.1 --- a/tools/libxen/src/xen_vm.c	Wed Nov 29 12:43:11 2006 +0000
     9.2 +++ b/tools/libxen/src/xen_vm.c	Wed Nov 29 23:31:07 2006 +0000
     9.3 @@ -22,6 +22,7 @@
     9.4  
     9.5  #include "xen_boot_type_internal.h"
     9.6  #include "xen_common.h"
     9.7 +#include "xen_console.h"
     9.8  #include "xen_cpu_feature.h"
     9.9  #include "xen_cpu_feature_internal.h"
    9.10  #include "xen_host.h"
    9.11 @@ -120,6 +121,9 @@ static const struct_member xen_vm_record
    9.12          { .key = "actions_after_crash",
    9.13            .type = &xen_on_crash_behaviour_abstract_type_,
    9.14            .offset = offsetof(xen_vm_record, actions_after_crash) },
    9.15 +        { .key = "consoles",
    9.16 +          .type = &abstract_type_ref_set,
    9.17 +          .offset = offsetof(xen_vm_record, consoles) },
    9.18          { .key = "VIFs",
    9.19            .type = &abstract_type_ref_set,
    9.20            .offset = offsetof(xen_vm_record, vifs) },
    9.21 @@ -205,6 +209,7 @@ xen_vm_record_free(xen_vm_record *record
    9.22      xen_cpu_feature_set_free(record->vcpus_features_can_use);
    9.23      xen_cpu_feature_set_free(record->vcpus_features_force_on);
    9.24      xen_cpu_feature_set_free(record->vcpus_features_force_off);
    9.25 +    xen_console_record_opt_set_free(record->consoles);
    9.26      xen_vif_record_opt_set_free(record->vifs);
    9.27      xen_vbd_record_opt_set_free(record->vbds);
    9.28      xen_vtpm_record_opt_set_free(record->vtpms);
    9.29 @@ -694,6 +699,23 @@ xen_vm_get_actions_after_crash(xen_sessi
    9.30  
    9.31  
    9.32  bool
    9.33 +xen_vm_get_consoles(xen_session *session, struct xen_console_set **result, xen_vm vm)
    9.34 +{
    9.35 +    abstract_value param_values[] =
    9.36 +        {
    9.37 +            { .type = &abstract_type_string,
    9.38 +              .u.string_val = vm }
    9.39 +        };
    9.40 +
    9.41 +    abstract_type result_type = abstract_type_string_set;
    9.42 +
    9.43 +    *result = NULL;
    9.44 +    XEN_CALL_("VM.get_consoles");
    9.45 +    return session->ok;
    9.46 +}
    9.47 +
    9.48 +
    9.49 +bool
    9.50  xen_vm_get_vifs(xen_session *session, struct xen_vif_set **result, xen_vm vm)
    9.51  {
    9.52      abstract_value param_values[] =