VirtualBox

source: vbox/trunk/src/VBox/Main/include/HostImpl.h@ 107044

Last change on this file since 107044 was 106061, checked in by vboxsync, 2 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.2 KB
Line 
1/* $Id: HostImpl.h 106061 2024-09-16 14:03:52Z vboxsync $ */
2/** @file
3 * Implementation of IHost.
4 */
5
6/*
7 * Copyright (C) 2006-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef MAIN_INCLUDED_HostImpl_h
29#define MAIN_INCLUDED_HostImpl_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#include "HostWrap.h"
35
36class HostUSBDeviceFilter;
37class USBProxyService;
38class SessionMachine;
39class Progress;
40class PerformanceCollector;
41class HostDrive;
42class HostDrivePartition;
43
44namespace settings
45{
46 struct Host;
47}
48
49#include <list>
50
51class ATL_NO_VTABLE Host :
52 public HostWrap
53{
54public:
55
56 DECLARE_COMMON_CLASS_METHODS(Host)
57
58 HRESULT FinalConstruct();
59 void FinalRelease();
60
61 // public initializer/uninitializer for internal purposes only
62 HRESULT init(VirtualBox *aParent);
63 void uninit();
64
65 // public methods only for internal purposes
66
67 /**
68 * Override of the default locking class to be used for validating lock
69 * order with the standard member lock handle.
70 */
71 virtual VBoxLockingClass getLockingClass() const
72 {
73 return LOCKCLASS_HOSTOBJECT;
74 }
75
76 HRESULT i_loadSettings(const settings::Host &data);
77 HRESULT i_saveSettings(settings::Host &data);
78
79 void i_updateProcessorFeatures();
80
81 HRESULT i_getDrives(DeviceType_T mediumType, bool fRefresh, MediaList *&pll, AutoWriteLock &treeLock);
82 HRESULT i_findHostDriveById(DeviceType_T mediumType, const Guid &uuid, bool fRefresh, ComObjPtr<Medium> &pMedium);
83 HRESULT i_findHostDriveByName(DeviceType_T mediumType, const Utf8Str &strLocationFull, bool fRefresh, ComObjPtr<Medium> &pMedium);
84
85#ifdef VBOX_WITH_USB
86 typedef std::list< ComObjPtr<HostUSBDeviceFilter> > USBDeviceFilterList;
87
88 /** Must be called from under this object's lock. */
89 USBProxyService* i_usbProxyService();
90
91 HRESULT i_addChild(HostUSBDeviceFilter *pChild);
92 HRESULT i_removeChild(HostUSBDeviceFilter *pChild);
93 VirtualBox* i_parent();
94
95 HRESULT i_onUSBDeviceFilterChange(HostUSBDeviceFilter *aFilter, BOOL aActiveChanged = FALSE);
96 void i_getUSBFilters(USBDeviceFilterList *aGlobalFiltes);
97 HRESULT i_checkUSBProxyService();
98#endif /* !VBOX_WITH_USB */
99
100 static void i_generateMACAddress(Utf8Str &mac);
101 static PlatformArchitecture_T s_getPlatformArchitecture();
102
103#ifdef RT_OS_WINDOWS
104 HRESULT i_updatePersistentConfigForHostOnlyAdapters(void);
105 HRESULT i_removePersistentConfig(const Bstr &bstrGuid);
106#endif /* RT_OS_WINDOWS */
107
108
109private:
110
111 // wrapped IHost properties
112 HRESULT getArchitecture(PlatformArchitecture_T *platformArchitecture);
113 HRESULT getDVDDrives(std::vector<ComPtr<IMedium> > &aDVDDrives);
114 HRESULT getFloppyDrives(std::vector<ComPtr<IMedium> > &aFloppyDrives);
115 HRESULT getAudioDevices(std::vector<ComPtr<IHostAudioDevice> > &aAudioDevices);
116 HRESULT getUSBDevices(std::vector<ComPtr<IHostUSBDevice> > &aUSBDevices);
117 HRESULT getUSBDeviceFilters(std::vector<ComPtr<IHostUSBDeviceFilter> > &aUSBDeviceFilters);
118 HRESULT getNetworkInterfaces(std::vector<ComPtr<IHostNetworkInterface> > &aNetworkInterfaces);
119 HRESULT getNameServers(std::vector<com::Utf8Str> &aNameServers);
120 HRESULT getDomainName(com::Utf8Str &aDomainName);
121 HRESULT getSearchStrings(std::vector<com::Utf8Str> &aSearchStrings);
122 HRESULT getProcessorCount(ULONG *aProcessorCount);
123 HRESULT getProcessorOnlineCount(ULONG *aProcessorOnlineCount);
124 HRESULT getProcessorCoreCount(ULONG *aProcessorCoreCount);
125 HRESULT getProcessorOnlineCoreCount(ULONG *aProcessorOnlineCoreCount);
126 HRESULT getHostDrives(std::vector<ComPtr<IHostDrive> > &aHostDrives);
127 HRESULT getMemorySize(ULONG *aMemorySize);
128 HRESULT getMemoryAvailable(ULONG *aMemoryAvailable);
129 HRESULT getOperatingSystem(com::Utf8Str &aOperatingSystem);
130 HRESULT getOSVersion(com::Utf8Str &aOSVersion);
131 HRESULT getUTCTime(LONG64 *aUTCTime);
132 HRESULT getVideoInputDevices(std::vector<ComPtr<IHostVideoInputDevice> > &aVideoInputDevices);
133 HRESULT getUpdateHost(ComPtr<IUpdateAgent> &aUpdate);
134 HRESULT getUpdateExtPack(ComPtr<IUpdateAgent> &aUpdate);
135 HRESULT getUpdateGuestAdditions(ComPtr<IUpdateAgent> &aUpdate);
136 HRESULT getUpdateResponse(BOOL *aUpdateNeeded);
137 HRESULT getUpdateVersion(com::Utf8Str &aUpdateVersion);
138 HRESULT getUpdateURL(com::Utf8Str &aUpdateURL);
139 HRESULT getUpdateCheckNeeded(BOOL *aUpdateCheckNeeded);
140 HRESULT getX86(ComPtr<IHostX86> &aHostX86);
141
142 // wrapped IHost methods
143 HRESULT getProcessorSpeed(ULONG aCpuId,
144 ULONG *aSpeed);
145 HRESULT getProcessorFeature(ProcessorFeature_T aFeature,
146 BOOL *aSupported);
147 HRESULT getProcessorDescription(ULONG aCpuId,
148 com::Utf8Str &aDescription);
149 HRESULT createHostOnlyNetworkInterface(ComPtr<IHostNetworkInterface> &aHostInterface,
150 ComPtr<IProgress> &aProgress);
151 HRESULT removeHostOnlyNetworkInterface(const com::Guid &aId,
152 ComPtr<IProgress> &aProgress);
153 HRESULT createUSBDeviceFilter(const com::Utf8Str &aName,
154 ComPtr<IHostUSBDeviceFilter> &aFilter);
155 HRESULT insertUSBDeviceFilter(ULONG aPosition,
156 const ComPtr<IHostUSBDeviceFilter> &aFilter);
157 HRESULT removeUSBDeviceFilter(ULONG aPosition);
158 HRESULT findHostDVDDrive(const com::Utf8Str &aName,
159 ComPtr<IMedium> &aDrive);
160 HRESULT findHostFloppyDrive(const com::Utf8Str &aName,
161 ComPtr<IMedium> &aDrive);
162 HRESULT findHostNetworkInterfaceByName(const com::Utf8Str &aName,
163 ComPtr<IHostNetworkInterface> &aNetworkInterface);
164 HRESULT findHostNetworkInterfaceById(const com::Guid &aId,
165 ComPtr<IHostNetworkInterface> &aNetworkInterface);
166 HRESULT findHostNetworkInterfacesOfType(HostNetworkInterfaceType_T aType,
167 std::vector<ComPtr<IHostNetworkInterface> > &aNetworkInterfaces);
168 HRESULT findUSBDeviceById(const com::Guid &aId,
169 ComPtr<IHostUSBDevice> &aDevice);
170 HRESULT findUSBDeviceByAddress(const com::Utf8Str &aName,
171 ComPtr<IHostUSBDevice> &aDevice);
172 HRESULT generateMACAddress(com::Utf8Str &aAddress);
173
174 HRESULT addUSBDeviceSource(const com::Utf8Str &aBackend, const com::Utf8Str &aId, const com::Utf8Str &aAddress,
175 const std::vector<com::Utf8Str> &aPropertyNames, const std::vector<com::Utf8Str> &aPropertyValues);
176
177 HRESULT removeUSBDeviceSource(const com::Utf8Str &aId);
178 HRESULT isExecutionEngineSupported(CPUArchitecture_T enmCpuArchitecture, VMExecutionEngine_T enmExecutionEngine, BOOL *pfIsSupported);
179
180 // Internal Methods.
181
182 HRESULT i_buildDVDDrivesList(MediaList &list);
183 HRESULT i_buildFloppyDrivesList(MediaList &list);
184 HRESULT i_findHostDriveByNameOrId(DeviceType_T mediumType, const Utf8Str &strNameOrId, ComObjPtr<Medium> &pMedium);
185
186#if defined(RT_OS_SOLARIS) && defined(VBOX_USE_LIBHAL)
187 bool i_getDVDInfoFromHal(std::list< ComObjPtr<Medium> > &list);
188 bool i_getFloppyInfoFromHal(std::list< ComObjPtr<Medium> > &list);
189 HRESULT i_getFixedDrivesFromHal(std::list<std::pair<com::Utf8Str, com::Utf8Str> > &list) RT_NOEXCEPT;
190#endif
191
192#if defined(RT_OS_SOLARIS)
193 void i_getDVDInfoFromDevTree(std::list< ComObjPtr<Medium> > &list);
194 void i_parseMountTable(char *mountTable, std::list< ComObjPtr<Medium> > &list);
195 bool i_validateDevice(const char *deviceNode, bool isCDROM);
196 HRESULT i_getFixedDrivesFromDevTree(std::list<std::pair<com::Utf8Str, com::Utf8Str> > &list) RT_NOEXCEPT;
197#endif
198
199 HRESULT i_updateNetIfList();
200
201#ifndef RT_OS_WINDOWS
202 HRESULT i_parseResolvConf();
203#else
204 HRESULT i_fetchNameResolvingInformation();
205#endif
206
207#ifdef VBOX_WITH_RESOURCE_USAGE_API
208 void i_registerMetrics(PerformanceCollector *aCollector);
209 void i_registerDiskMetrics(PerformanceCollector *aCollector);
210 void i_unregisterMetrics(PerformanceCollector *aCollector);
211#endif /* VBOX_WITH_RESOURCE_USAGE_API */
212
213#ifdef RT_OS_WINDOWS
214 HRESULT i_getFixedDrivesFromGlobalNamespace(std::list<std::pair<com::Utf8Str, com::Utf8Str> > &aDriveList) RT_NOEXCEPT;
215#endif
216 HRESULT i_getDrivesPathsList(std::list<std::pair<com::Utf8Str, com::Utf8Str> > &aDriveList) RT_NOEXCEPT;
217
218#ifdef VBOX_WITH_NATIVE_NEM
219 BOOL i_HostIsNativeApiSupported();
220#endif
221
222 struct Data; // opaque data structure, defined in HostImpl.cpp
223 Data *m;
224};
225
226#endif /* !MAIN_INCLUDED_HostImpl_h */
227
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