VirtualBox

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

Last change on this file since 30760 was 30760, checked in by vboxsync, 15 years ago

Main: separate internal machine data structs into MachineImplPrivate.h to significantly speed up compilation and for better interface separation; remove obsolete ConsoleEvents.h file

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.3 KB
Line 
1/** @file
2 *
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2010 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 "VirtualBoxBase.h"
22#include <VBox/ostypes.h>
23
24#ifdef VBOX_WITH_GUEST_CONTROL
25# include <VBox/HostServices/GuestControlSvc.h>
26# include <hgcm/HGCM.h>
27using namespace guestControl;
28#endif
29
30typedef enum
31{
32 GUESTSTATTYPE_CPUUSER = 0,
33 GUESTSTATTYPE_CPUKERNEL = 1,
34 GUESTSTATTYPE_CPUIDLE = 2,
35 GUESTSTATTYPE_MEMTOTAL = 3,
36 GUESTSTATTYPE_MEMFREE = 4,
37 GUESTSTATTYPE_MEMBALLOON = 5,
38 GUESTSTATTYPE_MEMCACHE = 6,
39 GUESTSTATTYPE_PAGETOTAL = 7,
40 GUESTSTATTYPE_PAGEFREE = 8,
41 GUESTSTATTYPE_MAX = 9
42} GUESTSTATTYPE;
43
44class ATL_NO_VTABLE Guest :
45 public VirtualBoxBase,
46 VBOX_SCRIPTABLE_IMPL(IGuest)
47{
48public:
49 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Guest, IGuest)
50
51 DECLARE_NOT_AGGREGATABLE(Guest)
52
53 DECLARE_PROTECT_FINAL_CONSTRUCT()
54
55 BEGIN_COM_MAP(Guest)
56 COM_INTERFACE_ENTRY(ISupportErrorInfo)
57 COM_INTERFACE_ENTRY(IGuest)
58 COM_INTERFACE_ENTRY(IDispatch)
59 END_COM_MAP()
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 // IGuest properties
71 STDMETHOD(COMGETTER(OSTypeId)) (BSTR *aOSTypeId);
72#if 0
73 /** @todo Will replace old AdditionsActive call. */
74 STDMETHOD(COMGETTER(AdditionsActive)) (ULONG aLevel, BOOL *aAdditionsActive);
75#endif
76 STDMETHOD(COMGETTER(AdditionsActive)) (BOOL *aAdditionsActive);
77#if 0
78 /** @todo Will replace AdditionsVersion to be more clear. */
79 STDMETHOD(COMGETTER(AdditionsAPIVersion)) (BSTR *aAdditionsVersion);
80#endif
81 STDMETHOD(COMGETTER(AdditionsVersion)) (BSTR *aAdditionsVersion);
82 /** @todo Remove */
83 STDMETHOD(COMGETTER(SupportsSeamless)) (BOOL *aSupportsSeamless);
84 STDMETHOD(COMGETTER(SupportsGraphics)) (BOOL *aSupportsGraphics);
85#if 0
86 /** @todo Will replace SupportsSeamless, SupportsGraphics, ... */
87 STDMETHOD(COMGETTER(AdditionsFeatureAvailable)) (ULONG64 aFeature, BOOL *aActive, BOOL *aAvailable);
88#endif
89 STDMETHOD(COMGETTER(MemoryBalloonSize)) (ULONG *aMemoryBalloonSize);
90 STDMETHOD(COMSETTER(MemoryBalloonSize)) (ULONG aMemoryBalloonSize);
91 STDMETHOD(COMGETTER(PageFusionEnabled)) (BOOL *aPageFusionEnabled);
92 STDMETHOD(COMSETTER(PageFusionEnabled)) (BOOL aPageFusionEnabled);
93 STDMETHOD(COMGETTER(StatisticsUpdateInterval)) (ULONG *aUpdateInterval);
94 STDMETHOD(COMSETTER(StatisticsUpdateInterval)) (ULONG aUpdateInterval);
95
96 // IGuest methods
97 STDMETHOD(SetCredentials)(IN_BSTR aUserName, IN_BSTR aPassword,
98 IN_BSTR aDomain, BOOL aAllowInteractiveLogon);
99 STDMETHOD(ExecuteProcess)(IN_BSTR aCommand, ULONG aFlags,
100 ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
101 IN_BSTR aUserName, IN_BSTR aPassword,
102 ULONG aTimeoutMS, ULONG *aPID, IProgress **aProgress);
103 STDMETHOD(GetProcessOutput)(ULONG aPID, ULONG aFlags, ULONG aTimeoutMS, ULONG64 aSize, ComSafeArrayOut(BYTE, aData));
104 STDMETHOD(GetProcessStatus)(ULONG aPID, ULONG *aExitCode, ULONG *aFlags, ULONG *aStatus);
105 STDMETHOD(InternalGetStatistics)(ULONG *aCpuUser, ULONG *aCpuKernel, ULONG *aCpuIdle,
106 ULONG *aMemTotal, ULONG *aMemFree, ULONG *aMemBalloon, ULONG *aMemShared, ULONG *aMemCache,
107 ULONG *aPageTotal, ULONG *aMemAllocTotal, ULONG *aMemFreeTotal, ULONG *aMemBalloonTotal, ULONG *aMemSharedTotal);
108
109 // Public methods that are not in IDL (only called internally).
110 void setAdditionsInfo(Bstr aVersion, VBOXOSTYPE aOsType);
111 void setAdditionsStatus(ULONG ulFacility, ULONG ulStatus, ULONG ulFlags);
112 void setSupportedFeatures(ULONG64 ulCaps, ULONG64 ulActive);
113 HRESULT setStatistic(ULONG aCpuId, GUESTSTATTYPE enmType, ULONG aVal);
114
115# ifdef VBOX_WITH_GUEST_CONTROL
116 /** Static callback for handling guest notifications. */
117 static DECLCALLBACK(int) doGuestCtrlNotification(void *pvExtension, uint32_t u32Function, void *pvParms, uint32_t cbParms);
118# endif
119
120private:
121
122# ifdef VBOX_WITH_GUEST_CONTROL
123 struct CallbackContext
124 {
125 eVBoxGuestCtrlCallbackType mType;
126 /** Pointer to user-supplied data. */
127 void *pvData;
128 /** Size of user-supplied data. */
129 uint32_t cbData;
130 /** Pointer to user-supplied IProgress. */
131 ComObjPtr<Progress> pProgress;
132 };
133 /*
134 * The map key is the context ID.
135 */
136 typedef std::map< uint32_t, CallbackContext > CallbackMap;
137 typedef std::map< uint32_t, CallbackContext >::iterator CallbackMapIter;
138 typedef std::map< uint32_t, CallbackContext >::const_iterator CallbackMapIterConst;
139
140 struct GuestProcess
141 {
142 uint32_t mStatus;
143 uint32_t mFlags;
144 uint32_t mExitCode;
145 };
146 /*
147 * The map key is the PID (process identifier).
148 */
149 typedef std::map< uint32_t, GuestProcess > GuestProcessMap;
150 typedef std::map< uint32_t, GuestProcess >::iterator GuestProcessMapIter;
151 typedef std::map< uint32_t, GuestProcess >::const_iterator GuestProcessMapIterConst;
152
153 int prepareExecuteEnv(const char *pszEnv, void **ppvList, uint32_t *pcbList, uint32_t *pcEnv);
154 /** Handler for guest execution control notifications. */
155 int notifyCtrlClientDisconnected(uint32_t u32Function, PCALLBACKDATACLIENTDISCONNECTED pData);
156 int notifyCtrlExecStatus(uint32_t u32Function, PCALLBACKDATAEXECSTATUS pData);
157 int notifyCtrlExecOut(uint32_t u32Function, PCALLBACKDATAEXECOUT pData);
158 CallbackMapIter getCtrlCallbackContextByID(uint32_t u32ContextID);
159 GuestProcessMapIter getProcessByPID(uint32_t u32PID);
160 void destroyCtrlCallbackContext(CallbackMapIter it);
161 uint32_t addCtrlCallbackContext(eVBoxGuestCtrlCallbackType enmType, void *pvData, uint32_t cbData, Progress* pProgress);
162# endif
163
164 struct Data
165 {
166 Data() : mAdditionsActive (FALSE), mSupportsSeamless (FALSE),
167 mSupportsGraphics (FALSE) {}
168
169 Bstr mOSTypeId;
170 BOOL mAdditionsActive;
171 Bstr mAdditionsVersion;
172 BOOL mSupportsSeamless;
173 BOOL mSupportsGraphics;
174 };
175
176 ULONG mMemoryBalloonSize;
177 ULONG mStatUpdateInterval;
178 ULONG mCurrentGuestStat[GUESTSTATTYPE_MAX];
179 BOOL mfPageFusionEnabled;
180
181 Console *mParent;
182 Data mData;
183
184# ifdef VBOX_WITH_GUEST_CONTROL
185 /** General extension callback for guest control. */
186 HGCMSVCEXTHANDLE mhExtCtrl;
187
188 volatile uint32_t mNextContextID;
189 CallbackMap mCallbackMap;
190 GuestProcessMap mGuestProcessMap;
191# endif
192};
193
194#endif // ____H_GUESTIMPL
195/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette