VirtualBox

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

Last change on this file since 43908 was 43908, checked in by vboxsync, 12 years ago

Main/Metrics: VM network rate metrics (#6345)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.2 KB
Line 
1/** @file
2 * VirtualBox COM class implementation
3 */
4
5/*
6 * Copyright (C) 2006-2012 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(Facilities)) (ComSafeArrayOut(IAdditionsFacility *, aFacilities));
84 STDMETHOD(COMGETTER(Sessions)) (ComSafeArrayOut(IGuestSession *, aSessions));
85 STDMETHOD(COMGETTER(MemoryBalloonSize)) (ULONG *aMemoryBalloonSize);
86 STDMETHOD(COMSETTER(MemoryBalloonSize)) (ULONG aMemoryBalloonSize);
87 STDMETHOD(COMGETTER(StatisticsUpdateInterval)) (ULONG *aUpdateInterval);
88 STDMETHOD(COMSETTER(StatisticsUpdateInterval)) (ULONG aUpdateInterval);
89 // IGuest methods.
90 STDMETHOD(GetFacilityStatus)(AdditionsFacilityType_T aType, LONG64 *aTimestamp, AdditionsFacilityStatus_T *aStatus);
91 STDMETHOD(GetAdditionsStatus)(AdditionsRunLevelType_T aLevel, BOOL *aActive);
92 STDMETHOD(SetCredentials)(IN_BSTR aUsername, IN_BSTR aPassword,
93 IN_BSTR aDomain, BOOL aAllowInteractiveLogon);
94 // Drag'n drop support.
95 STDMETHOD(DragHGEnter)(ULONG uScreenId, ULONG uX, ULONG uY, DragAndDropAction_T defaultAction, ComSafeArrayIn(DragAndDropAction_T, allowedActions), ComSafeArrayIn(IN_BSTR, formats), DragAndDropAction_T *pResultAction);
96 STDMETHOD(DragHGMove)(ULONG uScreenId, ULONG uX, ULONG uY, DragAndDropAction_T defaultAction, ComSafeArrayIn(DragAndDropAction_T, allowedActions), ComSafeArrayIn(IN_BSTR, formats), DragAndDropAction_T *pResultAction);
97 STDMETHOD(DragHGLeave)(ULONG uScreenId);
98 STDMETHOD(DragHGDrop)(ULONG uScreenId, ULONG uX, ULONG uY, DragAndDropAction_T defaultAction, ComSafeArrayIn(DragAndDropAction_T, allowedActions), ComSafeArrayIn(IN_BSTR, formats), BSTR *pstrFormat, DragAndDropAction_T *pResultAction);
99 STDMETHOD(DragHGPutData)(ULONG uScreenId, IN_BSTR strFormat, ComSafeArrayIn(BYTE, data), IProgress **ppProgress);
100 STDMETHOD(DragGHPending)(ULONG uScreenId, ComSafeArrayOut(BSTR, formats), ComSafeArrayOut(DragAndDropAction_T, allowedActions), DragAndDropAction_T *pDefaultAction);
101 STDMETHOD(DragGHDropped)(IN_BSTR strFormat, DragAndDropAction_T action, IProgress **ppProgress);
102 STDMETHOD(DragGHGetData)(ComSafeArrayOut(BYTE, data));
103 // Misc stuff
104 STDMETHOD(InternalGetStatistics)(ULONG *aCpuUser, ULONG *aCpuKernel, ULONG *aCpuIdle,
105 ULONG *aMemTotal, ULONG *aMemFree, ULONG *aMemBalloon, ULONG *aMemShared, ULONG *aMemCache,
106 ULONG *aPageTotal, ULONG *aMemAllocTotal, ULONG *aMemFreeTotal, ULONG *aMemBalloonTotal, ULONG *aMemSharedTotal);
107 STDMETHOD(UpdateGuestAdditions)(IN_BSTR aSource, ComSafeArrayIn(AdditionsUpdateFlag_T, aFlags), IProgress **aProgress);
108 STDMETHOD(CreateSession)(IN_BSTR aUser, IN_BSTR aPassword, IN_BSTR aDomain, IN_BSTR aSessionName, IGuestSession **aGuestSession);
109 STDMETHOD(FindSession)(IN_BSTR aSessionName, ComSafeArrayOut(IGuestSession *, aSessions));
110
111public:
112 /** @name Static internal methods.
113 * @{ */
114#ifdef VBOX_WITH_GUEST_CONTROL
115 /** Static callback for handling guest control notifications. */
116 static DECLCALLBACK(int) notifyCtrlDispatcher(void *pvExtension, uint32_t u32Function, void *pvParms, uint32_t cbParms);
117 static void staticUpdateStats(RTTIMERLR hTimerLR, void *pvUser, uint64_t iTick);
118#endif
119 /** @} */
120
121public:
122 /** @name Public internal methods.
123 * @{ */
124 void enableVMMStatistics(BOOL aEnable) { mCollectVMMStats = aEnable; };
125 void setAdditionsInfo(Bstr aInterfaceVersion, VBOXOSTYPE aOsType);
126 void setAdditionsInfo2(uint32_t a_uFullVersion, const char *a_pszName, uint32_t a_uRevision, uint32_t a_fFeatures);
127 bool facilityIsActive(VBoxGuestFacilityType enmFacility);
128 void facilityUpdate(VBoxGuestFacilityType a_enmFacility, VBoxGuestFacilityStatus a_enmStatus, uint32_t a_fFlags, PCRTTIMESPEC a_pTimeSpecTS);
129 void setAdditionsStatus(VBoxGuestFacilityType a_enmFacility, VBoxGuestFacilityStatus a_enmStatus, uint32_t a_fFlags, PCRTTIMESPEC a_pTimeSpecTS);
130 void setSupportedFeatures(uint32_t aCaps);
131 HRESULT setStatistic(ULONG aCpuId, GUESTSTATTYPE enmType, ULONG aVal);
132 BOOL isPageFusionEnabled();
133 static HRESULT setErrorStatic(HRESULT aResultCode,
134 const Utf8Str &aText)
135 {
136 return setErrorInternal(aResultCode, getStaticClassIID(), getStaticComponentName(), aText, false, true);
137 }
138#ifdef VBOX_WITH_GUEST_CONTROL
139 int dispatchToSession(uint32_t uContextID, uint32_t uFunction, void *pvData, size_t cbData);
140 uint32_t getAdditionsVersion(void) { return mData.mAdditionsVersionFull; }
141 Console *getConsole(void) { return mParent; }
142 int sessionRemove(GuestSession *pSession);
143 int sessionCreate(const Utf8Str &strUser, const Utf8Str &strPassword, const Utf8Str &strDomain,
144 const Utf8Str &strSessionName, ComObjPtr<GuestSession> &pGuestSession);
145 inline bool sessionExists(uint32_t uSessionID);
146#endif
147 /** @} */
148
149private:
150 /** @name Private internal methods.
151 * @{ */
152 void updateStats(uint64_t iTick);
153 static int staticEnumStatsCallback(const char *pszName, STAMTYPE enmType, void *pvSample, STAMUNIT enmUnit,
154 STAMVISIBILITY enmVisiblity, const char *pszDesc, void *pvUser);
155 /** @} */
156
157 typedef std::map< AdditionsFacilityType_T, ComObjPtr<AdditionsFacility> > FacilityMap;
158 typedef std::map< AdditionsFacilityType_T, ComObjPtr<AdditionsFacility> >::iterator FacilityMapIter;
159 typedef std::map< AdditionsFacilityType_T, ComObjPtr<AdditionsFacility> >::const_iterator FacilityMapIterConst;
160
161 /** Map for keeping the guest sessions. The primary key marks the guest session ID. */
162 typedef std::map <uint32_t, ComObjPtr<GuestSession> > GuestSessions;
163
164 struct Data
165 {
166 Data() : mAdditionsRunLevel(AdditionsRunLevelType_None)
167 , mAdditionsVersionFull(0), mAdditionsRevision(0), mAdditionsFeatures(0)
168 { }
169
170 Bstr mOSTypeId;
171 FacilityMap mFacilityMap;
172 AdditionsRunLevelType_T mAdditionsRunLevel;
173 uint32_t mAdditionsVersionFull;
174 Bstr mAdditionsVersionNew;
175 uint32_t mAdditionsRevision;
176 uint32_t mAdditionsFeatures;
177 Bstr mInterfaceVersion;
178 GuestSessions mGuestSessions;
179 uint32_t mNextSessionID;
180 };
181
182 ULONG mMemoryBalloonSize;
183 ULONG mStatUpdateInterval;
184 uint64_t mNetStatRx;
185 uint64_t mNetStatTx;
186 uint64_t mNetStatLastTs;
187 ULONG mCurrentGuestStat[GUESTSTATTYPE_MAX];
188 ULONG mVmValidStats;
189 BOOL mCollectVMMStats;
190 BOOL mfPageFusionEnabled;
191
192 Console *mParent;
193 Data mData;
194
195#ifdef VBOX_WITH_GUEST_CONTROL
196 /** General extension callback for guest control. */
197 HGCMSVCEXTHANDLE mhExtCtrl;
198#endif
199
200#ifdef VBOX_WITH_DRAG_AND_DROP
201 GuestDnD *m_pGuestDnD;
202 friend class GuestDnD;
203 friend class GuestDnDPrivate;
204#endif
205
206 RTTIMERLR mStatTimer;
207 uint32_t mMagic;
208};
209#define GUEST_MAGIC 0xCEED2006u
210
211#endif // ____H_GUESTIMPL
212
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