VirtualBox

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

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

Guest Control/Main: Added local process list, added early implementation of IGuest::GetProcessStatus().

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.9 KB
Line 
1/** @file
2 *
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#ifndef ____H_GUESTIMPL
23#define ____H_GUESTIMPL
24
25#include "VirtualBoxBase.h"
26#include <VBox/ostypes.h>
27
28#ifdef VBOX_WITH_GUEST_CONTROL
29# include <VBox/HostServices/GuestControlSvc.h>
30# include <hgcm/HGCM.h>
31using namespace guestControl;
32#endif
33
34typedef enum
35{
36 GUESTSTATTYPE_CPUUSER = 0,
37 GUESTSTATTYPE_CPUKERNEL = 1,
38 GUESTSTATTYPE_CPUIDLE = 2,
39 GUESTSTATTYPE_MEMTOTAL = 3,
40 GUESTSTATTYPE_MEMFREE = 4,
41 GUESTSTATTYPE_MEMBALLOON = 5,
42 GUESTSTATTYPE_MEMCACHE = 6,
43 GUESTSTATTYPE_PAGETOTAL = 7,
44 GUESTSTATTYPE_PAGEFREE = 8,
45 GUESTSTATTYPE_MAX = 9
46} GUESTSTATTYPE;
47
48class Console;
49#ifdef VBOX_WITH_GUEST_CONTROL
50class Progress;
51#endif
52
53class ATL_NO_VTABLE Guest :
54 public VirtualBoxSupportErrorInfoImpl<Guest, IGuest>,
55 public VirtualBoxSupportTranslation<Guest>,
56 public VirtualBoxBase,
57 VBOX_SCRIPTABLE_IMPL(IGuest)
58{
59public:
60
61 DECLARE_NOT_AGGREGATABLE(Guest)
62
63 DECLARE_PROTECT_FINAL_CONSTRUCT()
64
65 BEGIN_COM_MAP(Guest)
66 COM_INTERFACE_ENTRY(ISupportErrorInfo)
67 COM_INTERFACE_ENTRY(IGuest)
68 COM_INTERFACE_ENTRY(IDispatch)
69 END_COM_MAP()
70
71 DECLARE_EMPTY_CTOR_DTOR (Guest)
72
73 HRESULT FinalConstruct();
74 void FinalRelease();
75
76 // public initializer/uninitializer for internal purposes only
77 HRESULT init (Console *aParent);
78 void uninit();
79
80 // IGuest properties
81 STDMETHOD(COMGETTER(OSTypeId)) (BSTR *aOSTypeId);
82 STDMETHOD(COMGETTER(AdditionsActive)) (BOOL *aAdditionsActive);
83 STDMETHOD(COMGETTER(AdditionsVersion)) (BSTR *aAdditionsVersion);
84 STDMETHOD(COMGETTER(SupportsSeamless)) (BOOL *aSupportsSeamless);
85 STDMETHOD(COMGETTER(SupportsGraphics)) (BOOL *aSupportsGraphics);
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
91 // IGuest methods
92 STDMETHOD(SetCredentials)(IN_BSTR aUserName, IN_BSTR aPassword,
93 IN_BSTR aDomain, BOOL aAllowInteractiveLogon);
94 STDMETHOD(ExecuteProcess)(IN_BSTR aCommand, ULONG aFlags,
95 ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
96 IN_BSTR aStdIn, IN_BSTR aStdOut, IN_BSTR aStdErr,
97 IN_BSTR aUserName, IN_BSTR aPassword,
98 ULONG aTimeoutMS, ULONG *aPID, IProgress **aProgress);
99 STDMETHOD(GetProcessOutput)(ULONG aPID, ULONG aFlags, ULONG aTimeoutMS, ULONG64 aSize, ComSafeArrayOut(BYTE, aData));
100 STDMETHOD(GetProcessStatus)(ULONG aPID, ULONG *aReason, ULONG *aExitCode, ULONG *aStatus);
101 STDMETHOD(InternalGetStatistics)(ULONG *aCpuUser, ULONG *aCpuKernel, ULONG *aCpuIdle,
102 ULONG *aMemTotal, ULONG *aMemFree, ULONG *aMemBalloon, ULONG *aMemCache,
103 ULONG *aPageTotal, ULONG *aMemAllocTotal, ULONG *aMemFreeTotal, ULONG *aMemBalloonTotal);
104
105 // public methods that are not in IDL
106 void setAdditionsVersion (Bstr aVersion, VBOXOSTYPE aOsType);
107
108 void setSupportsSeamless (BOOL aSupportsSeamless);
109
110 void setSupportsGraphics (BOOL aSupportsGraphics);
111
112 HRESULT SetStatistic(ULONG aCpuId, GUESTSTATTYPE enmType, ULONG aVal);
113
114 // for VirtualBoxSupportErrorInfoImpl
115 static const wchar_t *getComponentName() { return L"Guest"; }
116
117# ifdef VBOX_WITH_GUEST_CONTROL
118 /** Static callback for handling guest notifications. */
119 static DECLCALLBACK(int) doGuestCtrlNotification(void *pvExtension, uint32_t u32Function, void *pvParms, uint32_t cbParms);
120# endif
121
122private:
123
124# ifdef VBOX_WITH_GUEST_CONTROL
125 struct CallbackContext
126 {
127 uint32_t mContextID;
128 eVBoxGuestCtrlCallbackType mType;
129 void *pvData;
130 uint32_t cbData;
131 /** Atomic flag whether callback was called. */
132 volatile bool bCalled;
133 /** Pointer to user-supplied IProgress. */
134 ComObjPtr<Progress> pProgress;
135 };
136 typedef std::list< CallbackContext > CallbackList;
137 typedef std::list< CallbackContext >::iterator CallbackListIter;
138 typedef std::list< CallbackContext >::const_iterator CallbackListIterConst;
139
140 struct GuestProcess
141 {
142 uint32_t mPID;
143 uint32_t mStatus;
144 uint32_t mReason;
145 uint32_t mExitCode;
146 };
147 typedef std::list< GuestProcess > GuestProcessList;
148 typedef std::list< GuestProcess >::iterator GuestProcessIter;
149 typedef std::list< GuestProcess >::const_iterator GuestProcessIterConst;
150
151 int prepareExecuteEnv(const char *pszEnv, void **ppvList, uint32_t *pcbList, uint32_t *pcEnv);
152 /** Handler for guest execution control notifications. */
153 int notifyCtrlExec(uint32_t u32Function, PHOSTEXECCALLBACKDATA pData);
154 int notifyCtrlExecOut(uint32_t u32Function, PHOSTEXECOUTCALLBACKDATA pData);
155 CallbackListIter getCtrlCallbackContextByID(uint32_t u32ContextID);
156 GuestProcessIter getProcessByPID(uint32_t u32PID);
157 void removeCtrlCallbackContext(CallbackListIter it);
158 uint32_t addCtrlCallbackContext(eVBoxGuestCtrlCallbackType enmType, void *pvData, uint32_t cbData, Progress* pProgress);
159# endif
160
161 struct Data
162 {
163 Data() : mAdditionsActive (FALSE), mSupportsSeamless (FALSE),
164 mSupportsGraphics (FALSE) {}
165
166 Bstr mOSTypeId;
167 BOOL mAdditionsActive;
168 Bstr mAdditionsVersion;
169 BOOL mSupportsSeamless;
170 BOOL mSupportsGraphics;
171 };
172
173 ULONG mMemoryBalloonSize;
174 ULONG mStatUpdateInterval;
175 ULONG mCurrentGuestStat[GUESTSTATTYPE_MAX];
176
177 Console *mParent;
178 Data mData;
179
180# ifdef VBOX_WITH_GUEST_CONTROL
181 /** General extension callback for guest control. */
182 HGCMSVCEXTHANDLE mhExtCtrl;
183
184 volatile uint32_t mNextContextID;
185 CallbackList mCallbackList;
186 GuestProcessList mGuestProcessList;
187# endif
188};
189
190#endif // ____H_GUESTIMPL
191/* vi: set tabstop=4 shiftwidth=4 expandtab: */
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