1 | /** @file
|
---|
2 | * Guest control service:
|
---|
3 | * Common header for host service and guest clients.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2010 Sun Microsystems, Inc.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.alldomusa.eu.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | *
|
---|
26 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
27 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
28 | * additional information or have any questions.
|
---|
29 | */
|
---|
30 |
|
---|
31 | #ifndef ___VBox_HostService_GuestControlService_h
|
---|
32 | #define ___VBox_HostService_GuestControlService_h
|
---|
33 |
|
---|
34 | #include <VBox/types.h>
|
---|
35 | #include <VBox/VMMDev.h>
|
---|
36 | #include <VBox/VBoxGuest2.h>
|
---|
37 | #include <VBox/hgcmsvc.h>
|
---|
38 | #include <VBox/log.h>
|
---|
39 | #include <iprt/assert.h>
|
---|
40 | #include <iprt/string.h>
|
---|
41 |
|
---|
42 | /** Everything defined in this file lives in this namespace. */
|
---|
43 | namespace guestControl {
|
---|
44 |
|
---|
45 | /******************************************************************************
|
---|
46 | * Typedefs, constants and inlines *
|
---|
47 | ******************************************************************************/
|
---|
48 |
|
---|
49 | /**
|
---|
50 | * Process status when executed in the guest.
|
---|
51 | */
|
---|
52 | enum eProcessStatus
|
---|
53 | {
|
---|
54 | /** Process is in an undefined state. */
|
---|
55 | PROC_STS_UNDEFINED = 0,
|
---|
56 | /** Process has been started. */
|
---|
57 | PROC_STS_STARTED = 1,
|
---|
58 | /** Process terminated normally. */
|
---|
59 | PROC_STS_TEN = 2,
|
---|
60 | /** Process terminated via signal. */
|
---|
61 | PROC_STS_TES = 3,
|
---|
62 | /** Process terminated abnormally. */
|
---|
63 | PROC_STS_TEA = 4,
|
---|
64 | /** Process timed out and was killed. */
|
---|
65 | PROC_STS_TOK = 5,
|
---|
66 | /** Process timed out and was not killed successfully. */
|
---|
67 | PROC_STS_TOA = 6,
|
---|
68 | /** Service is stopping, process was killed. */
|
---|
69 | PROC_STS_DWN = 7,
|
---|
70 | /** Something went wrong (error code in flags). */
|
---|
71 | PROC_STS_ERROR = 8
|
---|
72 | };
|
---|
73 |
|
---|
74 | typedef struct _VBoxGuestCtrlCallbackHeader
|
---|
75 | {
|
---|
76 | /** Magic number to identify the structure. */
|
---|
77 | uint32_t u32Magic;
|
---|
78 | /** Context ID to identify callback data. */
|
---|
79 | uint32_t u32ContextID;
|
---|
80 | } HOSTCCALLBACKHEADER, *PHOSTCCALLBACKHEADER;
|
---|
81 |
|
---|
82 | /**
|
---|
83 | * Data structure to pass to the service extension callback. We use this to
|
---|
84 | * notify the host of changes to properties.
|
---|
85 | */
|
---|
86 | typedef struct _VBoxGuestCtrlExecCallbackData
|
---|
87 | {
|
---|
88 | /** Callback data header. */
|
---|
89 | HOSTCCALLBACKHEADER hdr;
|
---|
90 | /** The process ID (PID). */
|
---|
91 | uint32_t u32PID;
|
---|
92 | /* The process status. */
|
---|
93 | uint32_t u32Status;
|
---|
94 | /** Optional flags (not used atm). */
|
---|
95 | uint32_t u32Flags;
|
---|
96 | /** Optional data buffer (not used atm). */
|
---|
97 | void *pvData;
|
---|
98 | /** Size of optional data buffer (not used atm). */
|
---|
99 | uint32_t cbData;
|
---|
100 | } HOSTEXECCALLBACKDATA, *PHOSTEXECCALLBACKDATA;
|
---|
101 |
|
---|
102 | typedef struct _VBoxGuestCtrlExecOutCallbackData
|
---|
103 | {
|
---|
104 | /** Callback data header. */
|
---|
105 | HOSTCCALLBACKHEADER hdr;
|
---|
106 | /** The process ID (PID). */
|
---|
107 | uint32_t u32PID;
|
---|
108 | /* The handle ID (stdout/stderr). */
|
---|
109 | uint32_t u32HandleId;
|
---|
110 | /** Optional flags (not used atm). */
|
---|
111 | uint32_t u32Flags;
|
---|
112 | /** Optional data buffer. */
|
---|
113 | void *pvData;
|
---|
114 | /** Size of optional data buffer. */
|
---|
115 | uint32_t cbData;
|
---|
116 | } HOSTEXECOUTCALLBACKDATA, *PHOSTEXECOUTCALLBACKDATA;
|
---|
117 |
|
---|
118 | enum
|
---|
119 | {
|
---|
120 | /** Magic number for sanity checking the HOSTEXECCALLBACKDATA structure. */
|
---|
121 | HOSTEXECCALLBACKDATAMAGIC = 0x26011982,
|
---|
122 | /** Magic number for sanity checking the HOSTEXECOUTCALLBACKDATA structure. */
|
---|
123 | HOSTEXECOUTCALLBACKDATAMAGIC = 0x11061949
|
---|
124 | };
|
---|
125 |
|
---|
126 | /**
|
---|
127 | * The service functions which are callable by host.
|
---|
128 | */
|
---|
129 | enum eHostFn
|
---|
130 | {
|
---|
131 | /**
|
---|
132 | * The host wants to execute something in the guest. This can be a command line
|
---|
133 | * or starting a program.
|
---|
134 | */
|
---|
135 | HOST_EXEC_CMD = 1,
|
---|
136 | /**
|
---|
137 | * Sends input data for stdin to a running process executed by HOST_EXEC_CMD.
|
---|
138 | */
|
---|
139 | HOST_EXEC_SET_INPUT = 2,
|
---|
140 | /**
|
---|
141 | * Gets the current status of a running process, e.g.
|
---|
142 | * new data on stdout/stderr, process terminated etc.
|
---|
143 | */
|
---|
144 | HOST_EXEC_GET_OUTPUT = 3
|
---|
145 | };
|
---|
146 |
|
---|
147 | /**
|
---|
148 | * The service functions which are called by guest. The numbers may not change,
|
---|
149 | * so we hardcode them.
|
---|
150 | */
|
---|
151 | enum eGuestFn
|
---|
152 | {
|
---|
153 | /**
|
---|
154 | * TODO
|
---|
155 | */
|
---|
156 | GUEST_GET_HOST_MSG = 1,
|
---|
157 | /**
|
---|
158 | * TODO
|
---|
159 | */
|
---|
160 | GUEST_EXEC_SEND_OUTPUT = 2,
|
---|
161 | /**
|
---|
162 | * TODO
|
---|
163 | */
|
---|
164 | GUEST_EXEC_SEND_STATUS = 3
|
---|
165 | };
|
---|
166 |
|
---|
167 | /**
|
---|
168 | * Sub host commands. These commands are stored as first (=0) parameter in a GUEST_GET_HOST_MSG
|
---|
169 | * so that the guest can react dynamically to requests from the host.
|
---|
170 | */
|
---|
171 | enum eGetHostMsgFn
|
---|
172 | {
|
---|
173 | /**
|
---|
174 | * The host wants to execute something in the guest. This can be a command line
|
---|
175 | * or starting a program.
|
---|
176 | */
|
---|
177 | GETHOSTMSG_EXEC_START_PROCESS = 1,
|
---|
178 | /**
|
---|
179 | * Sends input data for stdin to a running process executed by HOST_EXEC_CMD.
|
---|
180 | */
|
---|
181 | GETHOSTMSG_EXEC_SEND_INPUT = 2,
|
---|
182 | /**
|
---|
183 | * Host requests the so far collected stdout/stderr output
|
---|
184 | * from a running process executed by HOST_EXEC_CMD.
|
---|
185 | */
|
---|
186 | GETHOSTMSG_EXEC_GET_OUTPUT = 3
|
---|
187 | };
|
---|
188 |
|
---|
189 | /*
|
---|
190 | * HGCM parameter structures.
|
---|
191 | */
|
---|
192 | #pragma pack (1)
|
---|
193 | typedef struct _VBoxGuestCtrlHGCMMsgType
|
---|
194 | {
|
---|
195 | VBoxGuestHGCMCallInfoTimed hdr;
|
---|
196 |
|
---|
197 | /**
|
---|
198 | * The returned command the host wants to
|
---|
199 | * execute on the guest.
|
---|
200 | */
|
---|
201 | HGCMFunctionParameter msg; /* OUT uint32_t */
|
---|
202 |
|
---|
203 | HGCMFunctionParameter num_parms; /* OUT uint32_t */
|
---|
204 |
|
---|
205 | } VBoxGuestCtrlHGCMMsgType;
|
---|
206 |
|
---|
207 | typedef struct _VBoxGuestCtrlHGCMMsgExecCmd
|
---|
208 | {
|
---|
209 | VBoxGuestHGCMCallInfo hdr;
|
---|
210 |
|
---|
211 | HGCMFunctionParameter context;
|
---|
212 |
|
---|
213 | HGCMFunctionParameter cmd;
|
---|
214 |
|
---|
215 | HGCMFunctionParameter flags;
|
---|
216 |
|
---|
217 | HGCMFunctionParameter num_args;
|
---|
218 |
|
---|
219 | HGCMFunctionParameter args;
|
---|
220 |
|
---|
221 | HGCMFunctionParameter num_env;
|
---|
222 | /** Size (in bytes) of environment block, including terminating zeros. */
|
---|
223 | HGCMFunctionParameter cb_env;
|
---|
224 |
|
---|
225 | HGCMFunctionParameter env;
|
---|
226 |
|
---|
227 | HGCMFunctionParameter std_in;
|
---|
228 |
|
---|
229 | HGCMFunctionParameter std_out;
|
---|
230 |
|
---|
231 | HGCMFunctionParameter std_err;
|
---|
232 |
|
---|
233 | HGCMFunctionParameter username;
|
---|
234 |
|
---|
235 | HGCMFunctionParameter password;
|
---|
236 |
|
---|
237 | HGCMFunctionParameter timeout;
|
---|
238 |
|
---|
239 | } VBoxGuestCtrlHGCMMsgExecCmd;
|
---|
240 |
|
---|
241 | typedef struct _VBoxGuestCtrlHGCMMsgExecOut
|
---|
242 | {
|
---|
243 | VBoxGuestHGCMCallInfo hdr;
|
---|
244 | /** Context ID. */
|
---|
245 | HGCMFunctionParameter context;
|
---|
246 | /** The process ID (PID). */
|
---|
247 | HGCMFunctionParameter pid;
|
---|
248 | /** The pipe handle ID. */
|
---|
249 | HGCMFunctionParameter handle;
|
---|
250 | /** Optional flags. */
|
---|
251 | HGCMFunctionParameter flags;
|
---|
252 | /** Data buffer. */
|
---|
253 | HGCMFunctionParameter data;
|
---|
254 |
|
---|
255 | } VBoxGuestCtrlHGCMMsgExecOut;
|
---|
256 |
|
---|
257 | typedef struct _VBoxGuestCtrlHGCMMsgExecStatus
|
---|
258 | {
|
---|
259 | VBoxGuestHGCMCallInfo hdr;
|
---|
260 | /** Context ID. */
|
---|
261 | HGCMFunctionParameter context;
|
---|
262 | /** The process ID (PID). */
|
---|
263 | HGCMFunctionParameter pid;
|
---|
264 | /** The process status. */
|
---|
265 | HGCMFunctionParameter status;
|
---|
266 | /** Optional flags (based on status). */
|
---|
267 | HGCMFunctionParameter flags;
|
---|
268 | /** Optional data buffer (not used atm). */
|
---|
269 | HGCMFunctionParameter data;
|
---|
270 |
|
---|
271 | } VBoxGuestCtrlHGCMMsgExecStatus;
|
---|
272 | #pragma pack ()
|
---|
273 |
|
---|
274 | /* Structure for buffering execution requests in the host service. */
|
---|
275 | typedef struct _VBoxGuestCtrlParamBuffer
|
---|
276 | {
|
---|
277 | uint32_t uMsg;
|
---|
278 | uint32_t uParmCount;
|
---|
279 | VBOXHGCMSVCPARM *pParms;
|
---|
280 | } VBOXGUESTCTRPARAMBUFFER, *PVBOXGUESTCTRPARAMBUFFER;
|
---|
281 |
|
---|
282 | } /* namespace guestControl */
|
---|
283 |
|
---|
284 | #endif /* ___VBox_HostService_GuestControlService_h defined */
|
---|