VirtualBox

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

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

Guest Control: Update (callback + error handling, --verbose for VBoxManage).

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 6.3 KB
 
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. */
43namespace guestControl {
44
45/******************************************************************************
46* Typedefs, constants and inlines *
47******************************************************************************/
48
49/**
50 * Process status when executed in the guest.
51 */
52enum 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 /** @todo */
69 PROC_STS_DWN = 7,
70 /** Something went wrong (error code in flags). */
71 PROC_STS_ERROR = 8
72};
73
74/**
75 * Data structure to pass to the service extension callback. We use this to
76 * notify the host of changes to properties.
77 */
78typedef struct _VBoxGuestCtrlExecCallbackData
79{
80 /** Magic number to identify the structure. */
81 uint32_t u32Magic;
82 /** The process ID (PID). */
83 uint32_t pid;
84 /* The process status. */
85 uint32_t status;
86 /** Optional flags (not used atm). */
87 uint32_t flags;
88 /** Optional data buffer (not used atm). */
89 void *pvData;
90 /** Size of optional data buffer (not used atm). */
91 uint32_t cbData;
92 /** Atomic flags whether callback was called. */
93 bool called;
94
95} HOSTEXECCALLBACKDATA, *PHOSTEXECCALLBACKDATA;
96
97enum
98{
99 /** Magic number for sanity checking the HOSTCALLBACKDATA structure */
100 HOSTCALLBACKMAGIC = 0x26011982
101};
102
103/**
104 * The service functions which are callable by host.
105 */
106enum eHostFn
107{
108 /**
109 * The host wants to execute something in the guest. This can be a command line
110 * or starting a program.
111 */
112 HOST_EXEC_CMD = 1,
113 /**
114 * Sends input data for stdin to a running process executed by HOST_EXEC_CMD.
115 */
116 HOST_EXEC_SEND_STDIN = 2,
117 /**
118 * Gets the current status of a running process, e.g.
119 * new data on stdout/stderr, process terminated etc.
120 */
121 HOST_EXEC_GET_STATUS = 3
122};
123
124/**
125 * The service functions which are called by guest. The numbers may not change,
126 * so we hardcode them.
127 */
128enum eGuestFn
129{
130 /**
131 * TODO
132 */
133 GUEST_GET_HOST_MSG = 1,
134 /**
135 * TODO
136 */
137 GUEST_EXEC_SEND_STDOUT = 3,
138 /**
139 * TODO
140 */
141 GUEST_EXEC_SEND_STDERR = 4,
142 /**
143 * TODO
144 */
145 GUEST_EXEC_SEND_STATUS = 5
146};
147
148/**
149 * Sub host commands. These commands are stored as first (=0) parameter in a GUEST_GET_HOST_MSG
150 * so that the guest can react dynamically to requests from the host.
151 */
152enum eGetHostMsgFn
153{
154 /**
155 * The host wants to execute something in the guest. This can be a command line
156 * or starting a program.
157 */
158 GETHOSTMSG_EXEC_CMD = 1,
159 /**
160 * Sends input data for stdin to a running process executed by HOST_EXEC_CMD.
161 */
162 GETHOSTMSG_EXEC_STDIN = 2
163};
164
165/*
166 * HGCM parameter structures.
167 */
168#pragma pack (1)
169typedef struct _VBoxGuestCtrlHGCMMsgType
170{
171 VBoxGuestHGCMCallInfo hdr;
172
173 /**
174 * The returned command the host wants to
175 * execute on the guest.
176 */
177 HGCMFunctionParameter msg; /* OUT uint32_t */
178
179 HGCMFunctionParameter num_parms; /* OUT uint32_t */
180
181} VBoxGuestCtrlHGCMMsgType;
182
183typedef struct _VBoxGuestCtrlHGCMMsgExecCmd
184{
185 VBoxGuestHGCMCallInfo hdr;
186
187 HGCMFunctionParameter cmd;
188
189 HGCMFunctionParameter flags;
190
191 HGCMFunctionParameter num_args;
192
193 HGCMFunctionParameter args;
194
195 HGCMFunctionParameter num_env;
196 /** Size (in bytes) of environment block, including terminating zeros. */
197 HGCMFunctionParameter cb_env;
198
199 HGCMFunctionParameter env;
200
201 HGCMFunctionParameter std_in;
202
203 HGCMFunctionParameter std_out;
204
205 HGCMFunctionParameter std_err;
206
207 HGCMFunctionParameter username;
208
209 HGCMFunctionParameter password;
210
211 HGCMFunctionParameter timeout;
212
213} VBoxGuestCtrlHGCMMsgExecCmd;
214
215typedef struct _VBoxGuestCtrlHGCMMsgExecStatus
216{
217 VBoxGuestHGCMCallInfo hdr;
218 /** The process ID (PID). */
219 HGCMFunctionParameter pid;
220 /** The process status. */
221 HGCMFunctionParameter status;
222 /** Optional flags (based on status). */
223 HGCMFunctionParameter flags;
224 /** Optional data buffer (not used atm). */
225 HGCMFunctionParameter data;
226
227} VBoxGuestCtrlHGCMMsgExecStatus;
228#pragma pack ()
229
230/* Structure for buffering execution requests in the host service. */
231typedef struct _VBoxGuestCtrlParamBuffer
232{
233 uint32_t uParmCount;
234 VBOXHGCMSVCPARM *pParms;
235} VBOXGUESTCTRPARAMBUFFER, *PVBOXGUESTCTRPARAMBUFFER;
236
237} /* namespace guestControl */
238
239#endif /* ___VBox_HostService_GuestControlService_h defined */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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