VirtualBox

source: vbox/trunk/src/VBox/Main/include/GuestImpl.h@ 55631

Last change on this file since 55631 was 55613, checked in by vboxsync, 9 years ago

IGuestSession: Added a pathStyle attribute (read-only) that translates the OS type reported by the guest additions into a DOS, UNIX or Unknown path styles values. Added two methods fsExists and fsQueryInfo that aren't as narrow minded as fileQueryInfo and directoryQueryInfo and has parameters for how to treat symbolic links.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.8 KB
Line 
1/* $Id: GuestImpl.h 55613 2015-05-03 04:12:35Z vboxsync $ */
2/** @file
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2014 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.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_GUESTIMPL
19#define ____H_GUESTIMPL
20
21#include "GuestWrap.h"
22#include "VirtualBoxBase.h"
23#include <iprt/list.h>
24#include <iprt/time.h>
25#include <VBox/ostypes.h>
26#include <VBox/vmm/stam.h>
27
28#include "AdditionsFacilityImpl.h"
29#include "GuestCtrlImplPrivate.h"
30#ifdef VBOX_WITH_DRAG_AND_DROP
31# include "GuestDnDSourceImpl.h"
32# include "GuestDnDTargetImpl.h"
33#endif
34#include "GuestSessionImpl.h"
35#include "HGCM.h"
36
37typedef enum
38{
39 GUESTSTATTYPE_CPUUSER = 0,
40 GUESTSTATTYPE_CPUKERNEL = 1,
41 GUESTSTATTYPE_CPUIDLE = 2,
42 GUESTSTATTYPE_MEMTOTAL = 3,
43 GUESTSTATTYPE_MEMFREE = 4,
44 GUESTSTATTYPE_MEMBALLOON = 5,
45 GUESTSTATTYPE_MEMCACHE = 6,
46 GUESTSTATTYPE_PAGETOTAL = 7,
47 GUESTSTATTYPE_PAGEFREE = 8,
48 GUESTSTATTYPE_MAX = 9
49} GUESTSTATTYPE;
50
51class Console;
52
53class ATL_NO_VTABLE Guest :
54 public GuestWrap
55{
56public:
57
58 DECLARE_EMPTY_CTOR_DTOR (Guest)
59
60 HRESULT FinalConstruct();
61 void FinalRelease();
62
63 // Public initializer/uninitializer for internal purposes only.
64 HRESULT init(Console *aParent);
65 void uninit();
66
67
68public:
69 /** @name Static internal methods.
70 * @{ */
71#ifdef VBOX_WITH_GUEST_CONTROL
72 /** Static callback for handling guest control notifications. */
73 static DECLCALLBACK(int) i_notifyCtrlDispatcher(void *pvExtension, uint32_t u32Function, void *pvData, uint32_t cbData);
74 static DECLCALLBACK(void) i_staticUpdateStats(RTTIMERLR hTimerLR, void *pvUser, uint64_t iTick);
75#endif
76 /** @} */
77
78public:
79 /** @name Public internal methods.
80 * @{ */
81 void i_enableVMMStatistics(BOOL aEnable) { mCollectVMMStats = aEnable; };
82 void i_setAdditionsInfo(com::Utf8Str aInterfaceVersion, VBOXOSTYPE aOsType);
83 void i_setAdditionsInfo2(uint32_t a_uFullVersion, const char *a_pszName, uint32_t a_uRevision, uint32_t a_fFeatures);
84 bool i_facilityIsActive(VBoxGuestFacilityType enmFacility);
85 void i_facilityUpdate(VBoxGuestFacilityType a_enmFacility, VBoxGuestFacilityStatus a_enmStatus,
86 uint32_t a_fFlags, PCRTTIMESPEC a_pTimeSpecTS);
87 ComObjPtr<Console> i_getConsole(void) { return mParent; }
88 void i_setAdditionsStatus(VBoxGuestFacilityType a_enmFacility, VBoxGuestFacilityStatus a_enmStatus,
89 uint32_t a_fFlags, PCRTTIMESPEC a_pTimeSpecTS);
90 void i_onUserStateChange(Bstr aUser, Bstr aDomain, VBoxGuestUserState enmState, const uint8_t *puDetails, uint32_t cbDetails);
91 void i_setSupportedFeatures(uint32_t aCaps);
92 HRESULT i_setStatistic(ULONG aCpuId, GUESTSTATTYPE enmType, ULONG aVal);
93 BOOL i_isPageFusionEnabled();
94 static HRESULT i_setErrorStatic(HRESULT aResultCode, const Utf8Str &aText)
95 {
96 return setErrorInternal(aResultCode, getStaticClassIID(), getStaticComponentName(), aText, false, true);
97 }
98#ifdef VBOX_WITH_GUEST_CONTROL
99 int i_dispatchToSession(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
100 uint32_t i_getAdditionsVersion(void) { return mData.mAdditionsVersionFull; }
101 VBOXOSTYPE i_getGuestOSType(void) { return mData.mOSType; }
102 int i_sessionRemove(GuestSession *pSession);
103 int i_sessionCreate(const GuestSessionStartupInfo &ssInfo, const GuestCredentials &guestCreds,
104 ComObjPtr<GuestSession> &pGuestSession);
105 inline bool i_sessionExists(uint32_t uSessionID);
106
107#endif
108 /** @} */
109
110private:
111
112 // wrapped IGuest properties
113 HRESULT getOSTypeId(com::Utf8Str &aOSTypeId);
114 HRESULT getAdditionsRunLevel(AdditionsRunLevelType_T *aAdditionsRunLevel);
115 HRESULT getAdditionsVersion(com::Utf8Str &aAdditionsVersion);
116 HRESULT getAdditionsRevision(ULONG *aAdditionsRevision);
117 HRESULT getDnDSource(ComPtr<IGuestDnDSource> &aDnDSource);
118 HRESULT getDnDTarget(ComPtr<IGuestDnDTarget> &aDnDTarget);
119 HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
120 HRESULT getFacilities(std::vector<ComPtr<IAdditionsFacility> > &aFacilities);
121 HRESULT getSessions(std::vector<ComPtr<IGuestSession> > &aSessions);
122 HRESULT getMemoryBalloonSize(ULONG *aMemoryBalloonSize);
123 HRESULT setMemoryBalloonSize(ULONG aMemoryBalloonSize);
124 HRESULT getStatisticsUpdateInterval(ULONG *aStatisticsUpdateInterval);
125 HRESULT setStatisticsUpdateInterval(ULONG aStatisticsUpdateInterval);
126 HRESULT internalGetStatistics(ULONG *aCpuUser,
127 ULONG *aCpuKernel,
128 ULONG *aCpuIdle,
129 ULONG *aMemTotal,
130 ULONG *aMemFree,
131 ULONG *aMemBalloon,
132 ULONG *aMemShared,
133 ULONG *aMemCache,
134 ULONG *aPagedTotal,
135 ULONG *aMemAllocTotal,
136 ULONG *aMemFreeTotal,
137 ULONG *aMemBalloonTotal,
138 ULONG *aMemSharedTotal);
139 HRESULT getFacilityStatus(AdditionsFacilityType_T aFacility,
140 LONG64 *aTimestamp,
141 AdditionsFacilityStatus_T *aStatus);
142 HRESULT getAdditionsStatus(AdditionsRunLevelType_T aLevel,
143 BOOL *aActive);
144 HRESULT setCredentials(const com::Utf8Str &aUserName,
145 const com::Utf8Str &aPassword,
146 const com::Utf8Str &aDomain,
147 BOOL aAllowInteractiveLogon);
148
149 // wrapped IGuest methods
150 HRESULT createSession(const com::Utf8Str &aUser,
151 const com::Utf8Str &aPassword,
152 const com::Utf8Str &aDomain,
153 const com::Utf8Str &aSessionName,
154 ComPtr<IGuestSession> &aGuestSession);
155
156 HRESULT findSession(const com::Utf8Str &aSessionName,
157 std::vector<ComPtr<IGuestSession> > &aSessions);
158 HRESULT updateGuestAdditions(const com::Utf8Str &aSource,
159 const std::vector<com::Utf8Str> &aArguments,
160 const std::vector<AdditionsUpdateFlag_T> &aFlags,
161 ComPtr<IProgress> &aProgress);
162
163
164 /** @name Private internal methods.
165 * @{ */
166 void i_updateStats(uint64_t iTick);
167 static int i_staticEnumStatsCallback(const char *pszName, STAMTYPE enmType, void *pvSample, STAMUNIT enmUnit,
168 STAMVISIBILITY enmVisiblity, const char *pszDesc, void *pvUser);
169
170 /** @} */
171
172 typedef std::map< AdditionsFacilityType_T, ComObjPtr<AdditionsFacility> > FacilityMap;
173 typedef std::map< AdditionsFacilityType_T, ComObjPtr<AdditionsFacility> >::iterator FacilityMapIter;
174 typedef std::map< AdditionsFacilityType_T, ComObjPtr<AdditionsFacility> >::const_iterator FacilityMapIterConst;
175
176 /** Map for keeping the guest sessions. The primary key marks the guest session ID. */
177 typedef std::map <uint32_t, ComObjPtr<GuestSession> > GuestSessions;
178
179 struct Data
180 {
181 Data() : mOSType(VBOXOSTYPE_Unknown), mAdditionsRunLevel(AdditionsRunLevelType_None)
182 , mAdditionsVersionFull(0), mAdditionsRevision(0), mAdditionsFeatures(0)
183 { }
184
185 VBOXOSTYPE mOSType; /**@< For internal used. VBOXOSTYPE_Unknown if not reported. */
186 Utf8Str mOSTypeId;
187 FacilityMap mFacilityMap;
188 AdditionsRunLevelType_T mAdditionsRunLevel;
189 uint32_t mAdditionsVersionFull;
190 Utf8Str mAdditionsVersionNew;
191 uint32_t mAdditionsRevision;
192 uint32_t mAdditionsFeatures;
193 Utf8Str mInterfaceVersion;
194 GuestSessions mGuestSessions;
195 uint32_t mNextSessionID;
196 } mData;
197
198 ULONG mMemoryBalloonSize;
199 ULONG mStatUpdateInterval;
200 uint64_t mNetStatRx;
201 uint64_t mNetStatTx;
202 uint64_t mNetStatLastTs;
203 ULONG mCurrentGuestStat[GUESTSTATTYPE_MAX];
204 ULONG mVmValidStats;
205 BOOL mCollectVMMStats;
206 BOOL mfPageFusionEnabled;
207
208 const ComObjPtr<Console> mParent;
209
210#ifdef VBOX_WITH_GUEST_CONTROL
211 /**
212 * This can safely be used without holding any locks.
213 * An AutoCaller suffices to prevent it being destroy while in use and
214 * internally there is a lock providing the necessary serialization.
215 */
216 const ComObjPtr<EventSource> mEventSource;
217 /** General extension callback for guest control. */
218 HGCMSVCEXTHANDLE mhExtCtrl;
219#endif
220
221#ifdef VBOX_WITH_DRAG_AND_DROP
222 /** The guest's DnD source. */
223 const ComObjPtr<GuestDnDSource> mDnDSource;
224 /** The guest's DnD target. */
225 const ComObjPtr<GuestDnDTarget> mDnDTarget;
226#endif
227
228 RTTIMERLR mStatTimer;
229 uint32_t mMagic; /** @todo r=andy Rename this to something more meaningful. */
230};
231#define GUEST_MAGIC 0xCEED2006u /** @todo r=andy Not very well defined!? */
232
233#endif // ____H_GUESTIMPL
234
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