VirtualBox

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

Last change on this file since 49935 was 47310, checked in by vboxsync, 11 years ago

Build fix.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.8 KB
Line 
1/** @file
2 * VirtualBox COM class implementation
3 */
4
5/*
6 * Copyright (C) 2006-2013 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 "VirtualBoxBase.h"
21#include <iprt/list.h>
22#include <iprt/time.h>
23#include <VBox/ostypes.h>
24#include <VBox/vmm/stam.h>
25
26#include "AdditionsFacilityImpl.h"
27#include "GuestCtrlImplPrivate.h"
28#include "GuestSessionImpl.h"
29#include "HGCM.h"
30
31#ifdef VBOX_WITH_DRAG_AND_DROP
32class GuestDnD;
33#endif
34
35typedef enum
36{
37 GUESTSTATTYPE_CPUUSER = 0,
38 GUESTSTATTYPE_CPUKERNEL = 1,
39 GUESTSTATTYPE_CPUIDLE = 2,
40 GUESTSTATTYPE_MEMTOTAL = 3,
41 GUESTSTATTYPE_MEMFREE = 4,
42 GUESTSTATTYPE_MEMBALLOON = 5,
43 GUESTSTATTYPE_MEMCACHE = 6,
44 GUESTSTATTYPE_PAGETOTAL = 7,
45 GUESTSTATTYPE_PAGEFREE = 8,
46 GUESTSTATTYPE_MAX = 9
47} GUESTSTATTYPE;
48
49class Console;
50#ifdef VBOX_WITH_GUEST_CONTROL
51class Progress;
52#endif
53
54class ATL_NO_VTABLE Guest :
55 public VirtualBoxBase,
56 VBOX_SCRIPTABLE_IMPL(IGuest)
57{
58public:
59 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Guest, IGuest)
60
61 DECLARE_NOT_AGGREGATABLE(Guest)
62
63 DECLARE_PROTECT_FINAL_CONSTRUCT()
64
65 BEGIN_COM_MAP(Guest)
66 VBOX_DEFAULT_INTERFACE_ENTRIES(IGuest)
67 END_COM_MAP()
68
69 DECLARE_EMPTY_CTOR_DTOR (Guest)
70
71 HRESULT FinalConstruct(void);
72 void FinalRelease(void);
73
74 // Public initializer/uninitializer for internal purposes only.
75 HRESULT init (Console *aParent);
76 void uninit();
77
78 // IGuest properties.
79 STDMETHOD(COMGETTER(OSTypeId)) (BSTR *aOSTypeId);
80 STDMETHOD(COMGETTER(AdditionsRunLevel)) (AdditionsRunLevelType_T *aRunLevel);
81 STDMETHOD(COMGETTER(AdditionsVersion))(BSTR *a_pbstrAdditionsVersion);
82 STDMETHOD(COMGETTER(AdditionsRevision))(ULONG *a_puAdditionsRevision);
83 STDMETHOD(COMGETTER(EventSource))(IEventSource ** aEventSource);
84 STDMETHOD(COMGETTER(Facilities)) (ComSafeArrayOut(IAdditionsFacility *, aFacilities));
85 STDMETHOD(COMGETTER(Sessions)) (ComSafeArrayOut(IGuestSession *, aSessions));
86 STDMETHOD(COMGETTER(MemoryBalloonSize)) (ULONG *aMemoryBalloonSize);
87 STDMETHOD(COMSETTER(MemoryBalloonSize)) (ULONG aMemoryBalloonSize);
88 STDMETHOD(COMGETTER(StatisticsUpdateInterval)) (ULONG *aUpdateInterval);
89 STDMETHOD(COMSETTER(StatisticsUpdateInterval)) (ULONG aUpdateInterval);
90 // IGuest methods.
91 STDMETHOD(GetFacilityStatus)(AdditionsFacilityType_T aType, LONG64 *aTimestamp, AdditionsFacilityStatus_T *aStatus);
92 STDMETHOD(GetAdditionsStatus)(AdditionsRunLevelType_T aLevel, BOOL *aActive);
93 STDMETHOD(SetCredentials)(IN_BSTR aUsername, IN_BSTR aPassword,
94 IN_BSTR aDomain, BOOL aAllowInteractiveLogon);
95 // Drag'n drop support.
96 STDMETHOD(DragHGEnter)(ULONG uScreenId, ULONG uX, ULONG uY, DragAndDropAction_T defaultAction, ComSafeArrayIn(DragAndDropAction_T, allowedActions), ComSafeArrayIn(IN_BSTR, formats), DragAndDropAction_T *pResultAction);
97 STDMETHOD(DragHGMove)(ULONG uScreenId, ULONG uX, ULONG uY, DragAndDropAction_T defaultAction, ComSafeArrayIn(DragAndDropAction_T, allowedActions), ComSafeArrayIn(IN_BSTR, formats), DragAndDropAction_T *pResultAction);
98 STDMETHOD(DragHGLeave)(ULONG uScreenId);
99 STDMETHOD(DragHGDrop)(ULONG uScreenId, ULONG uX, ULONG uY, DragAndDropAction_T defaultAction, ComSafeArrayIn(DragAndDropAction_T, allowedActions), ComSafeArrayIn(IN_BSTR, formats), BSTR *pstrFormat, DragAndDropAction_T *pResultAction);
100 STDMETHOD(DragHGPutData)(ULONG uScreenId, IN_BSTR strFormat, ComSafeArrayIn(BYTE, data), IProgress **ppProgress);
101 STDMETHOD(DragGHPending)(ULONG uScreenId, ComSafeArrayOut(BSTR, formats), ComSafeArrayOut(DragAndDropAction_T, allowedActions), DragAndDropAction_T *pDefaultAction);
102 STDMETHOD(DragGHDropped)(IN_BSTR strFormat, DragAndDropAction_T action, IProgress **ppProgress);
103 STDMETHOD(DragGHGetData)(ComSafeArrayOut(BYTE, data));
104 // Guest control.
105 STDMETHOD(CreateSession)(IN_BSTR aUser, IN_BSTR aPassword, IN_BSTR aDomain, IN_BSTR aSessionName, IGuestSession **aGuestSession);
106 STDMETHOD(FindSession)(IN_BSTR aSessionName, ComSafeArrayOut(IGuestSession *, aSessions));
107 // Misc stuff
108 STDMETHOD(InternalGetStatistics)(ULONG *aCpuUser, ULONG *aCpuKernel, ULONG *aCpuIdle,
109 ULONG *aMemTotal, ULONG *aMemFree, ULONG *aMemBalloon, ULONG *aMemShared, ULONG *aMemCache,
110 ULONG *aPageTotal, ULONG *aMemAllocTotal, ULONG *aMemFreeTotal, ULONG *aMemBalloonTotal, ULONG *aMemSharedTotal);
111 STDMETHOD(UpdateGuestAdditions)(IN_BSTR aSource, ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(AdditionsUpdateFlag_T, aFlags), IProgress **aProgress);
112
113public:
114 /** @name Static internal methods.
115 * @{ */
116#ifdef VBOX_WITH_GUEST_CONTROL
117 /** Static callback for handling guest control notifications. */
118 static DECLCALLBACK(int) notifyCtrlDispatcher(void *pvExtension, uint32_t u32Function, void *pvData, uint32_t cbData);
119 static DECLCALLBACK(void) staticUpdateStats(RTTIMERLR hTimerLR, void *pvUser, uint64_t iTick);
120#endif
121 /** @} */
122
123public:
124 /** @name Public internal methods.
125 * @{ */
126 void enableVMMStatistics(BOOL aEnable) { mCollectVMMStats = aEnable; };
127 void setAdditionsInfo(Bstr aInterfaceVersion, VBOXOSTYPE aOsType);
128 void setAdditionsInfo2(uint32_t a_uFullVersion, const char *a_pszName, uint32_t a_uRevision, uint32_t a_fFeatures);
129 bool facilityIsActive(VBoxGuestFacilityType enmFacility);
130 void facilityUpdate(VBoxGuestFacilityType a_enmFacility, VBoxGuestFacilityStatus a_enmStatus, uint32_t a_fFlags, PCRTTIMESPEC a_pTimeSpecTS);
131 void setAdditionsStatus(VBoxGuestFacilityType a_enmFacility, VBoxGuestFacilityStatus a_enmStatus, uint32_t a_fFlags, PCRTTIMESPEC a_pTimeSpecTS);
132 void onUserStateChange(Bstr aUser, Bstr aDomain, VBoxGuestUserState enmState, const uint8_t *puDetails, uint32_t cbDetails);
133 void setSupportedFeatures(uint32_t aCaps);
134 HRESULT setStatistic(ULONG aCpuId, GUESTSTATTYPE enmType, ULONG aVal);
135 BOOL isPageFusionEnabled();
136 static HRESULT setErrorStatic(HRESULT aResultCode,
137 const Utf8Str &aText)
138 {
139 return setErrorInternal(aResultCode, getStaticClassIID(), getStaticComponentName(), aText, false, true);
140 }
141#ifdef VBOX_WITH_GUEST_CONTROL
142 int dispatchToSession(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
143 uint32_t getAdditionsVersion(void) { return mData.mAdditionsVersionFull; }
144 Console *getConsole(void) { return mParent; }
145 int sessionRemove(GuestSession *pSession);
146 int sessionCreate(const GuestSessionStartupInfo &ssInfo, const GuestCredentials &guestCreds, ComObjPtr<GuestSession> &pGuestSession);
147 inline bool sessionExists(uint32_t uSessionID);
148#endif
149 /** @} */
150
151private:
152 /** @name Private internal methods.
153 * @{ */
154 void updateStats(uint64_t iTick);
155 static int staticEnumStatsCallback(const char *pszName, STAMTYPE enmType, void *pvSample, STAMUNIT enmUnit,
156 STAMVISIBILITY enmVisiblity, const char *pszDesc, void *pvUser);
157 /** @} */
158
159 typedef std::map< AdditionsFacilityType_T, ComObjPtr<AdditionsFacility> > FacilityMap;
160 typedef std::map< AdditionsFacilityType_T, ComObjPtr<AdditionsFacility> >::iterator FacilityMapIter;
161 typedef std::map< AdditionsFacilityType_T, ComObjPtr<AdditionsFacility> >::const_iterator FacilityMapIterConst;
162
163 /** Map for keeping the guest sessions. The primary key marks the guest session ID. */
164 typedef std::map <uint32_t, ComObjPtr<GuestSession> > GuestSessions;
165
166 struct Data
167 {
168 Data() : mAdditionsRunLevel(AdditionsRunLevelType_None)
169 , mAdditionsVersionFull(0), mAdditionsRevision(0), mAdditionsFeatures(0)
170 { }
171
172 Bstr mOSTypeId;
173 FacilityMap mFacilityMap;
174 AdditionsRunLevelType_T mAdditionsRunLevel;
175 uint32_t mAdditionsVersionFull;
176 Bstr mAdditionsVersionNew;
177 uint32_t mAdditionsRevision;
178 uint32_t mAdditionsFeatures;
179 Bstr mInterfaceVersion;
180 GuestSessions mGuestSessions;
181 uint32_t mNextSessionID;
182 } mData;
183
184 ULONG mMemoryBalloonSize;
185 ULONG mStatUpdateInterval;
186 uint64_t mNetStatRx;
187 uint64_t mNetStatTx;
188 uint64_t mNetStatLastTs;
189 ULONG mCurrentGuestStat[GUESTSTATTYPE_MAX];
190 ULONG mVmValidStats;
191 BOOL mCollectVMMStats;
192 BOOL mfPageFusionEnabled;
193
194 Console *mParent;
195
196#ifdef VBOX_WITH_GUEST_CONTROL
197 /**
198 * This can safely be used without holding any locks.
199 * An AutoCaller suffices to prevent it being destroy while in use and
200 * internally there is a lock providing the necessary serialization.
201 */
202 const ComObjPtr<EventSource> mEventSource;
203 /** General extension callback for guest control. */
204 HGCMSVCEXTHANDLE mhExtCtrl;
205#endif
206
207#ifdef VBOX_WITH_DRAG_AND_DROP
208 GuestDnD *m_pGuestDnD;
209 friend class GuestDnD;
210 friend class GuestDnDPrivate;
211#endif
212
213 RTTIMERLR mStatTimer;
214 uint32_t mMagic;
215};
216#define GUEST_MAGIC 0xCEED2006u
217
218#endif // ____H_GUESTIMPL
219
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