VirtualBox

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

Last change on this file since 55466 was 49349, checked in by vboxsync, 11 years ago

Guest Control:

  • Implemented IGuestSession::DirectoryRemove, IGuestSession::DirectoryRemoveRecursive, IGuestSession::DirectoryRename + IGuestSession::FileRename.
  • Added appropriate commands to VBoxManage (basic support for now).
  • Implemented support for proper guest session process termination via SCM.
  • Implemented support for internal anonymous wait events which are not relying on the public API's VBoxEventType_T.
  • Various bugfixes.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 34.1 KB
Line 
1/** @file
2 * Guest control service - Common header for host service and guest clients.
3 */
4
5/*
6 * Copyright (C) 2011-2013 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#define HGCMSERVICE_NAME "VBoxGuestControlSvc"
45
46/** Maximum number of concurrent guest sessions a VM can have. */
47#define VBOX_GUESTCTRL_MAX_SESSIONS 32
48/** Maximum number of concurrent guest objects (processes, files, ...)
49 * a guest session can have. */
50#define VBOX_GUESTCTRL_MAX_OBJECTS _2K
51/** Maximum of callback contexts a guest process can have. */
52#define VBOX_GUESTCTRL_MAX_CONTEXTS _64K
53
54/** Base (start) of guest control session IDs. Session
55 * ID 0 is reserved for the root process which
56 * hosts all other guest session processes. */
57#define VBOX_GUESTCTRL_SESSION_ID_BASE 1
58
59/** Builds a context ID out of the session ID, object ID and an
60 * increasing count. */
61#define VBOX_GUESTCTRL_CONTEXTID_MAKE(uSession, uObject, uCount) \
62 ( (uint32_t)((uSession) & 0x1f) << 27 \
63 | (uint32_t)((uObject) & 0x7ff) << 16 \
64 | (uint32_t)((uCount) & 0xffff) \
65 )
66/** Creates a context ID out of a session ID. */
67#define VBOX_GUESTCTRL_CONTEXTID_MAKE_SESSION(uSession) \
68 ((uint32_t)((uSession) & 0x1f) << 27)
69/** Gets the session ID out of a context ID. */
70#define VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(uContextID) \
71 (((uContextID) >> 27) & 0x1f)
72/** Gets the process ID out of a context ID. */
73#define VBOX_GUESTCTRL_CONTEXTID_GET_OBJECT(uContextID) \
74 (((uContextID) >> 16) & 0x7ff)
75/** Gets the context count of a process out of a context ID. */
76#define VBOX_GUESTCTRL_CONTEXTID_GET_COUNT(uContextID) \
77 ((uContextID) & 0xffff)
78/** Filter context IDs by session. Can be used in conjunction
79 * with VbglR3GuestCtrlMsgFilterSet(). */
80#define VBOX_GUESTCTRL_FILTER_BY_SESSION(uSession) \
81 (VBOX_GUESTCTRL_CONTEXTID_MAKE_SESSION(uSession) | 0xF8000000)
82
83/**
84 * Process status when executed in the guest.
85 */
86enum eProcessStatus
87{
88 /** Process is in an undefined state. */
89 PROC_STS_UNDEFINED = 0,
90 /** Process has been started. */
91 PROC_STS_STARTED = 1,
92 /** Process terminated normally. */
93 PROC_STS_TEN = 2,
94 /** Process terminated via signal. */
95 PROC_STS_TES = 3,
96 /** Process terminated abnormally. */
97 PROC_STS_TEA = 4,
98 /** Process timed out and was killed. */
99 PROC_STS_TOK = 5,
100 /** Process timed out and was not killed successfully. */
101 PROC_STS_TOA = 6,
102 /** Service/OS is stopping, process was killed. */
103 PROC_STS_DWN = 7,
104 /** Something went wrong (error code in flags). */
105 PROC_STS_ERROR = 8
106};
107
108/**
109 * Input flags, set by the host. This is needed for
110 * handling flags on the guest side.
111 * Note: Has to match Main's ProcessInputFlag_* flags!
112 */
113#define INPUT_FLAG_NONE 0x0
114#define INPUT_FLAG_EOF RT_BIT(0)
115
116/**
117 * Guest session creation flags.
118 * Only handled internally at the moment.
119 */
120#define SESSIONCREATIONFLAG_NONE 0x0
121
122/**
123 * Guest directory removement flags.
124 * Essentially using what IPRT's RTDIRRMREC_F_
125 * defines have to offer.
126 */
127#define DIRREMOVE_FLAG_RECURSIVE RT_BIT(0)
128/** Delete the content of the directory and the directory itself. */
129#define DIRREMOVE_FLAG_CONTENT_AND_DIR RT_BIT(1)
130/** Only delete the content of the directory, omit the directory it self. */
131#define DIRREMOVE_FLAG_CONTENT_ONLY RT_BIT(2)
132/** Mask of valid flags. */
133#define DIRREMOVE_FLAG_VALID_MASK UINT32_C(0x00000003)
134
135/**
136 * Guest process creation flags.
137 * Note: Has to match Main's ProcessCreateFlag_* flags!
138 */
139#define EXECUTEPROCESSFLAG_NONE 0x0
140#define EXECUTEPROCESSFLAG_WAIT_START RT_BIT(0)
141#define EXECUTEPROCESSFLAG_IGNORE_ORPHANED RT_BIT(1)
142#define EXECUTEPROCESSFLAG_HIDDEN RT_BIT(2)
143#define EXECUTEPROCESSFLAG_NO_PROFILE RT_BIT(3)
144#define EXECUTEPROCESSFLAG_WAIT_STDOUT RT_BIT(4)
145#define EXECUTEPROCESSFLAG_WAIT_STDERR RT_BIT(5)
146#define EXECUTEPROCESSFLAG_EXPAND_ARGUMENTS RT_BIT(6)
147
148/**
149 * Pipe handle IDs used internally for referencing to
150 * a certain pipe buffer.
151 */
152#define OUTPUT_HANDLE_ID_STDOUT_DEPRECATED 0 /* Needed for VBox hosts < 4.1.0. */
153#define OUTPUT_HANDLE_ID_STDOUT 1
154#define OUTPUT_HANDLE_ID_STDERR 2
155
156/**
157 * Guest path rename flags.
158 * Essentially using what IPRT's RTPATHRENAME_FLAGS_
159 * defines have to offer.
160 */
161/** Do not replace anything. */
162#define PATHRENAME_FLAG_NO_REPLACE UINT32_C(0)
163/** This will replace attempt any target which isn't a directory. */
164#define PATHRENAME_FLAG_REPLACE RT_BIT(0)
165/** Don't allow symbolic links as part of the path. */
166#define PATHRENAME_FLAG_NO_SYMLINKS RT_BIT(1)
167/** Mask of valid flags. */
168#define PATHRENAME_FLAG_VALID_MASK UINT32_C(0x00000002)
169
170/**
171 * Defines for guest process array lengths.
172 */
173#define GUESTPROCESS_MAX_CMD_LEN _1K
174#define GUESTPROCESS_MAX_ARGS_LEN _1K
175#define GUESTPROCESS_MAX_ENV_LEN _64K
176#define GUESTPROCESS_MAX_USER_LEN 128
177#define GUESTPROCESS_MAX_PASSWORD_LEN 128
178#define GUESTPROCESS_MAX_DOMAIN_LEN 256
179
180/** @name Internal tools built into VBoxService which are used in order to
181 * accomplish tasks host<->guest.
182 * @{
183 */
184#define VBOXSERVICE_TOOL_CAT "vbox_cat"
185#define VBOXSERVICE_TOOL_LS "vbox_ls"
186#define VBOXSERVICE_TOOL_RM "vbox_rm"
187#define VBOXSERVICE_TOOL_MKDIR "vbox_mkdir"
188#define VBOXSERVICE_TOOL_MKTEMP "vbox_mktemp"
189#define VBOXSERVICE_TOOL_STAT "vbox_stat"
190/** @} */
191
192/**
193 * Input status, reported by the client.
194 */
195enum eInputStatus
196{
197 /** Input is in an undefined state. */
198 INPUT_STS_UNDEFINED = 0,
199 /** Input was written (partially, see cbProcessed). */
200 INPUT_STS_WRITTEN = 1,
201 /** Input failed with an error (see flags for rc). */
202 INPUT_STS_ERROR = 20,
203 /** Process has abandoned / terminated input handling. */
204 INPUT_STS_TERMINATED = 21,
205 /** Too much input data. */
206 INPUT_STS_OVERFLOW = 30
207};
208
209/**
210 * Structure keeping the context of a host callback.
211 */
212typedef struct VBoxGuestCtrlHostCbCtx
213{
214 /** HGCM Function number. */
215 uint32_t uFunction;
216 /** The context ID. */
217 uint32_t uContextID;
218 /** Protocol version of this guest session. Might
219 * be 0 if not supported. */
220 uint32_t uProtocol;
221
222} VBOXGUESTCTRLHOSTCBCTX, *PVBOXGUESTCTRLHOSTCBCTX;
223
224/**
225 * Structure for low level HGCM host callback from
226 * the guest. No deep copy. */
227typedef struct VBoxGuestCtrlHostCallback
228{
229 VBoxGuestCtrlHostCallback(uint32_t cParms, VBOXHGCMSVCPARM paParms[])
230 : mParms(cParms), mpaParms(paParms) { }
231
232 /** Number of HGCM parameters. */
233 uint32_t mParms;
234 /** Actual HGCM parameters. */
235 PVBOXHGCMSVCPARM mpaParms;
236
237} VBOXGUESTCTRLHOSTCALLBACK, *PVBOXGUESTCTRLHOSTCALLBACK;
238
239/**
240 * The service functions which are callable by host.
241 */
242enum eHostFn
243{
244 /**
245 * The host asks the client to cancel all pending waits and exit.
246 */
247 HOST_CANCEL_PENDING_WAITS = 0,
248 /**
249 * The host wants to create a guest session.
250 */
251 HOST_SESSION_CREATE = 20,
252 /**
253 * The host wants to close a guest session.
254 */
255 HOST_SESSION_CLOSE = 21,
256 /**
257 * The host wants to execute something in the guest. This can be a command line
258 * or starting a program.
259 ** Note: Legacy (VBox < 4.3) command.
260 */
261 HOST_EXEC_CMD = 100,
262 /**
263 * Sends input data for stdin to a running process executed by HOST_EXEC_CMD.
264 ** Note: Legacy (VBox < 4.3) command.
265 */
266 HOST_EXEC_SET_INPUT = 101,
267 /**
268 * Gets the current status of a running process, e.g.
269 * new data on stdout/stderr, process terminated etc.
270 ** Note: Legacy (VBox < 4.3) command.
271 */
272 HOST_EXEC_GET_OUTPUT = 102,
273 /**
274 * Terminates a running guest process.
275 */
276 HOST_EXEC_TERMINATE = 110,
277 /**
278 * Waits for a certain event to happen. This can be an input, output
279 * or status event.
280 */
281 HOST_EXEC_WAIT_FOR = 120,
282 /**
283 * Opens a guest file.
284 */
285 HOST_FILE_OPEN = 240,
286 /**
287 * Closes a guest file.
288 */
289 HOST_FILE_CLOSE = 241,
290 /**
291 * Reads from an opened guest file.
292 */
293 HOST_FILE_READ = 250,
294 /**
295 * Reads from an opened guest file at
296 * a specified offset.
297 */
298 HOST_FILE_READ_AT = 251,
299 /**
300 * Write to an opened guest file.
301 */
302 HOST_FILE_WRITE = 260,
303 /**
304 * Write to an opened guest file at
305 * a specified offset.
306 */
307 HOST_FILE_WRITE_AT = 261,
308 /**
309 * Changes the read & write position of an opened guest file.
310 */
311 HOST_FILE_SEEK = 270,
312 /**
313 * Gets the current file position of an opened guest file.
314 */
315 HOST_FILE_TELL = 271,
316 /**
317 * Removes a directory on the guest.
318 */
319 HOST_DIR_REMOVE = 320,
320 /**
321 * Renames a path on the guest.
322 */
323 HOST_PATH_RENAME = 330
324};
325
326/**
327 * The service functions which are called by guest. The numbers may not change,
328 * so we hardcode them.
329 */
330enum eGuestFn
331{
332 /**
333 * Guest waits for a new message the host wants to process on the guest side.
334 * This is a blocking call and can be deferred.
335 */
336 GUEST_MSG_WAIT = 1,
337 /**
338 * Guest asks the host to cancel all pending waits the guest itself waits on.
339 * This becomes necessary when the guest wants to quit but still waits for
340 * commands from the host.
341 */
342 GUEST_CANCEL_PENDING_WAITS = 2,
343 /**
344 * Guest disconnected (terminated normally or due to a crash HGCM
345 * detected when calling service::clientDisconnect().
346 */
347 GUEST_DISCONNECTED = 3,
348 /**
349 * Sets a message filter to only get messages which have a certain
350 * context ID scheme (that is, a specific session, object etc).
351 * Since VBox 4.3+.
352 */
353 GUEST_MSG_FILTER_SET = 4,
354 /**
355 * Unsets (and resets) a previously set message filter.
356 */
357 GUEST_MSG_FILTER_UNSET = 5,
358 /**
359 * Skips the current assigned message returned by GUEST_MSG_WAIT.
360 * Needed for telling the host service to not keep stale
361 * host commands in the queue.
362 */
363 GUEST_MSG_SKIP = 10,
364 /**
365 * General reply to a host message. Only contains basic data
366 * along with a simple payload.
367 */
368 GUEST_MSG_REPLY = 11,
369 /**
370 * General message for updating a pending progress for
371 * a long task.
372 */
373 GUEST_MSG_PROGRESS_UPDATE = 12,
374 /**
375 * Guest reports back a guest session status.
376 */
377 GUEST_SESSION_NOTIFY = 20,
378 /**
379 * Guest wants to close a specific guest session.
380 */
381 GUEST_SESSION_CLOSE = 21,
382 /**
383 * Guests sends output from an executed process.
384 */
385 GUEST_EXEC_OUTPUT = 100,
386 /**
387 * Guest sends a status update of an executed process to the host.
388 */
389 GUEST_EXEC_STATUS = 101,
390 /**
391 * Guests sends an input status notification to the host.
392 */
393 GUEST_EXEC_INPUT_STATUS = 102,
394 /**
395 * Guest notifies the host about some I/O event. This can be
396 * a stdout, stderr or a stdin event. The actual event only tells
397 * how many data is available / can be sent without actually
398 * transmitting the data.
399 */
400 GUEST_EXEC_IO_NOTIFY = 210,
401 /**
402 * Guest notifies the host about some directory event.
403 */
404 GUEST_DIR_NOTIFY = 230,
405 /**
406 * Guest notifies the host about some file event.
407 */
408 GUEST_FILE_NOTIFY = 240
409};
410
411/**
412 * Guest session notification types.
413 * @sa HGCMMsgSessionNotify.
414 */
415enum GUEST_SESSION_NOTIFYTYPE
416{
417 GUEST_SESSION_NOTIFYTYPE_UNDEFINED = 0,
418 /** Something went wrong (see rc). */
419 GUEST_SESSION_NOTIFYTYPE_ERROR = 1,
420 /** Guest session has been started. */
421 GUEST_SESSION_NOTIFYTYPE_STARTED = 11,
422 /** Guest session terminated normally. */
423 GUEST_SESSION_NOTIFYTYPE_TEN = 20,
424 /** Guest session terminated via signal. */
425 GUEST_SESSION_NOTIFYTYPE_TES = 30,
426 /** Guest session terminated abnormally. */
427 GUEST_SESSION_NOTIFYTYPE_TEA = 40,
428 /** Guest session timed out and was killed. */
429 GUEST_SESSION_NOTIFYTYPE_TOK = 50,
430 /** Guest session timed out and was not killed successfully. */
431 GUEST_SESSION_NOTIFYTYPE_TOA = 60,
432 /** Service/OS is stopping, process was killed. */
433 GUEST_SESSION_NOTIFYTYPE_DWN = 150
434};
435
436/**
437 * Guest directory notification types.
438 * @sa HGCMMsgDirNotify.
439 */
440enum GUEST_DIR_NOTIFYTYPE
441{
442 GUEST_DIR_NOTIFYTYPE_UNKNOWN = 0,
443 /** Something went wrong (see rc). */
444 GUEST_DIR_NOTIFYTYPE_ERROR = 1,
445 /** Guest directory opened. */
446 GUEST_DIR_NOTIFYTYPE_OPEN = 10,
447 /** Guest directory closed. */
448 GUEST_DIR_NOTIFYTYPE_CLOSE = 20,
449 /** Information about an open guest directory. */
450 GUEST_DIR_NOTIFYTYPE_INFO = 40,
451 /** Guest directory created. */
452 GUEST_DIR_NOTIFYTYPE_CREATE = 70,
453 /** Guest directory deleted. */
454 GUEST_DIR_NOTIFYTYPE_REMOVE = 80
455};
456
457/**
458 * Guest file notification types.
459 * @sa HGCMMsgFileNotify.
460 */
461enum GUEST_FILE_NOTIFYTYPE
462{
463 GUEST_FILE_NOTIFYTYPE_UNKNOWN = 0,
464 GUEST_FILE_NOTIFYTYPE_ERROR = 1,
465 GUEST_FILE_NOTIFYTYPE_OPEN = 10,
466 GUEST_FILE_NOTIFYTYPE_CLOSE = 20,
467 GUEST_FILE_NOTIFYTYPE_READ = 30,
468 GUEST_FILE_NOTIFYTYPE_WRITE = 40,
469 GUEST_FILE_NOTIFYTYPE_SEEK = 50,
470 GUEST_FILE_NOTIFYTYPE_TELL = 60
471};
472
473/**
474 * Guest file seeking types. Has to
475 * match FileSeekType in Main.
476 */
477enum GUEST_FILE_SEEKTYPE
478{
479 GUEST_FILE_SEEKTYPE_BEGIN = 1,
480 GUEST_FILE_SEEKTYPE_CURRENT = 4,
481 GUEST_FILE_SEEKTYPE_END = 8
482};
483
484/*
485 * HGCM parameter structures.
486 */
487#pragma pack (1)
488
489/**
490 * Waits for a host command to arrive. The structure then contains the
491 * actual message type + required number of parameters needed to successfully
492 * retrieve that host command (in a next round).
493 */
494typedef struct HGCMMsgCmdWaitFor
495{
496 VBoxGuestHGCMCallInfo hdr;
497 /**
498 * The returned command the host wants to
499 * run on the guest.
500 */
501 HGCMFunctionParameter msg; /* OUT uint32_t */
502 /** Number of parameters the message needs. */
503 HGCMFunctionParameter num_parms; /* OUT uint32_t */
504} HGCMMsgCmdWaitFor;
505
506/**
507 * Asks the guest control host service to set a command
508 * filter for this client. This filter will then only
509 * deliver messages to the client which match the
510 * wanted context ID (ranges).
511 */
512typedef struct HGCMMsgCmdFilterSet
513{
514 VBoxGuestHGCMCallInfo hdr;
515 /** Value to filter for after filter mask
516 * was applied. */
517 HGCMFunctionParameter value; /* IN uint32_t */
518 /** Mask to add to the current set filter. */
519 HGCMFunctionParameter mask_add; /* IN uint32_t */
520 /** Mask to remove from the current set filter. */
521 HGCMFunctionParameter mask_remove; /* IN uint32_t */
522 /** Filter flags; currently unused. */
523 HGCMFunctionParameter flags; /* IN uint32_t */
524} HGCMMsgCmdFilterSet;
525
526/**
527 * Asks the guest control host service to disable
528 * a previously set message filter again.
529 */
530typedef struct HGCMMsgCmdFilterUnset
531{
532 VBoxGuestHGCMCallInfo hdr;
533 /** Unset flags; currently unused. */
534 HGCMFunctionParameter flags; /* IN uint32_t */
535} HGCMMsgCmdFilterUnset;
536
537/**
538 * Asks the guest control host service to skip the
539 * currently assigned host command returned by
540 * VbglR3GuestCtrlMsgWaitFor().
541 */
542typedef struct HGCMMsgCmdSkip
543{
544 VBoxGuestHGCMCallInfo hdr;
545 /** Skip flags; currently unused. */
546 HGCMFunctionParameter flags; /* IN uint32_t */
547} HGCMMsgCmdSkip;
548
549/**
550 * Asks the guest control host service to cancel all pending (outstanding)
551 * waits which were not processed yet. This is handy for a graceful shutdown.
552 */
553typedef struct HGCMMsgCancelPendingWaits
554{
555 VBoxGuestHGCMCallInfo hdr;
556} HGCMMsgCancelPendingWaits;
557
558typedef struct HGCMMsgCmdReply
559{
560 VBoxGuestHGCMCallInfo hdr;
561 /** Context ID. */
562 HGCMFunctionParameter context;
563 /** Message type. */
564 HGCMFunctionParameter type;
565 /** IPRT result of overall operation. */
566 HGCMFunctionParameter rc;
567 /** Optional payload to this reply. */
568 HGCMFunctionParameter payload;
569} HGCMMsgCmdReply;
570
571/**
572 * Creates a guest session.
573 */
574typedef struct HGCMMsgSessionOpen
575{
576 VBoxGuestHGCMCallInfo hdr;
577 /** Context ID. */
578 HGCMFunctionParameter context;
579 /** The guest control protocol version this
580 * session is about to use. */
581 HGCMFunctionParameter protocol;
582 /** The user name to run the guest session under. */
583 HGCMFunctionParameter username;
584 /** The user's password. */
585 HGCMFunctionParameter password;
586 /** The domain to run the guest session under. */
587 HGCMFunctionParameter domain;
588 /** Session creation flags. */
589 HGCMFunctionParameter flags;
590} HGCMMsgSessionOpen;
591
592/**
593 * Terminates (closes) a guest session.
594 */
595typedef struct HGCMMsgSessionClose
596{
597 VBoxGuestHGCMCallInfo hdr;
598 /** Context ID. */
599 HGCMFunctionParameter context;
600 /** Session termination flags. */
601 HGCMFunctionParameter flags;
602} HGCMMsgSessionClose;
603
604/**
605 * Reports back a guest session's status.
606 */
607typedef struct HGCMMsgSessionNotify
608{
609 VBoxGuestHGCMCallInfo hdr;
610 /** Context ID. */
611 HGCMFunctionParameter context;
612 /** Notification type. */
613 HGCMFunctionParameter type;
614 /** Notification result. */
615 HGCMFunctionParameter result;
616} HGCMMsgSessionNotify;
617
618typedef struct HGCMMsgPathRename
619{
620 VBoxGuestHGCMCallInfo hdr;
621 /** UInt32: Context ID. */
622 HGCMFunctionParameter context;
623 /** Source to rename. */
624 HGCMFunctionParameter source;
625 /** Destination to rename source to. */
626 HGCMFunctionParameter dest;
627 /** UInt32: Rename flags. */
628 HGCMFunctionParameter flags;
629} HGCMMsgPathRename;
630
631/**
632 * Executes a command inside the guest.
633 */
634typedef struct HGCMMsgProcExec
635{
636 VBoxGuestHGCMCallInfo hdr;
637 /** Context ID. */
638 HGCMFunctionParameter context;
639 /** The command to execute on the guest. */
640 HGCMFunctionParameter cmd;
641 /** Execution flags (see IGuest::ProcessCreateFlag_*). */
642 HGCMFunctionParameter flags;
643 /** Number of arguments. */
644 HGCMFunctionParameter num_args;
645 /** The actual arguments. */
646 HGCMFunctionParameter args;
647 /** Number of environment value pairs. */
648 HGCMFunctionParameter num_env;
649 /** Size (in bytes) of environment block, including terminating zeros. */
650 HGCMFunctionParameter cb_env;
651 /** The actual environment block. */
652 HGCMFunctionParameter env;
653 union
654 {
655 struct
656 {
657 /** The user name to run the executed command under.
658 * Only for VBox < 4.3 hosts. */
659 HGCMFunctionParameter username;
660 /** The user's password.
661 * Only for VBox < 4.3 hosts. */
662 HGCMFunctionParameter password;
663 /** Timeout (in msec) which either specifies the
664 * overall lifetime of the process or how long it
665 * can take to bring the process up and running -
666 * (depends on the IGuest::ProcessCreateFlag_*). */
667 HGCMFunctionParameter timeout;
668 } v1;
669 struct
670 {
671 /** Timeout (in ms) which either specifies the
672 * overall lifetime of the process or how long it
673 * can take to bring the process up and running -
674 * (depends on the IGuest::ProcessCreateFlag_*). */
675 HGCMFunctionParameter timeout;
676 /** Process priority. */
677 HGCMFunctionParameter priority;
678 /** Number of process affinity blocks. */
679 HGCMFunctionParameter num_affinity;
680 /** Pointer to process affinity blocks (uint64_t). */
681 HGCMFunctionParameter affinity;
682 } v2;
683 } u;
684} HGCMMsgProcExec;
685
686/**
687 * Sends input to a guest process via stdin.
688 */
689typedef struct HGCMMsgProcInput
690{
691 VBoxGuestHGCMCallInfo hdr;
692 /** Context ID. */
693 HGCMFunctionParameter context;
694 /** The process ID (PID) to send the input to. */
695 HGCMFunctionParameter pid;
696 /** Input flags (see IGuest::ProcessInputFlag_*). */
697 HGCMFunctionParameter flags;
698 /** Data buffer. */
699 HGCMFunctionParameter data;
700 /** Actual size of data (in bytes). */
701 HGCMFunctionParameter size;
702} HGCMMsgProcInput;
703
704/**
705 * Retrieves ouptut from a previously executed process
706 * from stdout/stderr.
707 */
708typedef struct HGCMMsgProcOutput
709{
710 VBoxGuestHGCMCallInfo hdr;
711 /** Context ID. */
712 HGCMFunctionParameter context;
713 /** The process ID (PID). */
714 HGCMFunctionParameter pid;
715 /** The pipe handle ID (stdout/stderr). */
716 HGCMFunctionParameter handle;
717 /** Optional flags. */
718 HGCMFunctionParameter flags;
719 /** Data buffer. */
720 HGCMFunctionParameter data;
721} HGCMMsgProcOutput;
722
723/**
724 * Reports the current status of a guest process.
725 */
726typedef struct HGCMMsgProcStatus
727{
728 VBoxGuestHGCMCallInfo hdr;
729 /** Context ID. */
730 HGCMFunctionParameter context;
731 /** The process ID (PID). */
732 HGCMFunctionParameter pid;
733 /** The process status. */
734 HGCMFunctionParameter status;
735 /** Optional flags (based on status). */
736 HGCMFunctionParameter flags;
737 /** Optional data buffer (not used atm). */
738 HGCMFunctionParameter data;
739} HGCMMsgProcStatus;
740
741/**
742 * Reports back the status of data written to a process.
743 */
744typedef struct HGCMMsgProcStatusInput
745{
746 VBoxGuestHGCMCallInfo hdr;
747 /** Context ID. */
748 HGCMFunctionParameter context;
749 /** The process ID (PID). */
750 HGCMFunctionParameter pid;
751 /** Status of the operation. */
752 HGCMFunctionParameter status;
753 /** Optional flags. */
754 HGCMFunctionParameter flags;
755 /** Data written. */
756 HGCMFunctionParameter written;
757} HGCMMsgProcStatusInput;
758
759/*
760 * Guest control 2.0 messages.
761 */
762
763/**
764 * Terminates a guest process.
765 */
766typedef struct HGCMMsgProcTerminate
767{
768 VBoxGuestHGCMCallInfo hdr;
769 /** Context ID. */
770 HGCMFunctionParameter context;
771 /** The process ID (PID). */
772 HGCMFunctionParameter pid;
773} HGCMMsgProcTerminate;
774
775/**
776 * Waits for certain events to happen.
777 */
778typedef struct HGCMMsgProcWaitFor
779{
780 VBoxGuestHGCMCallInfo hdr;
781 /** Context ID. */
782 HGCMFunctionParameter context;
783 /** The process ID (PID). */
784 HGCMFunctionParameter pid;
785 /** Wait (event) flags. */
786 HGCMFunctionParameter flags;
787 /** Timeout (in ms). */
788 HGCMFunctionParameter timeout;
789} HGCMMsgProcWaitFor;
790
791typedef struct HGCMMsgDirRemove
792{
793 VBoxGuestHGCMCallInfo hdr;
794 /** UInt32: Context ID. */
795 HGCMFunctionParameter context;
796 /** Directory to remove. */
797 HGCMFunctionParameter path;
798 /** UInt32: Removement flags. */
799 HGCMFunctionParameter flags;
800} HGCMMsgDirRemove;
801
802/**
803 * Opens a guest file.
804 */
805typedef struct HGCMMsgFileOpen
806{
807 VBoxGuestHGCMCallInfo hdr;
808 /** UInt32: Context ID. */
809 HGCMFunctionParameter context;
810 /** File to open. */
811 HGCMFunctionParameter filename;
812 /** Open mode. */
813 HGCMFunctionParameter openmode;
814 /** Disposition mode. */
815 HGCMFunctionParameter disposition;
816 /** Sharing mode. */
817 HGCMFunctionParameter sharing;
818 /** UInt32: Creation mode. */
819 HGCMFunctionParameter creationmode;
820 /** UInt64: Initial offset. */
821 HGCMFunctionParameter offset;
822} HGCMMsgFileOpen;
823
824/**
825 * Closes a guest file.
826 */
827typedef struct HGCMMsgFileClose
828{
829 VBoxGuestHGCMCallInfo hdr;
830 /** Context ID. */
831 HGCMFunctionParameter context;
832 /** File handle to close. */
833 HGCMFunctionParameter handle;
834} HGCMMsgFileClose;
835
836/**
837 * Reads from a guest file.
838 */
839typedef struct HGCMMsgFileRead
840{
841 VBoxGuestHGCMCallInfo hdr;
842 /** Context ID. */
843 HGCMFunctionParameter context;
844 /** File handle to read from. */
845 HGCMFunctionParameter handle;
846 /** Size (in bytes) to read. */
847 HGCMFunctionParameter size;
848} HGCMMsgFileRead;
849
850/**
851 * Reads at a specified offset from a guest file.
852 */
853typedef struct HGCMMsgFileReadAt
854{
855 VBoxGuestHGCMCallInfo hdr;
856 /** Context ID. */
857 HGCMFunctionParameter context;
858 /** File handle to read from. */
859 HGCMFunctionParameter handle;
860 /** Offset where to start reading from. */
861 HGCMFunctionParameter offset;
862 /** Actual size of data (in bytes). */
863 HGCMFunctionParameter size;
864} HGCMMsgFileReadAt;
865
866/**
867 * Writes to a guest file.
868 */
869typedef struct HGCMMsgFileWrite
870{
871 VBoxGuestHGCMCallInfo hdr;
872 /** Context ID. */
873 HGCMFunctionParameter context;
874 /** File handle to write to. */
875 HGCMFunctionParameter handle;
876 /** Actual size of data (in bytes). */
877 HGCMFunctionParameter size;
878 /** Data buffer to write to the file. */
879 HGCMFunctionParameter data;
880} HGCMMsgFileWrite;
881
882/**
883 * Writes at a specified offset to a guest file.
884 */
885typedef struct HGCMMsgFileWriteAt
886{
887 VBoxGuestHGCMCallInfo hdr;
888 /** Context ID. */
889 HGCMFunctionParameter context;
890 /** File handle to write to. */
891 HGCMFunctionParameter handle;
892 /** Offset where to start reading from. */
893 HGCMFunctionParameter offset;
894 /** Actual size of data (in bytes). */
895 HGCMFunctionParameter size;
896 /** Data buffer to write to the file. */
897 HGCMFunctionParameter data;
898} HGCMMsgFileWriteAt;
899
900/**
901 * Seeks the read/write position of a guest file.
902 */
903typedef struct HGCMMsgFileSeek
904{
905 VBoxGuestHGCMCallInfo hdr;
906 /** Context ID. */
907 HGCMFunctionParameter context;
908 /** File handle to seek. */
909 HGCMFunctionParameter handle;
910 /** The seeking method. */
911 HGCMFunctionParameter method;
912 /** The seeking offset. */
913 HGCMFunctionParameter offset;
914} HGCMMsgFileSeek;
915
916/**
917 * Tells the current read/write position of a guest file.
918 */
919typedef struct HGCMMsgFileTell
920{
921 VBoxGuestHGCMCallInfo hdr;
922 /** Context ID. */
923 HGCMFunctionParameter context;
924 /** File handle to get the current position for. */
925 HGCMFunctionParameter handle;
926} HGCMMsgFileTell;
927
928/******************************************************************************
929* HGCM replies from the guest. These are handled in Main's low-level HGCM *
930* callbacks and dispatched to the appropriate guest object. *
931******************************************************************************/
932
933typedef struct HGCMReplyFileNotify
934{
935 VBoxGuestHGCMCallInfo hdr;
936 /** Context ID. */
937 HGCMFunctionParameter context;
938 /** Notification type. */
939 HGCMFunctionParameter type;
940 /** IPRT result of overall operation. */
941 HGCMFunctionParameter rc;
942 union
943 {
944 struct
945 {
946 /** Guest file handle. */
947 HGCMFunctionParameter handle;
948 } open;
949 /** Note: Close does not have any additional data (yet). */
950 struct
951 {
952 /** Actual data read (if any). */
953 HGCMFunctionParameter data;
954 } read;
955 struct
956 {
957 /** How much data (in bytes) have been successfully written. */
958 HGCMFunctionParameter written;
959 } write;
960 struct
961 {
962 HGCMFunctionParameter offset;
963 } seek;
964 struct
965 {
966 HGCMFunctionParameter offset;
967 } tell;
968 } u;
969} HGCMReplyFileNotify;
970
971typedef struct HGCMReplyDirNotify
972{
973 VBoxGuestHGCMCallInfo hdr;
974 /** Context ID. */
975 HGCMFunctionParameter context;
976 /** Notification type. */
977 HGCMFunctionParameter type;
978 /** IPRT result of overall operation. */
979 HGCMFunctionParameter rc;
980 union
981 {
982 struct
983 {
984 /** Directory information. */
985 HGCMFunctionParameter objInfo;
986 } info;
987 struct
988 {
989 /** Guest directory handle. */
990 HGCMFunctionParameter handle;
991 } open;
992 struct
993 {
994 /** Current read directory entry. */
995 HGCMFunctionParameter entry;
996 /** Extended entry object information. Optional. */
997 HGCMFunctionParameter objInfo;
998 } read;
999 } u;
1000} HGCMReplyDirNotify;
1001
1002#pragma pack ()
1003
1004/******************************************************************************
1005* Callback data structures. *
1006******************************************************************************/
1007
1008/**
1009 * The guest control callback data header. Must come first
1010 * on each callback structure defined below this struct.
1011 */
1012typedef struct CALLBACKDATA_HEADER
1013{
1014 /** Context ID to identify callback data. This is
1015 * and *must* be the very first parameter in this
1016 * structure to still be backwards compatible. */
1017 uint32_t uContextID;
1018} CALLBACKDATA_HEADER, *PCALLBACKDATA_HEADER;
1019
1020/*
1021 * These structures make up the actual low level HGCM callback data sent from
1022 * the guest back to the host.
1023 */
1024
1025typedef struct CALLBACKDATA_CLIENT_DISCONNECTED
1026{
1027 /** Callback data header. */
1028 CALLBACKDATA_HEADER hdr;
1029} CALLBACKDATA_CLIENT_DISCONNECTED, *PCALLBACKDATA_CLIENT_DISCONNECTED;
1030
1031typedef struct CALLBACKDATA_MSG_REPLY
1032{
1033 /** Callback data header. */
1034 CALLBACKDATA_HEADER hdr;
1035 /** Notification type. */
1036 uint32_t uType;
1037 /** Notification result. Note: int vs. uint32! */
1038 uint32_t rc;
1039 /** Pointer to optional payload. */
1040 void *pvPayload;
1041 /** Payload size (in bytes). */
1042 uint32_t cbPayload;
1043} CALLBACKDATA_MSG_REPLY, *PCALLBACKDATA_MSG_REPLY;
1044
1045typedef struct CALLBACKDATA_SESSION_NOTIFY
1046{
1047 /** Callback data header. */
1048 CALLBACKDATA_HEADER hdr;
1049 /** Notification type. */
1050 uint32_t uType;
1051 /** Notification result. Note: int vs. uint32! */
1052 uint32_t uResult;
1053} CALLBACKDATA_SESSION_NOTIFY, *PCALLBACKDATA_SESSION_NOTIFY;
1054
1055typedef struct CALLBACKDATA_PROC_STATUS
1056{
1057 /** Callback data header. */
1058 CALLBACKDATA_HEADER hdr;
1059 /** The process ID (PID). */
1060 uint32_t uPID;
1061 /** The process status. */
1062 uint32_t uStatus;
1063 /** Optional flags, varies, based on u32Status. */
1064 uint32_t uFlags;
1065 /** Optional data buffer (not used atm). */
1066 void *pvData;
1067 /** Size of optional data buffer (not used atm). */
1068 uint32_t cbData;
1069} CALLBACKDATA_PROC_STATUS, *PCALLBACKDATA_PROC_STATUS;
1070
1071typedef struct CALLBACKDATA_PROC_OUTPUT
1072{
1073 /** Callback data header. */
1074 CALLBACKDATA_HEADER hdr;
1075 /** The process ID (PID). */
1076 uint32_t uPID;
1077 /** The handle ID (stdout/stderr). */
1078 uint32_t uHandle;
1079 /** Optional flags (not used atm). */
1080 uint32_t uFlags;
1081 /** Optional data buffer. */
1082 void *pvData;
1083 /** Size (in bytes) of optional data buffer. */
1084 uint32_t cbData;
1085} CALLBACKDATA_PROC_OUTPUT, *PCALLBACKDATA_PROC_OUTPUT;
1086
1087typedef struct CALLBACKDATA_PROC_INPUT
1088{
1089 /** Callback data header. */
1090 CALLBACKDATA_HEADER hdr;
1091 /** The process ID (PID). */
1092 uint32_t uPID;
1093 /** Current input status. */
1094 uint32_t uStatus;
1095 /** Optional flags. */
1096 uint32_t uFlags;
1097 /** Size (in bytes) of processed input data. */
1098 uint32_t uProcessed;
1099} CALLBACKDATA_PROC_INPUT, *PCALLBACKDATA_PROC_INPUT;
1100
1101/**
1102 * General guest directory notification callback.
1103 */
1104typedef struct CALLBACKDATA_DIR_NOTIFY
1105{
1106 /** Callback data header. */
1107 CALLBACKDATA_HEADER hdr;
1108 /** Notification type. */
1109 uint32_t uType;
1110 /** IPRT result of overall operation. */
1111 uint32_t rc;
1112 union
1113 {
1114 struct
1115 {
1116 /** Size (in bytes) of directory information. */
1117 uint32_t cbObjInfo;
1118 /** Pointer to directory information. */
1119 void *pvObjInfo;
1120 } info;
1121 struct
1122 {
1123 /** Guest directory handle. */
1124 uint32_t uHandle;
1125 } open;
1126 /** Note: Close does not have any additional data (yet). */
1127 struct
1128 {
1129 /** Size (in bytes) of directory entry information. */
1130 uint32_t cbEntry;
1131 /** Pointer to directory entry information. */
1132 void *pvEntry;
1133 /** Size (in bytes) of directory entry object information. */
1134 uint32_t cbObjInfo;
1135 /** Pointer to directory entry object information. */
1136 void *pvObjInfo;
1137 } read;
1138 } u;
1139} CALLBACKDATA_DIR_NOTIFY, *PCALLBACKDATA_DIR_NOTIFY;
1140
1141/**
1142 * General guest file notification callback.
1143 */
1144typedef struct CALLBACKDATA_FILE_NOTIFY
1145{
1146 /** Callback data header. */
1147 CALLBACKDATA_HEADER hdr;
1148 /** Notification type. */
1149 uint32_t uType;
1150 /** IPRT result of overall operation. */
1151 uint32_t rc;
1152 union
1153 {
1154 struct
1155 {
1156 /** Guest file handle. */
1157 uint32_t uHandle;
1158 } open;
1159 /** Note: Close does not have any additional data (yet). */
1160 struct
1161 {
1162 /** How much data (in bytes) have been read. */
1163 uint32_t cbData;
1164 /** Actual data read (if any). */
1165 void *pvData;
1166 } read;
1167 struct
1168 {
1169 /** How much data (in bytes) have been successfully written. */
1170 uint32_t cbWritten;
1171 } write;
1172 struct
1173 {
1174 /** New file offset after successful seek. */
1175 uint64_t uOffActual;
1176 } seek;
1177 struct
1178 {
1179 /** New file offset after successful tell. */
1180 uint64_t uOffActual;
1181 } tell;
1182 } u;
1183} CALLBACKDATA_FILE_NOTIFY, *PCALLBACKDATA_FILE_NOTIFY;
1184
1185} /* namespace guestControl */
1186
1187#endif /* !___VBox_HostService_GuestControlService_h */
1188
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