1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
/** @file
*
* VirtualBox COM class implementation
*/
/*
* Copyright (C) 2006-2007 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* you can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#ifndef ____H_GUESTIMPL
#define ____H_GUESTIMPL
#include "VirtualBoxBase.h"
#include <VBox/ostypes.h>
#ifdef VBOX_WITH_GUEST_CONTROL
# include <VBox/HostServices/GuestControlSvc.h>
# include <hgcm/HGCM.h>
using namespace guestControl;
#endif
typedef enum
{
GUESTSTATTYPE_CPUUSER = 0,
GUESTSTATTYPE_CPUKERNEL = 1,
GUESTSTATTYPE_CPUIDLE = 2,
GUESTSTATTYPE_MEMTOTAL = 3,
GUESTSTATTYPE_MEMFREE = 4,
GUESTSTATTYPE_MEMBALLOON = 5,
GUESTSTATTYPE_MEMCACHE = 6,
GUESTSTATTYPE_PAGETOTAL = 7,
GUESTSTATTYPE_PAGEFREE = 8,
GUESTSTATTYPE_MAX = 9
} GUESTSTATTYPE;
class Console;
#ifdef VBOX_WITH_GUEST_CONTROL
class Progress;
#endif
class ATL_NO_VTABLE Guest :
public VirtualBoxSupportErrorInfoImpl<Guest, IGuest>,
public VirtualBoxSupportTranslation<Guest>,
public VirtualBoxBase,
VBOX_SCRIPTABLE_IMPL(IGuest)
{
public:
DECLARE_NOT_AGGREGATABLE(Guest)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(Guest)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
COM_INTERFACE_ENTRY(IGuest)
COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()
DECLARE_EMPTY_CTOR_DTOR (Guest)
HRESULT FinalConstruct();
void FinalRelease();
// public initializer/uninitializer for internal purposes only
HRESULT init (Console *aParent);
void uninit();
// IGuest properties
STDMETHOD(COMGETTER(OSTypeId)) (BSTR *aOSTypeId);
STDMETHOD(COMGETTER(AdditionsActive)) (BOOL *aAdditionsActive);
STDMETHOD(COMGETTER(AdditionsVersion)) (BSTR *aAdditionsVersion);
STDMETHOD(COMGETTER(SupportsSeamless)) (BOOL *aSupportsSeamless);
STDMETHOD(COMGETTER(SupportsGraphics)) (BOOL *aSupportsGraphics);
STDMETHOD(COMGETTER(PageFusionEnabled)) (BOOL *enabled);
STDMETHOD(COMSETTER(PageFusionEnabled)) (BOOL enabled);
STDMETHOD(COMGETTER(MemoryBalloonSize)) (ULONG *aMemoryBalloonSize);
STDMETHOD(COMSETTER(MemoryBalloonSize)) (ULONG aMemoryBalloonSize);
STDMETHOD(COMGETTER(StatisticsUpdateInterval)) (ULONG *aUpdateInterval);
STDMETHOD(COMSETTER(StatisticsUpdateInterval)) (ULONG aUpdateInterval);
// IGuest methods
STDMETHOD(SetCredentials)(IN_BSTR aUserName, IN_BSTR aPassword,
IN_BSTR aDomain, BOOL aAllowInteractiveLogon);
STDMETHOD(ExecuteProcess)(IN_BSTR aCommand, ULONG aFlags,
ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
IN_BSTR aStdIn, IN_BSTR aStdOut, IN_BSTR aStdErr,
IN_BSTR aUserName, IN_BSTR aPassword,
ULONG aTimeoutMS, ULONG *aPID, IProgress **aProgress);
STDMETHOD(GetProcessOutput)(ULONG aPID, ULONG aFlags, ULONG aTimeoutMS, ULONG64 aSize, ComSafeArrayOut(BYTE, aData));
STDMETHOD(GetProcessStatus)(ULONG aPID, ULONG *aExitCode, ULONG *aFlags, ULONG *aStatus);
STDMETHOD(InternalGetStatistics)(ULONG *aCpuUser, ULONG *aCpuKernel, ULONG *aCpuIdle,
ULONG *aMemTotal, ULONG *aMemFree, ULONG *aMemBalloon, ULONG *aMemShared, ULONG *aMemCache,
ULONG *aPageTotal, ULONG *aMemAllocTotal, ULONG *aMemFreeTotal, ULONG *aMemBalloonTotal, ULONG *aMemSharedTotal);
// public methods that are not in IDL
void setAdditionsVersion (Bstr aVersion, VBOXOSTYPE aOsType);
void setSupportsSeamless (BOOL aSupportsSeamless);
void setSupportsGraphics (BOOL aSupportsGraphics);
HRESULT SetStatistic(ULONG aCpuId, GUESTSTATTYPE enmType, ULONG aVal);
// for VirtualBoxSupportErrorInfoImpl
static const wchar_t *getComponentName() { return L"Guest"; }
# ifdef VBOX_WITH_GUEST_CONTROL
/** Static callback for handling guest notifications. */
static DECLCALLBACK(int) doGuestCtrlNotification(void *pvExtension, uint32_t u32Function, void *pvParms, uint32_t cbParms);
# endif
private:
# ifdef VBOX_WITH_GUEST_CONTROL
struct CallbackContext
{
uint32_t mContextID;
eVBoxGuestCtrlCallbackType mType;
void *pvData;
uint32_t cbData;
/** Atomic flag whether callback was called. */
volatile bool bCalled;
/** Pointer to user-supplied IProgress. */
ComObjPtr<Progress> pProgress;
};
typedef std::list< CallbackContext > CallbackList;
typedef std::list< CallbackContext >::iterator CallbackListIter;
typedef std::list< CallbackContext >::const_iterator CallbackListIterConst;
struct GuestProcess
{
uint32_t mPID;
uint32_t mStatus;
uint32_t mFlags;
uint32_t mExitCode;
};
typedef std::list< GuestProcess > GuestProcessList;
typedef std::list< GuestProcess >::iterator GuestProcessIter;
typedef std::list< GuestProcess >::const_iterator GuestProcessIterConst;
int prepareExecuteEnv(const char *pszEnv, void **ppvList, uint32_t *pcbList, uint32_t *pcEnv);
/** Handler for guest execution control notifications. */
int notifyCtrlExec(uint32_t u32Function, PHOSTEXECCALLBACKDATA pData);
int notifyCtrlExecOut(uint32_t u32Function, PHOSTEXECOUTCALLBACKDATA pData);
CallbackListIter getCtrlCallbackContextByID(uint32_t u32ContextID);
GuestProcessIter getProcessByPID(uint32_t u32PID);
void destroyCtrlCallbackContext(CallbackListIter it);
uint32_t addCtrlCallbackContext(eVBoxGuestCtrlCallbackType enmType, void *pvData, uint32_t cbData, Progress* pProgress);
# endif
struct Data
{
Data() : mAdditionsActive (FALSE), mSupportsSeamless (FALSE),
mSupportsGraphics (FALSE) {}
Bstr mOSTypeId;
BOOL mAdditionsActive;
Bstr mAdditionsVersion;
BOOL mSupportsSeamless;
BOOL mSupportsGraphics;
};
ULONG mMemoryBalloonSize;
ULONG mStatUpdateInterval;
ULONG mCurrentGuestStat[GUESTSTATTYPE_MAX];
Console *mParent;
Data mData;
# ifdef VBOX_WITH_GUEST_CONTROL
/** General extension callback for guest control. */
HGCMSVCEXTHANDLE mhExtCtrl;
volatile uint32_t mNextContextID;
CallbackList mCallbackList;
GuestProcessList mGuestProcessList;
# endif
};
#endif // ____H_GUESTIMPL
/* vi: set tabstop=4 shiftwidth=4 expandtab: */
|