VirtualBox

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

最後變更 在這個檔案從28887是 28887,由 vboxsync 提交於 15 年 前

Guest Control/Main: Faster (no polling on guest side), free data on shutdown.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 7.7 KB
 
1/** @file
2 * Guest control service:
3 * Common header for host service and guest clients.
4 */
5
6/*
7 * Copyright (C) 2010 Oracle Corporation
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
27#ifndef ___VBox_HostService_GuestControlService_h
28#define ___VBox_HostService_GuestControlService_h
29
30#include <VBox/types.h>
31#include <VBox/VMMDev.h>
32#include <VBox/VBoxGuest2.h>
33#include <VBox/hgcmsvc.h>
34#include <VBox/log.h>
35#include <iprt/assert.h>
36#include <iprt/string.h>
37
38/** Everything defined in this file lives in this namespace. */
39namespace guestControl {
40
41/******************************************************************************
42* Typedefs, constants and inlines *
43******************************************************************************/
44
45/**
46 * Process status when executed in the guest.
47 */
48enum eProcessStatus
49{
50 /** Process is in an undefined state. */
51 PROC_STS_UNDEFINED = 0,
52 /** Process has been started. */
53 PROC_STS_STARTED = 1,
54 /** Process terminated normally. */
55 PROC_STS_TEN = 2,
56 /** Process terminated via signal. */
57 PROC_STS_TES = 3,
58 /** Process terminated abnormally. */
59 PROC_STS_TEA = 4,
60 /** Process timed out and was killed. */
61 PROC_STS_TOK = 5,
62 /** Process timed out and was not killed successfully. */
63 PROC_STS_TOA = 6,
64 /** Service is stopping, process was killed. */
65 PROC_STS_DWN = 7,
66 /** Something went wrong (error code in flags). */
67 PROC_STS_ERROR = 8
68};
69
70typedef struct _VBoxGuestCtrlCallbackHeader
71{
72 /** Magic number to identify the structure. */
73 uint32_t u32Magic;
74 /** Context ID to identify callback data. */
75 uint32_t u32ContextID;
76} HOSTCCALLBACKHEADER, *PHOSTCCALLBACKHEADER;
77
78/**
79 * Data structure to pass to the service extension callback. We use this to
80 * notify the host of changes to properties.
81 */
82typedef struct _VBoxGuestCtrlExecCallbackData
83{
84 /** Callback data header. */
85 HOSTCCALLBACKHEADER hdr;
86 /** The process ID (PID). */
87 uint32_t u32PID;
88 /* The process status. */
89 uint32_t u32Status;
90 /** Optional flags (not used atm). */
91 uint32_t u32Flags;
92 /** Optional data buffer (not used atm). */
93 void *pvData;
94 /** Size of optional data buffer (not used atm). */
95 uint32_t cbData;
96} HOSTEXECCALLBACKDATA, *PHOSTEXECCALLBACKDATA;
97
98typedef struct _VBoxGuestCtrlExecOutCallbackData
99{
100 /** Callback data header. */
101 HOSTCCALLBACKHEADER hdr;
102 /** The process ID (PID). */
103 uint32_t u32PID;
104 /* The handle ID (stdout/stderr). */
105 uint32_t u32HandleId;
106 /** Optional flags (not used atm). */
107 uint32_t u32Flags;
108 /** Optional data buffer. */
109 void *pvData;
110 /** Size of optional data buffer. */
111 uint32_t cbData;
112} HOSTEXECOUTCALLBACKDATA, *PHOSTEXECOUTCALLBACKDATA;
113
114enum
115{
116 /** Magic number for sanity checking the HOSTEXECCALLBACKDATA structure. */
117 HOSTEXECCALLBACKDATAMAGIC = 0x26011982,
118 /** Magic number for sanity checking the HOSTEXECOUTCALLBACKDATA structure. */
119 HOSTEXECOUTCALLBACKDATAMAGIC = 0x11061949
120};
121
122enum eVBoxGuestCtrlCallbackType
123{
124 VBOXGUESTCTRLCALLBACKTYPE_UNKNOWN = 0,
125 VBOXGUESTCTRLCALLBACKTYPE_EXEC_START = 1,
126 VBOXGUESTCTRLCALLBACKTYPE_EXEC_OUTPUT = 2
127};
128
129/**
130 * The service functions which are callable by host.
131 */
132enum eHostFn
133{
134 /**
135 * The host wants to execute something in the guest. This can be a command line
136 * or starting a program.
137 */
138 HOST_EXEC_CMD = 1,
139 /**
140 * Sends input data for stdin to a running process executed by HOST_EXEC_CMD.
141 */
142 HOST_EXEC_SET_INPUT = 2,
143 /**
144 * Gets the current status of a running process, e.g.
145 * new data on stdout/stderr, process terminated etc.
146 */
147 HOST_EXEC_GET_OUTPUT = 3
148};
149
150/**
151 * The service functions which are called by guest. The numbers may not change,
152 * so we hardcode them.
153 */
154enum eGuestFn
155{
156 /**
157 * TODO
158 */
159 GUEST_GET_HOST_MSG = 1,
160 /**
161 * TODO
162 */
163 GUEST_EXEC_SEND_OUTPUT = 2,
164 /**
165 * TODO
166 */
167 GUEST_EXEC_SEND_STATUS = 3
168};
169
170/**
171 * Sub host commands. These commands are stored as first (=0) parameter in a GUEST_GET_HOST_MSG
172 * so that the guest can react dynamically to requests from the host.
173 */
174enum eGetHostMsgFn
175{
176 /**
177 * The host wants to execute something in the guest. This can be a command line
178 * or starting a program.
179 */
180 GETHOSTMSG_EXEC_START_PROCESS = 1,
181 /**
182 * Sends input data for stdin to a running process executed by HOST_EXEC_CMD.
183 */
184 GETHOSTMSG_EXEC_SEND_INPUT = 2,
185 /**
186 * Host requests the so far collected stdout/stderr output
187 * from a running process executed by HOST_EXEC_CMD.
188 */
189 GETHOSTMSG_EXEC_GET_OUTPUT = 3
190};
191
192/*
193 * HGCM parameter structures.
194 */
195#pragma pack (1)
196typedef struct _VBoxGuestCtrlHGCMMsgType
197{
198 VBoxGuestHGCMCallInfo hdr;
199
200 /**
201 * The returned command the host wants to
202 * execute on the guest.
203 */
204 HGCMFunctionParameter msg; /* OUT uint32_t */
205
206 HGCMFunctionParameter num_parms; /* OUT uint32_t */
207
208} VBoxGuestCtrlHGCMMsgType;
209
210typedef struct _VBoxGuestCtrlHGCMMsgExecCmd
211{
212 VBoxGuestHGCMCallInfo hdr;
213
214 HGCMFunctionParameter context;
215
216 HGCMFunctionParameter cmd;
217
218 HGCMFunctionParameter flags;
219
220 HGCMFunctionParameter num_args;
221
222 HGCMFunctionParameter args;
223
224 HGCMFunctionParameter num_env;
225 /** Size (in bytes) of environment block, including terminating zeros. */
226 HGCMFunctionParameter cb_env;
227
228 HGCMFunctionParameter env;
229
230 HGCMFunctionParameter std_in;
231
232 HGCMFunctionParameter std_out;
233
234 HGCMFunctionParameter std_err;
235
236 HGCMFunctionParameter username;
237
238 HGCMFunctionParameter password;
239
240 HGCMFunctionParameter timeout;
241
242} VBoxGuestCtrlHGCMMsgExecCmd;
243
244typedef struct _VBoxGuestCtrlHGCMMsgExecOut
245{
246 VBoxGuestHGCMCallInfo hdr;
247 /** Context ID. */
248 HGCMFunctionParameter context;
249 /** The process ID (PID). */
250 HGCMFunctionParameter pid;
251 /** The pipe handle ID. */
252 HGCMFunctionParameter handle;
253 /** Optional flags. */
254 HGCMFunctionParameter flags;
255 /** Data buffer. */
256 HGCMFunctionParameter data;
257
258} VBoxGuestCtrlHGCMMsgExecOut;
259
260typedef struct _VBoxGuestCtrlHGCMMsgExecStatus
261{
262 VBoxGuestHGCMCallInfo hdr;
263 /** Context ID. */
264 HGCMFunctionParameter context;
265 /** The process ID (PID). */
266 HGCMFunctionParameter pid;
267 /** The process status. */
268 HGCMFunctionParameter status;
269 /** Optional flags (based on status). */
270 HGCMFunctionParameter flags;
271 /** Optional data buffer (not used atm). */
272 HGCMFunctionParameter data;
273
274} VBoxGuestCtrlHGCMMsgExecStatus;
275#pragma pack ()
276
277/* Structure for buffering execution requests in the host service. */
278typedef struct _VBoxGuestCtrlParamBuffer
279{
280 uint32_t uMsg;
281 uint32_t uParmCount;
282 VBOXHGCMSVCPARM *pParms;
283} VBOXGUESTCTRPARAMBUFFER, *PVBOXGUESTCTRPARAMBUFFER;
284
285} /* namespace guestControl */
286
287#endif /* ___VBox_HostService_GuestControlService_h defined */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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