VirtualBox

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

Last change on this file since 55437 was 55401, checked in by vboxsync, 10 years ago

added a couple of missing Id headers

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.6 KB
Line 
1/* $Id: GuestImpl.h 55401 2015-04-23 10:03:17Z 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 int i_sessionRemove(GuestSession *pSession);
102 int i_sessionCreate(const GuestSessionStartupInfo &ssInfo, const GuestCredentials &guestCreds,
103 ComObjPtr<GuestSession> &pGuestSession);
104 inline bool i_sessionExists(uint32_t uSessionID);
105
106#endif
107 /** @} */
108
109private:
110
111 // wrapped IGuest properties
112 HRESULT getOSTypeId(com::Utf8Str &aOSTypeId);
113 HRESULT getAdditionsRunLevel(AdditionsRunLevelType_T *aAdditionsRunLevel);
114 HRESULT getAdditionsVersion(com::Utf8Str &aAdditionsVersion);
115 HRESULT getAdditionsRevision(ULONG *aAdditionsRevision);
116 HRESULT getDnDSource(ComPtr<IGuestDnDSource> &aDnDSource);
117 HRESULT getDnDTarget(ComPtr<IGuestDnDTarget> &aDnDTarget);
118 HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
119 HRESULT getFacilities(std::vector<ComPtr<IAdditionsFacility> > &aFacilities);
120 HRESULT getSessions(std::vector<ComPtr<IGuestSession> > &aSessions);
121 HRESULT getMemoryBalloonSize(ULONG *aMemoryBalloonSize);
122 HRESULT setMemoryBalloonSize(ULONG aMemoryBalloonSize);
123 HRESULT getStatisticsUpdateInterval(ULONG *aStatisticsUpdateInterval);
124 HRESULT setStatisticsUpdateInterval(ULONG aStatisticsUpdateInterval);
125 HRESULT internalGetStatistics(ULONG *aCpuUser,
126 ULONG *aCpuKernel,
127 ULONG *aCpuIdle,
128 ULONG *aMemTotal,
129 ULONG *aMemFree,
130 ULONG *aMemBalloon,
131 ULONG *aMemShared,
132 ULONG *aMemCache,
133 ULONG *aPagedTotal,
134 ULONG *aMemAllocTotal,
135 ULONG *aMemFreeTotal,
136 ULONG *aMemBalloonTotal,
137 ULONG *aMemSharedTotal);
138 HRESULT getFacilityStatus(AdditionsFacilityType_T aFacility,
139 LONG64 *aTimestamp,
140 AdditionsFacilityStatus_T *aStatus);
141 HRESULT getAdditionsStatus(AdditionsRunLevelType_T aLevel,
142 BOOL *aActive);
143 HRESULT setCredentials(const com::Utf8Str &aUserName,
144 const com::Utf8Str &aPassword,
145 const com::Utf8Str &aDomain,
146 BOOL aAllowInteractiveLogon);
147
148 // wrapped IGuest methods
149 HRESULT createSession(const com::Utf8Str &aUser,
150 const com::Utf8Str &aPassword,
151 const com::Utf8Str &aDomain,
152 const com::Utf8Str &aSessionName,
153 ComPtr<IGuestSession> &aGuestSession);
154
155 HRESULT findSession(const com::Utf8Str &aSessionName,
156 std::vector<ComPtr<IGuestSession> > &aSessions);
157 HRESULT updateGuestAdditions(const com::Utf8Str &aSource,
158 const std::vector<com::Utf8Str> &aArguments,
159 const std::vector<AdditionsUpdateFlag_T> &aFlags,
160 ComPtr<IProgress> &aProgress);
161
162
163 /** @name Private internal methods.
164 * @{ */
165 void i_updateStats(uint64_t iTick);
166 static int i_staticEnumStatsCallback(const char *pszName, STAMTYPE enmType, void *pvSample, STAMUNIT enmUnit,
167 STAMVISIBILITY enmVisiblity, const char *pszDesc, void *pvUser);
168
169 /** @} */
170
171 typedef std::map< AdditionsFacilityType_T, ComObjPtr<AdditionsFacility> > FacilityMap;
172 typedef std::map< AdditionsFacilityType_T, ComObjPtr<AdditionsFacility> >::iterator FacilityMapIter;
173 typedef std::map< AdditionsFacilityType_T, ComObjPtr<AdditionsFacility> >::const_iterator FacilityMapIterConst;
174
175 /** Map for keeping the guest sessions. The primary key marks the guest session ID. */
176 typedef std::map <uint32_t, ComObjPtr<GuestSession> > GuestSessions;
177
178 struct Data
179 {
180 Data() : mAdditionsRunLevel(AdditionsRunLevelType_None)
181 , mAdditionsVersionFull(0), mAdditionsRevision(0), mAdditionsFeatures(0)
182 { }
183
184 Utf8Str mOSTypeId;
185 FacilityMap mFacilityMap;
186 AdditionsRunLevelType_T mAdditionsRunLevel;
187 uint32_t mAdditionsVersionFull;
188 Utf8Str mAdditionsVersionNew;
189 uint32_t mAdditionsRevision;
190 uint32_t mAdditionsFeatures;
191 Utf8Str mInterfaceVersion;
192 GuestSessions mGuestSessions;
193 uint32_t mNextSessionID;
194 } mData;
195
196 ULONG mMemoryBalloonSize;
197 ULONG mStatUpdateInterval;
198 uint64_t mNetStatRx;
199 uint64_t mNetStatTx;
200 uint64_t mNetStatLastTs;
201 ULONG mCurrentGuestStat[GUESTSTATTYPE_MAX];
202 ULONG mVmValidStats;
203 BOOL mCollectVMMStats;
204 BOOL mfPageFusionEnabled;
205
206 const ComObjPtr<Console> mParent;
207
208#ifdef VBOX_WITH_GUEST_CONTROL
209 /**
210 * This can safely be used without holding any locks.
211 * An AutoCaller suffices to prevent it being destroy while in use and
212 * internally there is a lock providing the necessary serialization.
213 */
214 const ComObjPtr<EventSource> mEventSource;
215 /** General extension callback for guest control. */
216 HGCMSVCEXTHANDLE mhExtCtrl;
217#endif
218
219#ifdef VBOX_WITH_DRAG_AND_DROP
220 /** The guest's DnD source. */
221 const ComObjPtr<GuestDnDSource> mDnDSource;
222 /** The guest's DnD target. */
223 const ComObjPtr<GuestDnDTarget> mDnDTarget;
224#endif
225
226 RTTIMERLR mStatTimer;
227 uint32_t mMagic; /** @todo r=andy Rename this to something more meaningful. */
228};
229#define GUEST_MAGIC 0xCEED2006u /** @todo r=andy Not very well defined!? */
230
231#endif // ____H_GUESTIMPL
232
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