VirtualBox

source: vbox/trunk/src/VBox/Main/include/GuestSessionImpl.h@ 71213

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

Guest Control: Moved the copying host -> guest implementations from VBoxMange into Main, where it actually belongs. Also cleaned up and refactored the internal session task helpers into file / directory primitives, which can be reused for various different tasks.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 25.7 KB
 
1/* $Id: GuestSessionImpl.h 71213 2018-03-05 20:30:44Z vboxsync $ */
2/** @file
3 * VirtualBox Main - Guest session handling.
4 */
5
6/*
7 * Copyright (C) 2012-2018 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
18#ifndef ____H_GUESTSESSIONIMPL
19#define ____H_GUESTSESSIONIMPL
20
21#include "GuestSessionWrap.h"
22#include "EventImpl.h"
23
24#include "GuestCtrlImplPrivate.h"
25#include "GuestProcessImpl.h"
26#include "GuestDirectoryImpl.h"
27#include "GuestFileImpl.h"
28#include "GuestFsObjInfoImpl.h"
29#include "ThreadTask.h"
30
31#include <iprt/isofs.h> /* For UpdateAdditions. */
32
33class Guest;
34class GuestSessionTaskInternalOpen;
35
36/**
37 * Abstract base class for a lenghtly per-session operation which
38 * runs in a Main worker thread.
39 */
40class GuestSessionTask : public ThreadTask
41{
42public:
43
44 GuestSessionTask(GuestSession *pSession);
45
46 virtual ~GuestSessionTask(void);
47
48public:
49
50 virtual int Run(void) = 0;
51 void handler()
52 {
53 int vrc = Run();
54 NOREF(vrc);
55 /** @todo
56 *
57 * r=bird: what was your idea WRT to Run status code and async tasks?
58 *
59 */
60 }
61
62 int RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress);
63
64 HRESULT Init(const Utf8Str &strTaskDesc)
65 {
66 HRESULT hr = S_OK;
67 setTaskDesc(strTaskDesc);
68 hr = createAndSetProgressObject();
69 return hr;
70 }
71
72 const ComObjPtr<Progress>& GetProgressObject() const { return mProgress; }
73
74protected:
75
76 /** @name Directory handling primitives.
77 * @{ */
78 int directoryCreate(const com::Utf8Str &strPath, DirectoryCreateFlag_T enmDirecotryCreateFlags, uint32_t uMode, bool fFollowSymlinks);
79 /** @} */
80
81 /** @name File handling primitives.
82 * @{ */
83 int fileCopyToGuestEx(const Utf8Str &strSource, const Utf8Str &strDest, FileCopyFlag_T enmFileCopyFlags, PRTFILE pFile, uint64_t cbOffset, uint64_t cbSize);
84 int fileCopyToGuest(const Utf8Str &strSource, const Utf8Str &strDest, FileCopyFlag_T enmFileCopyFlags);
85 /** @} */
86
87 /** @name Guest property handling primitives.
88 * @{ */
89 int getGuestProperty(const ComObjPtr<Guest> &pGuest, const Utf8Str &strPath, Utf8Str &strValue);
90 /** @} */
91
92 /** @name Path handling primitives.
93 * @{ */
94 int pathConstructOnGuest(const Utf8Str &strSourceRoot, const Utf8Str &strSource, const Utf8Str &strDest, Utf8Str &strOut);
95 /** @} */
96
97 int setProgress(ULONG uPercent);
98 int setProgressSuccess(void);
99 HRESULT setProgressErrorMsg(HRESULT hr, const Utf8Str &strMsg);
100
101 inline void setTaskDesc(const Utf8Str &strTaskDesc) throw()
102 {
103 mDesc = strTaskDesc;
104 }
105
106 HRESULT createAndSetProgressObject();
107
108protected:
109
110 Utf8Str mDesc;
111 /** The guest session object this task is working on. */
112 ComObjPtr<GuestSession> mSession;
113 /** Progress object for getting updated when running
114 * asynchronously. Optional. */
115 ComObjPtr<Progress> mProgress;
116};
117
118/**
119 * Task for opening a guest session.
120 */
121class SessionTaskOpen : public GuestSessionTask
122{
123public:
124
125 SessionTaskOpen(GuestSession *pSession,
126 uint32_t uFlags,
127 uint32_t uTimeoutMS);
128 virtual ~SessionTaskOpen(void);
129 int Run(void);
130
131protected:
132
133 /** Session creation flags. */
134 uint32_t mFlags;
135 /** Session creation timeout (in ms). */
136 uint32_t mTimeoutMS;
137};
138
139/**
140 * Task for copying directories from guest to the host.
141 */
142class SessionTaskCopyDirFrom : public GuestSessionTask
143{
144public:
145
146 SessionTaskCopyDirFrom(GuestSession *pSession,
147 const Utf8Str &strSource, const Utf8Str &strDest, const Utf8Str &strFilter, DirectoryCopyFlags_T enmDirCopyFlags);
148 virtual ~SessionTaskCopyDirFrom(void);
149 int Run(void);
150
151protected:
152
153 int directoryCopyToHost(const Utf8Str &strSource, const Utf8Str &strFilter, const Utf8Str &strDest, bool fRecursive, bool fFollowSymlinks,
154 const Utf8Str &strSubDir /* For recursion. */);
155protected:
156
157 Utf8Str mSource;
158 Utf8Str mDest;
159 Utf8Str mFilter;
160 DirectoryCopyFlags_T mDirCopyFlags;
161};
162
163/**
164 * Task for copying directories from host to the guest.
165 */
166class SessionTaskCopyDirTo : public GuestSessionTask
167{
168public:
169
170 SessionTaskCopyDirTo(GuestSession *pSession,
171 const Utf8Str &strSource, const Utf8Str &strDest, const Utf8Str &strFilter, DirectoryCopyFlags_T enmDirCopyFlags);
172 virtual ~SessionTaskCopyDirTo(void);
173 int Run(void);
174
175protected:
176
177 int directoryCopyToGuest(const Utf8Str &strSource, const Utf8Str &strFilter, const Utf8Str &strDest, bool fRecursive, bool fFollowSymlinks,
178 const Utf8Str &strSubDir /* For recursion. */);
179protected:
180
181 Utf8Str mSource;
182 Utf8Str mDest;
183 Utf8Str mFilter;
184 DirectoryCopyFlags_T mDirCopyFlags;
185};
186
187/**
188 * Task for copying files from host to the guest.
189 */
190class SessionTaskCopyFileTo : public GuestSessionTask
191{
192public:
193
194 SessionTaskCopyFileTo(GuestSession *pSession,
195 const Utf8Str &strSource, const Utf8Str &strDest, uint32_t uFlags);
196 SessionTaskCopyFileTo(GuestSession *pSession,
197 PRTFILE pSourceFile, size_t cbSourceOffset, uint64_t cbSourceSize,
198 const Utf8Str &strDest, uint32_t uFlags);
199 virtual ~SessionTaskCopyFileTo(void);
200 int Run(void);
201
202protected:
203
204 Utf8Str mSource;
205 PRTFILE mSourceFile;
206 size_t mSourceOffset;
207 uint64_t mSourceSize;
208 Utf8Str mDest;
209 uint32_t mCopyFileFlags;
210};
211
212/**
213 * Task for copying files from guest to the host.
214 */
215class SessionTaskCopyFileFrom : public GuestSessionTask
216{
217public:
218
219 SessionTaskCopyFileFrom(GuestSession *pSession,
220 const Utf8Str &strSource, const Utf8Str &strDest, uint32_t uFlags);
221 virtual ~SessionTaskCopyFileFrom(void);
222 int Run(void);
223
224protected:
225
226 Utf8Str mSource;
227 Utf8Str mDest;
228 uint32_t mFlags;
229};
230
231/**
232 * Task for automatically updating the Guest Additions on the guest.
233 */
234class SessionTaskUpdateAdditions : public GuestSessionTask
235{
236public:
237
238 SessionTaskUpdateAdditions(GuestSession *pSession,
239 const Utf8Str &strSource, const ProcessArguments &aArguments,
240 uint32_t uFlags);
241 virtual ~SessionTaskUpdateAdditions(void);
242 int Run(void);
243
244protected:
245
246 /**
247 * Suported OS types for automatic updating.
248 */
249 enum eOSType
250 {
251 eOSType_Unknown = 0,
252 eOSType_Windows = 1,
253 eOSType_Linux = 2,
254 eOSType_Solaris = 3
255 };
256
257 /**
258 * Structure representing a file to
259 * get off the .ISO, copied to the guest.
260 */
261 struct InstallerFile
262 {
263 InstallerFile(const Utf8Str &aSource,
264 const Utf8Str &aDest,
265 uint32_t aFlags = 0)
266 : strSource(aSource),
267 strDest(aDest),
268 fFlags(aFlags) { }
269
270 InstallerFile(const Utf8Str &aSource,
271 const Utf8Str &aDest,
272 uint32_t aFlags,
273 const GuestProcessStartupInfo &aStartupInfo)
274 : strSource(aSource),
275 strDest(aDest),
276 fFlags(aFlags),
277 mProcInfo(aStartupInfo)
278 {
279 mProcInfo.mExecutable = strDest;
280 if (mProcInfo.mName.isEmpty())
281 mProcInfo.mName = strDest;
282 }
283
284 /** Source file on .ISO. */
285 Utf8Str strSource;
286 /** Destination file on the guest. */
287 Utf8Str strDest;
288 /** File flags. */
289 uint32_t fFlags;
290 /** Optional arguments if this file needs to be
291 * executed. */
292 GuestProcessStartupInfo mProcInfo;
293 };
294
295 int addProcessArguments(ProcessArguments &aArgumentsDest, const ProcessArguments &aArgumentsSource);
296 int copyFileToGuest(GuestSession *pSession, PRTISOFSFILE pISO, Utf8Str const &strFileSource, const Utf8Str &strFileDest, bool fOptional, uint32_t *pcbSize);
297 int runFileOnGuest(GuestSession *pSession, GuestProcessStartupInfo &procInfo);
298
299 /** Files to handle. */
300 std::vector<InstallerFile> mFiles;
301 /** The (optionally) specified Guest Additions .ISO on the host
302 * which will be used for the updating process. */
303 Utf8Str mSource;
304 /** (Optional) installer command line arguments. */
305 ProcessArguments mArguments;
306 /** Update flags. */
307 uint32_t mFlags;
308};
309
310/**
311 * Guest session implementation.
312 */
313class ATL_NO_VTABLE GuestSession :
314 public GuestSessionWrap,
315 public GuestBase
316{
317public:
318 /** @name COM and internal init/term/mapping cruft.
319 * @{ */
320 DECLARE_EMPTY_CTOR_DTOR(GuestSession)
321
322 int init(Guest *pGuest, const GuestSessionStartupInfo &ssInfo, const GuestCredentials &guestCreds);
323 void uninit(void);
324 HRESULT FinalConstruct(void);
325 void FinalRelease(void);
326 /** @} */
327
328private:
329
330 /** Wrapped @name IGuestSession properties.
331 * @{ */
332 HRESULT getUser(com::Utf8Str &aUser);
333 HRESULT getDomain(com::Utf8Str &aDomain);
334 HRESULT getName(com::Utf8Str &aName);
335 HRESULT getId(ULONG *aId);
336 HRESULT getTimeout(ULONG *aTimeout);
337 HRESULT setTimeout(ULONG aTimeout);
338 HRESULT getProtocolVersion(ULONG *aProtocolVersion);
339 HRESULT getStatus(GuestSessionStatus_T *aStatus);
340 HRESULT getEnvironmentChanges(std::vector<com::Utf8Str> &aEnvironmentChanges);
341 HRESULT setEnvironmentChanges(const std::vector<com::Utf8Str> &aEnvironmentChanges);
342 HRESULT getEnvironmentBase(std::vector<com::Utf8Str> &aEnvironmentBase);
343 HRESULT getProcesses(std::vector<ComPtr<IGuestProcess> > &aProcesses);
344 HRESULT getPathStyle(PathStyle_T *aPathStyle);
345 HRESULT getCurrentDirectory(com::Utf8Str &aCurrentDirectory);
346 HRESULT setCurrentDirectory(const com::Utf8Str &aCurrentDirectory);
347 HRESULT getDirectories(std::vector<ComPtr<IGuestDirectory> > &aDirectories);
348 HRESULT getFiles(std::vector<ComPtr<IGuestFile> > &aFiles);
349 HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
350 /** @} */
351
352 /** Wrapped @name IGuestSession methods.
353 * @{ */
354 HRESULT close();
355
356 HRESULT directoryCopy(const com::Utf8Str &aSource,
357 const com::Utf8Str &aDestination,
358 const std::vector<DirectoryCopyFlags_T> &aFlags,
359 ComPtr<IProgress> &aProgress);
360 HRESULT directoryCopyFromGuest(const com::Utf8Str &aSource,
361 const com::Utf8Str &aDestination,
362 const std::vector<DirectoryCopyFlags_T> &aFlags,
363 ComPtr<IProgress> &aProgress);
364 HRESULT directoryCopyToGuest(const com::Utf8Str &aSource,
365 const com::Utf8Str &aDestination,
366 const std::vector<DirectoryCopyFlags_T> &aFlags,
367 ComPtr<IProgress> &aProgress);
368 HRESULT directoryCreate(const com::Utf8Str &aPath,
369 ULONG aMode,
370 const std::vector<DirectoryCreateFlag_T> &aFlags);
371 HRESULT directoryCreateTemp(const com::Utf8Str &aTemplateName,
372 ULONG aMode,
373 const com::Utf8Str &aPath,
374 BOOL aSecure,
375 com::Utf8Str &aDirectory);
376 HRESULT directoryExists(const com::Utf8Str &aPath,
377 BOOL aFollowSymlinks,
378 BOOL *aExists);
379 HRESULT directoryOpen(const com::Utf8Str &aPath,
380 const com::Utf8Str &aFilter,
381 const std::vector<DirectoryOpenFlag_T> &aFlags,
382 ComPtr<IGuestDirectory> &aDirectory);
383 HRESULT directoryRemove(const com::Utf8Str &aPath);
384 HRESULT directoryRemoveRecursive(const com::Utf8Str &aPath,
385 const std::vector<DirectoryRemoveRecFlag_T> &aFlags,
386 ComPtr<IProgress> &aProgress);
387 HRESULT environmentScheduleSet(const com::Utf8Str &aName,
388 const com::Utf8Str &aValue);
389 HRESULT environmentScheduleUnset(const com::Utf8Str &aName);
390 HRESULT environmentGetBaseVariable(const com::Utf8Str &aName,
391 com::Utf8Str &aValue);
392 HRESULT environmentDoesBaseVariableExist(const com::Utf8Str &aName,
393 BOOL *aExists);
394
395 HRESULT fileCopy(const com::Utf8Str &aSource,
396 const com::Utf8Str &aDestination,
397 const std::vector<FileCopyFlag_T> &aFlags,
398 ComPtr<IProgress> &aProgress);
399 HRESULT fileCopyToGuest(const com::Utf8Str &aSource,
400 const com::Utf8Str &aDestination,
401 const std::vector<FileCopyFlag_T> &aFlags,
402 ComPtr<IProgress> &aProgress);
403 HRESULT fileCopyFromGuest(const com::Utf8Str &aSource,
404 const com::Utf8Str &aDestination,
405 const std::vector<FileCopyFlag_T> &aFlags,
406 ComPtr<IProgress> &aProgress);
407 HRESULT fileCreateTemp(const com::Utf8Str &aTemplateName,
408 ULONG aMode,
409 const com::Utf8Str &aPath,
410 BOOL aSecure,
411 ComPtr<IGuestFile> &aFile);
412 HRESULT fileExists(const com::Utf8Str &aPath,
413 BOOL aFollowSymlinks,
414 BOOL *aExists);
415 HRESULT fileOpen(const com::Utf8Str &aPath,
416 FileAccessMode_T aAccessMode,
417 FileOpenAction_T aOpenAction,
418 ULONG aCreationMode,
419 ComPtr<IGuestFile> &aFile);
420 HRESULT fileOpenEx(const com::Utf8Str &aPath,
421 FileAccessMode_T aAccessMode,
422 FileOpenAction_T aOpenAction,
423 FileSharingMode_T aSharingMode,
424 ULONG aCreationMode,
425 const std::vector<FileOpenExFlags_T> &aFlags,
426 ComPtr<IGuestFile> &aFile);
427 HRESULT fileQuerySize(const com::Utf8Str &aPath,
428 BOOL aFollowSymlinks,
429 LONG64 *aSize);
430 HRESULT fsObjExists(const com::Utf8Str &aPath,
431 BOOL aFollowSymlinks,
432 BOOL *pfExists);
433 HRESULT fsObjQueryInfo(const com::Utf8Str &aPath,
434 BOOL aFollowSymlinks,
435 ComPtr<IGuestFsObjInfo> &aInfo);
436 HRESULT fsObjRemove(const com::Utf8Str &aPath);
437 HRESULT fsObjRename(const com::Utf8Str &aOldPath,
438 const com::Utf8Str &aNewPath,
439 const std::vector<FsObjRenameFlag_T> &aFlags);
440 HRESULT fsObjMove(const com::Utf8Str &aSource,
441 const com::Utf8Str &aDestination,
442 const std::vector<FsObjMoveFlags_T> &aFlags,
443 ComPtr<IProgress> &aProgress);
444 HRESULT fsObjSetACL(const com::Utf8Str &aPath,
445 BOOL aFollowSymlinks,
446 const com::Utf8Str &aAcl,
447 ULONG aMode);
448 HRESULT processCreate(const com::Utf8Str &aCommand,
449 const std::vector<com::Utf8Str> &aArguments,
450 const std::vector<com::Utf8Str> &aEnvironment,
451 const std::vector<ProcessCreateFlag_T> &aFlags,
452 ULONG aTimeoutMS,
453 ComPtr<IGuestProcess> &aGuestProcess);
454 HRESULT processCreateEx(const com::Utf8Str &aCommand,
455 const std::vector<com::Utf8Str> &aArguments,
456 const std::vector<com::Utf8Str> &aEnvironment,
457 const std::vector<ProcessCreateFlag_T> &aFlags,
458 ULONG aTimeoutMS,
459 ProcessPriority_T aPriority,
460 const std::vector<LONG> &aAffinity,
461 ComPtr<IGuestProcess> &aGuestProcess);
462 HRESULT processGet(ULONG aPid,
463 ComPtr<IGuestProcess> &aGuestProcess);
464 HRESULT symlinkCreate(const com::Utf8Str &aSource,
465 const com::Utf8Str &aTarget,
466 SymlinkType_T aType);
467 HRESULT symlinkExists(const com::Utf8Str &aSymlink,
468 BOOL *aExists);
469 HRESULT symlinkRead(const com::Utf8Str &aSymlink,
470 const std::vector<SymlinkReadFlag_T> &aFlags,
471 com::Utf8Str &aTarget);
472 HRESULT waitFor(ULONG aWaitFor,
473 ULONG aTimeoutMS,
474 GuestSessionWaitResult_T *aReason);
475 HRESULT waitForArray(const std::vector<GuestSessionWaitForFlag_T> &aWaitFor,
476 ULONG aTimeoutMS,
477 GuestSessionWaitResult_T *aReason);
478 /** @} */
479
480 /** Map of guest directories. The key specifies the internal directory ID. */
481 typedef std::map <uint32_t, ComObjPtr<GuestDirectory> > SessionDirectories;
482 /** Map of guest files. The key specifies the internal file ID. */
483 typedef std::map <uint32_t, ComObjPtr<GuestFile> > SessionFiles;
484 /** Map of guest processes. The key specifies the internal process number.
485 * To retrieve the process' guest PID use the Id() method of the IProcess interface. */
486 typedef std::map <uint32_t, ComObjPtr<GuestProcess> > SessionProcesses;
487
488public:
489 /** @name Public internal methods.
490 * @todo r=bird: Most of these are public for no real reason...
491 * @{ */
492 int i_copyToGuestCreateDir(const com::Utf8Str &aDestination, uint32_t fFlags, int *pGuestRc);
493 int i_closeSession(uint32_t uFlags, uint32_t uTimeoutMS, int *pGuestRc);
494 inline bool i_directoryExists(uint32_t uDirID, ComObjPtr<GuestDirectory> *pDir);
495 int i_directoryRemoveFromList(GuestDirectory *pDirectory);
496 int i_directoryRemoveInternal(const Utf8Str &strPath, uint32_t uFlags, int *pGuestRc);
497 int i_directoryCreateInternal(const Utf8Str &strPath, uint32_t uMode, uint32_t uFlags, int *pGuestRc);
498 int i_objectCreateTempInternal(const Utf8Str &strTemplate, const Utf8Str &strPath, bool fDirectory,
499 Utf8Str &strName, int *pGuestRc);
500 int i_directoryOpenInternal(const GuestDirectoryOpenInfo &openInfo,
501 ComObjPtr<GuestDirectory> &pDirectory, int *pGuestRc);
502 int i_directoryQueryInfoInternal(const Utf8Str &strPath, bool fFollowSymlinks, GuestFsObjData &objData, int *pGuestRc);
503 int i_dispatchToDirectory(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
504 int i_dispatchToFile(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
505 int i_dispatchToObject(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
506 int i_dispatchToProcess(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
507 int i_dispatchToThis(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
508 inline bool i_fileExists(uint32_t uFileID, ComObjPtr<GuestFile> *pFile);
509 int i_fileRemoveFromList(GuestFile *pFile);
510 int i_fileRemoveInternal(const Utf8Str &strPath, int *pGuestRc);
511 int i_fileOpenInternal(const GuestFileOpenInfo &openInfo, ComObjPtr<GuestFile> &pFile, int *pGuestRc);
512 int i_fileQueryInfoInternal(const Utf8Str &strPath, bool fFollowSymlinks, GuestFsObjData &objData, int *pGuestRc);
513 int i_fileQuerySizeInternal(const Utf8Str &strPath, bool fFollowSymlinks, int64_t *pllSize, int *pGuestRc);
514 int i_fsQueryInfoInternal(const Utf8Str &strPath, bool fFollowSymlinks, GuestFsObjData &objData, int *pGuestRc);
515 const GuestCredentials &i_getCredentials(void);
516 EventSource *i_getEventSource(void) { return mEventSource; }
517 Utf8Str i_getName(void);
518 ULONG i_getId(void) { return mData.mSession.mID; }
519 static Utf8Str i_guestErrorToString(int guestRc);
520 HRESULT i_isReadyExternal(void);
521 int i_onRemove(void);
522 int i_onSessionStatusChange(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData);
523 int i_startSessionInternal(int *pGuestRc);
524 int i_startSessionAsync(void);
525 static void i_startSessionThreadTask(GuestSessionTaskInternalOpen *pTask);
526 Guest *i_getParent(void) { return mParent; }
527 uint32_t i_getProtocolVersion(void) { return mData.mProtocolVersion; }
528 int i_pathRenameInternal(const Utf8Str &strSource, const Utf8Str &strDest, uint32_t uFlags,
529 int *pGuestRc);
530 int i_processRemoveFromList(GuestProcess *pProcess);
531 int i_processCreateExInternal(GuestProcessStartupInfo &procInfo, ComObjPtr<GuestProcess> &pProgress);
532 inline bool i_processExists(uint32_t uProcessID, ComObjPtr<GuestProcess> *pProcess);
533 inline int i_processGetByPID(ULONG uPID, ComObjPtr<GuestProcess> *pProcess);
534 int i_sendCommand(uint32_t uFunction, uint32_t uParms, PVBOXHGCMSVCPARM paParms);
535 static HRESULT i_setErrorExternal(VirtualBoxBase *pInterface, int guestRc);
536 int i_setSessionStatus(GuestSessionStatus_T sessionStatus, int sessionRc);
537 int i_signalWaiters(GuestSessionWaitResult_T enmWaitResult, int rc /*= VINF_SUCCESS */);
538 int i_determineProtocolVersion(void);
539 int i_waitFor(uint32_t fWaitFlags, ULONG uTimeoutMS, GuestSessionWaitResult_T &waitResult, int *pGuestRc);
540 int i_waitForStatusChange(GuestWaitEvent *pEvent, uint32_t fWaitFlags, uint32_t uTimeoutMS,
541 GuestSessionStatus_T *pSessionStatus, int *pGuestRc);
542 /** @} */
543
544private:
545
546 /** Pointer to the parent (Guest). */
547 Guest *mParent;
548 /**
549 * The session's event source. This source is used for
550 * serving the internal listener as well as all other
551 * external listeners that may register to it.
552 *
553 * Note: This can safely be used without holding any locks.
554 * An AutoCaller suffices to prevent it being destroy while in use and
555 * internally there is a lock providing the necessary serialization.
556 */
557 const ComObjPtr<EventSource> mEventSource;
558
559 struct Data
560 {
561 /** The session credentials. */
562 GuestCredentials mCredentials;
563 /** The session's startup info. */
564 GuestSessionStartupInfo mSession;
565 /** The session's current status. */
566 GuestSessionStatus_T mStatus;
567 /** The set of environment changes for the session for use when
568 * creating new guest processes. */
569 GuestEnvironmentChanges mEnvironmentChanges;
570 /** Pointer to the immutable base environment for the session.
571 * @note This is not allocated until the guest reports it to the host. It is
572 * also shared with child processes. */
573 GuestEnvironment const *mpBaseEnvironment;
574 /** Directory objects bound to this session. */
575 SessionDirectories mDirectories;
576 /** File objects bound to this session. */
577 SessionFiles mFiles;
578 /** Process objects bound to this session. */
579 SessionProcesses mProcesses;
580 /** Guest control protocol version to be used.
581 * Guest Additions < VBox 4.3 have version 1,
582 * any newer version will have version 2. */
583 uint32_t mProtocolVersion;
584 /** Session timeout (in ms). */
585 uint32_t mTimeout;
586 /** Total number of session objects (processes,
587 * files, ...). */
588 uint32_t mNumObjects;
589 /** The last returned session status
590 * returned from the guest side. */
591 int mRC;
592
593 Data(void)
594 : mpBaseEnvironment(NULL)
595 { }
596 Data(const Data &rThat)
597 : mCredentials(rThat.mCredentials)
598 , mSession(rThat.mSession)
599 , mStatus(rThat.mStatus)
600 , mEnvironmentChanges(rThat.mEnvironmentChanges)
601 , mpBaseEnvironment(NULL)
602 , mDirectories(rThat.mDirectories)
603 , mFiles(rThat.mFiles)
604 , mProcesses(rThat.mProcesses)
605 , mProtocolVersion(rThat.mProtocolVersion)
606 , mTimeout(rThat.mTimeout)
607 , mNumObjects(rThat.mNumObjects)
608 , mRC(rThat.mRC)
609 { }
610 ~Data(void)
611 {
612 if (mpBaseEnvironment)
613 {
614 mpBaseEnvironment->releaseConst();
615 mpBaseEnvironment = NULL;
616 }
617 }
618 } mData;
619};
620
621#endif /* !____H_GUESTSESSIONIMPL */
622
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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