VirtualBox

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

Last change on this file since 53390 was 52082, checked in by vboxsync, 10 years ago

6813 - DisplayImpl using COM Wrappers

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