VirtualBox

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

Last change on this file since 56448 was 55644, checked in by vboxsync, 10 years ago

Main: Made it compile without VBOX_WITH_GUEST_CONTROL.

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