VirtualBox

source: vbox/trunk/include/VBox/HostServices/GuestControlSvc.h@ 35517

Last change on this file since 35517 was 34556, checked in by vboxsync, 14 years ago

GuestControlSvc.h: a bit of doxygen, dropping leading underscores

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.8 KB
Line 
1/** @file
2 * Guest control service - Common header for host service and guest clients.
3 */
4
5/*
6 * Copyright (C) 2010 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef ___VBox_HostService_GuestControlService_h
27#define ___VBox_HostService_GuestControlService_h
28
29#include <VBox/types.h>
30#include <VBox/VMMDev.h>
31#include <VBox/VBoxGuest2.h>
32#include <VBox/hgcmsvc.h>
33#include <VBox/log.h>
34#include <iprt/assert.h>
35#include <iprt/string.h>
36
37/* Everything defined in this file lives in this namespace. */
38namespace guestControl {
39
40/******************************************************************************
41* Typedefs, constants and inlines *
42******************************************************************************/
43
44/**
45 * Process status when executed in the guest.
46 */
47enum eProcessStatus
48{
49 /** Process is in an undefined state. */
50 PROC_STS_UNDEFINED = 0,
51 /** Process has been started. */
52 PROC_STS_STARTED = 1,
53 /** Process terminated normally. */
54 PROC_STS_TEN = 2,
55 /** Process terminated via signal. */
56 PROC_STS_TES = 3,
57 /** Process terminated abnormally. */
58 PROC_STS_TEA = 4,
59 /** Process timed out and was killed. */
60 PROC_STS_TOK = 5,
61 /** Process timed out and was not killed successfully. */
62 PROC_STS_TOA = 6,
63 /** Service/OS is stopping, process was killed. */
64 PROC_STS_DWN = 7,
65 /** Something went wrong (error code in flags). */
66 PROC_STS_ERROR = 8
67};
68
69/**
70 * Input flags, set by the host. This is needed for
71 * handling flags on the guest side.
72 * Note: Has to match Main's ProcessInputFlag_* flags!
73 */
74#define INPUT_FLAG_NONE 0
75#define INPUT_FLAG_EOF RT_BIT(0)
76
77/** @name Internal tools built into VBoxService which are used in order to
78 * accomplish tasks host<->guest.
79 * @{
80 */
81#define VBOXSERVICE_TOOL_CAT "vbox_cat"
82#define VBOXSERVICE_TOOL_MKDIR "vbox_mkdir"
83/** @} */
84
85/**
86 * Input status, reported by the client.
87 */
88enum eInputStatus
89{
90 /** Input is in an undefined state. */
91 INPUT_STS_UNDEFINED = 0,
92 /** Input was written (partially, see cbProcessed). */
93 INPUT_STS_WRITTEN = 1,
94 /** Input failed with an error (see flags for rc). */
95 INPUT_STS_ERROR = 20,
96 /** Process has abandoned / terminated input handling. */
97 INPUT_STS_TERMINATED = 21,
98 /** Too much input data. */
99 INPUT_STS_OVERFLOW = 30
100};
101
102/**
103 * Document me.
104 */
105typedef struct VBoxGuestCtrlCallbackHeader
106{
107 /** Magic number to identify the structure. */
108 uint32_t u32Magic;
109 /** Context ID to identify callback data. */
110 uint32_t u32ContextID;
111} CALLBACKHEADER;
112typedef CALLBACKHEADER *PCALLBACKHEADER;
113
114/**
115 * Data structure to pass to the service extension callback. We use this to
116 * notify the host of changes to properties.
117 */
118typedef struct VBoxGuestCtrlCallbackDataExecStatus
119{
120 /** Callback data header. */
121 CALLBACKHEADER hdr;
122 /** The process ID (PID). */
123 uint32_t u32PID;
124 /** The process status. */
125 uint32_t u32Status;
126 /** Optional flags, varies, based on u32Status. */
127 uint32_t u32Flags;
128 /** Optional data buffer (not used atm). */
129 void *pvData;
130 /** Size of optional data buffer (not used atm). */
131 uint32_t cbData;
132} CALLBACKDATAEXECSTATUS;
133typedef CALLBACKDATAEXECSTATUS *PCALLBACKDATAEXECSTATUS;
134
135typedef struct VBoxGuestCtrlCallbackDataExecOut
136{
137 /** Callback data header. */
138 CALLBACKHEADER hdr;
139 /** The process ID (PID). */
140 uint32_t u32PID;
141 /** The handle ID (stdout/stderr). */
142 uint32_t u32HandleId;
143 /** Optional flags (not used atm). */
144 uint32_t u32Flags;
145 /** Optional data buffer. */
146 void *pvData;
147 /** Size (in bytes) of optional data buffer. */
148 uint32_t cbData;
149} CALLBACKDATAEXECOUT;
150typedef CALLBACKDATAEXECOUT *PCALLBACKDATAEXECOUT;
151
152typedef struct VBoxGuestCtrlCallbackDataExecInStatus
153{
154 /** Callback data header. */
155 CALLBACKHEADER hdr;
156 /** The process ID (PID). */
157 uint32_t u32PID;
158 /** Current input status. */
159 uint32_t u32Status;
160 /** Optional flags. */
161 uint32_t u32Flags;
162 /** Size (in bytes) of processed input data. */
163 uint32_t cbProcessed;
164} CALLBACKDATAEXECINSTATUS;
165typedef CALLBACKDATAEXECINSTATUS *PCALLBACKDATAEXECINSTATUS;
166
167typedef struct VBoxGuestCtrlCallbackDataClientDisconnected
168{
169 /** Callback data header. */
170 CALLBACKHEADER hdr;
171} CALLBACKDATACLIENTDISCONNECTED;
172typedef CALLBACKDATACLIENTDISCONNECTED *PCALLBACKDATACLIENTDISCONNECTED;
173
174enum
175{
176 /** Magic number for sanity checking the CALLBACKDATACLIENTDISCONNECTED structure. */
177 CALLBACKDATAMAGICCLIENTDISCONNECTED = 0x08041984,
178 /** Magic number for sanity checking the CALLBACKDATAEXECSTATUS structure. */
179 CALLBACKDATAMAGICEXECSTATUS = 0x26011982,
180 /** Magic number for sanity checking the CALLBACKDATAEXECOUT structure. */
181 CALLBACKDATAMAGICEXECOUT = 0x11061949,
182 /** Magic number for sanity checking the CALLBACKDATAEXECIN structure. */
183 CALLBACKDATAMAGICEXECINSTATUS = 0x19091951
184};
185
186enum eVBoxGuestCtrlCallbackType
187{
188 VBOXGUESTCTRLCALLBACKTYPE_UNKNOWN = 0,
189 VBOXGUESTCTRLCALLBACKTYPE_EXEC_START = 1,
190 VBOXGUESTCTRLCALLBACKTYPE_EXEC_OUTPUT = 2,
191 VBOXGUESTCTRLCALLBACKTYPE_EXEC_INPUT_STATUS = 3
192};
193
194/**
195 * The service functions which are callable by host.
196 */
197enum eHostFn
198{
199 /**
200 * The host asks the client to cancel all pending waits and exit.
201 */
202 HOST_CANCEL_PENDING_WAITS = 0,
203 /**
204 * The host wants to execute something in the guest. This can be a command line
205 * or starting a program.
206 */
207 HOST_EXEC_CMD = 100,
208 /**
209 * Sends input data for stdin to a running process executed by HOST_EXEC_CMD.
210 */
211 HOST_EXEC_SET_INPUT = 101,
212 /**
213 * Gets the current status of a running process, e.g.
214 * new data on stdout/stderr, process terminated etc.
215 */
216 HOST_EXEC_GET_OUTPUT = 102
217};
218
219/**
220 * The service functions which are called by guest. The numbers may not change,
221 * so we hardcode them.
222 */
223enum eGuestFn
224{
225 /**
226 * Guest waits for a new message the host wants to process on the guest side.
227 * This is a blocking call and can be deferred.
228 */
229 GUEST_GET_HOST_MSG = 1,
230 /**
231 * Guest asks the host to cancel all pending waits the guest itself waits on.
232 * This becomes necessary when the guest wants to quit but still waits for
233 * commands from the host.
234 */
235 GUEST_CANCEL_PENDING_WAITS = 2,
236 /**
237 * Guest disconnected (terminated normally or due to a crash HGCM
238 * detected when calling service::clientDisconnect().
239 */
240 GUEST_DISCONNECTED = 3,
241 /**
242 * Guests sends output from an executed process.
243 */
244 GUEST_EXEC_SEND_OUTPUT = 100,
245 /**
246 * Guest sends a status update of an executed process to the host.
247 */
248 GUEST_EXEC_SEND_STATUS = 101,
249 /**
250 * Guests sends an input status notification to the host.
251 */
252 GUEST_EXEC_SEND_INPUT_STATUS = 102
253};
254
255/*
256 * HGCM parameter structures.
257 */
258#pragma pack (1)
259
260typedef struct VBoxGuestCtrlHGCMMsgType
261{
262 VBoxGuestHGCMCallInfo hdr;
263
264 /**
265 * The returned command the host wants to
266 * run on the guest.
267 */
268 HGCMFunctionParameter msg; /* OUT uint32_t */
269 /** Number of parameters the message needs. */
270 HGCMFunctionParameter num_parms; /* OUT uint32_t */
271
272} VBoxGuestCtrlHGCMMsgType;
273
274/**
275 * Asks the guest control host service to cancel all pending (outstanding)
276 * waits which were not processed yet. This is handy for a graceful shutdown.
277 */
278typedef struct VBoxGuestCtrlHGCMMsgCancelPendingWaits
279{
280 VBoxGuestHGCMCallInfo hdr;
281} VBoxGuestCtrlHGCMMsgCancelPendingWaits;
282
283/**
284 * Executes a command inside the guest.
285 */
286typedef struct VBoxGuestCtrlHGCMMsgExecCmd
287{
288 VBoxGuestHGCMCallInfo hdr;
289 /** Context ID. */
290 HGCMFunctionParameter context;
291 /** The command to execute on the guest. */
292 HGCMFunctionParameter cmd;
293 /** Execution flags (see IGuest::ExecuteProcessFlag_*). */
294 HGCMFunctionParameter flags;
295 /** Number of arguments. */
296 HGCMFunctionParameter num_args;
297 /** The actual arguments. */
298 HGCMFunctionParameter args;
299 /** Number of environment value pairs. */
300 HGCMFunctionParameter num_env;
301 /** Size (in bytes) of environment block, including terminating zeros. */
302 HGCMFunctionParameter cb_env;
303 /** The actual environment block. */
304 HGCMFunctionParameter env;
305 /** The user name to run the executed command under. */
306 HGCMFunctionParameter username;
307 /** The user's password. */
308 HGCMFunctionParameter password;
309 /** Timeout (in msec) which either specifies the
310 * overall lifetime of the process or how long it
311 * can take to bring the process up and running -
312 * (depends on the IGuest::ExecuteProcessFlag_*). */
313 HGCMFunctionParameter timeout;
314
315} VBoxGuestCtrlHGCMMsgExecCmd;
316
317/**
318 * Injects input to a previously executed process via stdin.
319 */
320typedef struct VBoxGuestCtrlHGCMMsgExecIn
321{
322 VBoxGuestHGCMCallInfo hdr;
323 /** Context ID. */
324 HGCMFunctionParameter context;
325 /** The process ID (PID) to send the input to. */
326 HGCMFunctionParameter pid;
327 /** Input flags (see IGuest::ProcessInputFlag_*). */
328 HGCMFunctionParameter flags;
329 /** Data buffer. */
330 HGCMFunctionParameter data;
331 /** Actual size of data (in bytes). */
332 HGCMFunctionParameter size;
333
334} VBoxGuestCtrlHGCMMsgExecIn;
335
336typedef struct VBoxGuestCtrlHGCMMsgExecOut
337{
338 VBoxGuestHGCMCallInfo hdr;
339 /** Context ID. */
340 HGCMFunctionParameter context;
341 /** The process ID (PID). */
342 HGCMFunctionParameter pid;
343 /** The pipe handle ID (stdout/stderr). */
344 HGCMFunctionParameter handle;
345 /** Optional flags. */
346 HGCMFunctionParameter flags;
347 /** Data buffer. */
348 HGCMFunctionParameter data;
349
350} VBoxGuestCtrlHGCMMsgExecOut;
351
352typedef struct VBoxGuestCtrlHGCMMsgExecStatus
353{
354 VBoxGuestHGCMCallInfo hdr;
355 /** Context ID. */
356 HGCMFunctionParameter context;
357 /** The process ID (PID). */
358 HGCMFunctionParameter pid;
359 /** The process status. */
360 HGCMFunctionParameter status;
361 /** Optional flags (based on status). */
362 HGCMFunctionParameter flags;
363 /** Optional data buffer (not used atm). */
364 HGCMFunctionParameter data;
365
366} VBoxGuestCtrlHGCMMsgExecStatus;
367
368typedef struct VBoxGuestCtrlHGCMMsgExecStatusIn
369{
370 VBoxGuestHGCMCallInfo hdr;
371 /** Context ID. */
372 HGCMFunctionParameter context;
373 /** The process ID (PID). */
374 HGCMFunctionParameter pid;
375 /** Status of the operation. */
376 HGCMFunctionParameter status;
377 /** Optional flags. */
378 HGCMFunctionParameter flags;
379 /** Data written. */
380 HGCMFunctionParameter written;
381
382} VBoxGuestCtrlHGCMMsgExecStatusIn;
383
384#pragma pack ()
385
386/**
387 * Structure for buffering execution requests in the host service.
388 */
389typedef struct VBoxGuestCtrlParamBuffer
390{
391 uint32_t uMsg;
392 uint32_t uParmCount;
393 VBOXHGCMSVCPARM *pParms;
394} VBOXGUESTCTRPARAMBUFFER;
395typedef VBOXGUESTCTRPARAMBUFFER *PVBOXGUESTCTRPARAMBUFFER;
396
397} /* namespace guestControl */
398
399#endif /* !___VBox_HostService_GuestControlService_h */
400
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette