VirtualBox

source: vbox/trunk/src/VBox/Main/src-server/GuestOSTypeImpl.cpp

Last change on this file was 101683, checked in by vboxsync, 7 months ago

Main/Unattended|GuestOSType: Add an entry in the guest OS type to indicate the name of the additions install package instead of hardcoding it in the templates. Allows easy adaption if something changes and makes it possible to auto install guest additions for linux.arm64 guests, bugref:10542

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.4 KB
RevLine 
[55401]1/* $Id: GuestOSTypeImpl.cpp 101683 2023-10-31 12:38:46Z vboxsync $ */
[1]2/** @file
3 * VirtualBox COM class implementation
4 */
5
6/*
[98103]7 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
[1]8 *
[96407]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
[1]26 */
27
[76592]28#define LOG_GROUP LOG_GROUP_MAIN_GUESTOSTYPE
[1]29#include "GuestOSTypeImpl.h"
[25860]30#include "AutoCaller.h"
[76592]31#include "LoggingNew.h"
[25346]32#include <iprt/cpp/utils.h>
[1]33
34// constructor / destructor
35/////////////////////////////////////////////////////////////////////////////
36
37GuestOSType::GuestOSType()
[32531]38 : mOSType(VBOXOSTYPE_Unknown)
39 , mOSHint(VBOXOSHINT_NONE)
[75817]40 , mRAMSize(0)
[91470]41 , mCPUCount(1)
[75817]42 , mGraphicsControllerType(GraphicsControllerType_Null)
43 , mVRAMSize(0)
[85216]44 , mHDDSize(0)
[32531]45 , mNetworkAdapterType(NetworkAdapterType_Am79C973)
46 , mNumSerialEnabled(0)
[42551]47 , mDVDStorageControllerType(StorageControllerType_PIIX3)
48 , mDVDStorageBusType(StorageBus_IDE)
49 , mHDStorageControllerType(StorageControllerType_PIIX3)
50 , mHDStorageBusType(StorageBus_IDE)
[32120]51 , mChipsetType(ChipsetType_PIIX3)
[87241]52 , mIommuType(IommuType_None)
[33447]53 , mAudioControllerType(AudioControllerType_AC97)
[56459]54 , mAudioCodecType(AudioCodecType_STAC9700)
[1]55{
56}
57
58GuestOSType::~GuestOSType()
59{
60}
61
[2567]62HRESULT GuestOSType::FinalConstruct()
63{
[35638]64 return BaseFinalConstruct();
[2567]65}
66
67void GuestOSType::FinalRelease()
68{
69 uninit();
[37423]70
[35638]71 BaseFinalRelease();
[2567]72}
73
[1]74// public initializer/uninitializer for internal purposes only
75/////////////////////////////////////////////////////////////////////////////
76
77/**
78 * Initializes the guest OS type object.
79 *
80 * @returns COM result indicator
[65120]81 * @param ostype containing the following parts:
82 * @a aFamilyId os family short name string
83 * @a aFamilyDescription os family name string
84 * @a aId os short name string
85 * @a aDescription os name string
86 * @a aOSType global OS type ID
87 * @a aOSHint os configuration hint
88 * @a aRAMSize recommended RAM size in megabytes
89 * @a aVRAMSize recommended video memory size in megabytes
90 * @a aHDDSize recommended HDD size in bytes
[1]91 */
[65120]92HRESULT GuestOSType::init(const Global::OSType &ostype)
[1]93{
[32894]94 ComAssertRet(ostype.familyId && ostype.familyDescription && ostype.id && ostype.description, E_INVALIDARG);
[1]95
[2567]96 /* Enclose the state transition NotReady->InInit->Ready */
[21878]97 AutoInitSpan autoInitSpan(this);
98 AssertReturn(autoInitSpan.isOk(), E_FAIL);
[1]99
[101683]100 unconst(mFamilyID) = ostype.familyId;
101 unconst(mFamilyDescription) = ostype.familyDescription;
102 unconst(mOSSubtype) = ostype.subtype;
103 unconst(mID) = ostype.id;
104 unconst(mDescription) = ostype.description;
105 unconst(mOSType) = ostype.osType;
106 unconst(mOSHint) = ostype.osHint;
107 unconst(mRAMSize) = ostype.recommendedRAM;
108 unconst(mCPUCount) = ostype.recommendedCPUCount;
109 unconst(mHDDSize) = ostype.recommendedHDD;
110 unconst(mGraphicsControllerType) = ostype.graphicsControllerType;
111 unconst(mVRAMSize) = ostype.recommendedVRAM;
112 unconst(mNetworkAdapterType) = ostype.networkAdapterType;
113 unconst(mNumSerialEnabled) = ostype.numSerialEnabled;
114 unconst(mDVDStorageControllerType) = ostype.dvdStorageControllerType;
115 unconst(mDVDStorageBusType) = ostype.dvdStorageBusType;
116 unconst(mHDStorageControllerType) = ostype.hdStorageControllerType;
117 unconst(mHDStorageBusType) = ostype.hdStorageBusType;
118 unconst(mChipsetType) = ostype.chipsetType;
119 unconst(mIommuType) = ostype.iommuType;
120 unconst(mAudioControllerType) = ostype.audioControllerType;
121 unconst(mAudioCodecType) = ostype.audioCodecType;
122 unconst(mGuestAdditionsInstallPackageName) = ostype.guestAdditionsInstallPkgName;
[2567]123
124 /* Confirm a successful initialization when it's the case */
125 autoInitSpan.setSucceeded();
126
[1]127 return S_OK;
128}
129
[2567]130/**
131 * Uninitializes the instance and sets the ready flag to FALSE.
132 * Called either from FinalRelease() or by the parent when it gets destroyed.
133 */
134void GuestOSType::uninit()
135{
136 /* Enclose the state transition Ready->InUninit->NotReady */
[21878]137 AutoUninitSpan autoUninitSpan(this);
[2567]138 if (autoUninitSpan.uninitDone())
139 return;
140}
141
[1]142// IGuestOSType properties
143/////////////////////////////////////////////////////////////////////////////
144
[49644]145HRESULT GuestOSType::getFamilyId(com::Utf8Str &aFamilyId)
[14437]146{
147 /* mFamilyID is constant during life time, no need to lock */
[49644]148 aFamilyId = mFamilyID;
[14437]149 return S_OK;
150}
151
[49644]152
153HRESULT GuestOSType::getFamilyDescription(com::Utf8Str &aFamilyDescription)
[14437]154{
155 /* mFamilyDescription is constant during life time, no need to lock */
[49644]156 aFamilyDescription = mFamilyDescription;
[14437]157
158 return S_OK;
159}
160
[49644]161
[101593]162HRESULT GuestOSType::getSubtype(com::Utf8Str &aSubtype)
[101164]163{
[101593]164 /* mOSSubtype is constant during life time, no need to lock */
165 aSubtype = mOSSubtype;
[101164]166
167 return S_OK;
168}
169
170
[49644]171HRESULT GuestOSType::getId(com::Utf8Str &aId)
[1]172{
[2567]173 /* mID is constant during life time, no need to lock */
[49644]174 aId = mID;
[2567]175
[1]176 return S_OK;
177}
178
[49644]179
180HRESULT GuestOSType::getDescription(com::Utf8Str &aDescription)
[1]181{
[2567]182 /* mDescription is constant during life time, no need to lock */
[49644]183 aDescription = mDescription;
[2567]184
[1]185 return S_OK;
186}
187
[49644]188HRESULT GuestOSType::getIs64Bit(BOOL *aIs64Bit)
[14437]189{
190 /* mIs64Bit is constant during life time, no need to lock */
[15064]191 *aIs64Bit = !!(mOSHint & VBOXOSHINT_64BIT);
[14437]192
193 return S_OK;
194}
195
[101177]196PlatformArchitecture_T GuestOSType::i_platformArchitecture() const
[101171]197{
198 /* mOSType constant during life time, no need to lock */
199 VBOXOSTYPE const osTypePlatformArchitectureMasked = VBOXOSTYPE(mOSType & VBOXOSTYPE_ArchitectureMask);
[101195]200 if ( osTypePlatformArchitectureMasked == VBOXOSTYPE_x86
201 || osTypePlatformArchitectureMasked == VBOXOSTYPE_x64)
[101177]202 return PlatformArchitecture_x86;
[101204]203 else if ( osTypePlatformArchitectureMasked == VBOXOSTYPE_arm32
204 || osTypePlatformArchitectureMasked == VBOXOSTYPE_arm64)
[101177]205 return PlatformArchitecture_ARM;
[101171]206
[101177]207 /* Will happen when called before being properly initialized(). */
208 return PlatformArchitecture_None;
209}
210
211HRESULT GuestOSType::getPlatformArchitecture(PlatformArchitecture_T *aPlatformArchitecture)
212{
213 *aPlatformArchitecture = i_platformArchitecture();
[101171]214 return S_OK;
215}
216
[49644]217HRESULT GuestOSType::getRecommendedIOAPIC(BOOL *aRecommendedIOAPIC)
[14664]218{
219 /* mRecommendedIOAPIC is constant during life time, no need to lock */
[101215]220 *aRecommendedIOAPIC = !!(mOSHint & VBOXOSHINT_X86_IOAPIC);
[14664]221
222 return S_OK;
223}
224
[49644]225
226HRESULT GuestOSType::getRecommendedVirtEx(BOOL *aRecommendedVirtEx)
[14664]227{
228 /* mRecommendedVirtEx is constant during life time, no need to lock */
[101215]229 *aRecommendedVirtEx = !!(mOSHint & VBOXOSHINT_X86_HWVIRTEX);
[14664]230
231 return S_OK;
232}
233
[49644]234
235HRESULT GuestOSType::getRecommendedRAM(ULONG *aRAMSize)
[1]236{
[2567]237 /* mRAMSize is constant during life time, no need to lock */
238 *aRAMSize = mRAMSize;
239
[1]240 return S_OK;
241}
242
[49644]243
[75817]244HRESULT GuestOSType::getRecommendedGraphicsController(GraphicsControllerType_T *aRecommendedGraphicsController)
245{
246 /* mGraphicsController is constant during life time, no need to lock */
247 *aRecommendedGraphicsController = mGraphicsControllerType;
248
249 return S_OK;
250}
251
252
[49644]253HRESULT GuestOSType::getRecommendedVRAM(ULONG *aVRAMSize)
[1]254{
[2567]255 /* mVRAMSize is constant during life time, no need to lock */
256 *aVRAMSize = mVRAMSize;
257
[1]258 return S_OK;
259}
260
[49644]261
262HRESULT GuestOSType::getRecommended2DVideoAcceleration(BOOL *aRecommended2DVideoAcceleration)
[39055]263{
264 /* Constant during life time, no need to lock */
265 *aRecommended2DVideoAcceleration = !!(mOSHint & VBOXOSHINT_ACCEL2D);
266
267 return S_OK;
268}
269
[49644]270
271HRESULT GuestOSType::getRecommended3DAcceleration(BOOL *aRecommended3DAcceleration)
[39055]272{
273 /* Constant during life time, no need to lock */
274 *aRecommended3DAcceleration = !!(mOSHint & VBOXOSHINT_ACCEL3D);
275
276 return S_OK;
277}
278
[49644]279
280HRESULT GuestOSType::getRecommendedHDD(LONG64 *aHDDSize)
[1]281{
[2567]282 /* mHDDSize is constant during life time, no need to lock */
[85215]283 *aHDDSize = (LONG64)mHDDSize;
[2567]284
[1]285 return S_OK;
286}
[14664]287
[49644]288
289HRESULT GuestOSType::getAdapterType(NetworkAdapterType_T *aNetworkAdapterType)
[14664]290{
291 /* mNetworkAdapterType is constant during life time, no need to lock */
292 *aNetworkAdapterType = mNetworkAdapterType;
293
294 return S_OK;
295}
[26333]296
[49644]297HRESULT GuestOSType::getRecommendedPAE(BOOL *aRecommendedPAE)
[26333]298{
[26389]299 /* recommended PAE is constant during life time, no need to lock */
[101215]300 *aRecommendedPAE = !!(mOSHint & VBOXOSHINT_X86_PAE);
[26333]301
302 return S_OK;
303}
304
[49644]305
306HRESULT GuestOSType::getRecommendedFirmware(FirmwareType_T *aFirmwareType)
[26333]307{
308 /* firmware type is constant during life time, no need to lock */
[26536]309 if (mOSHint & VBOXOSHINT_EFI)
310 *aFirmwareType = FirmwareType_EFI;
311 else
312 *aFirmwareType = FirmwareType_BIOS;
[26333]313
314 return S_OK;
315}
316
[49644]317
318HRESULT GuestOSType::getRecommendedDVDStorageController(StorageControllerType_T *aStorageControllerType)
[26389]319{
320 /* storage controller type is constant during life time, no need to lock */
[42551]321 *aStorageControllerType = mDVDStorageControllerType;
[26389]322
323 return S_OK;
324}
325
[49644]326
327HRESULT GuestOSType::getRecommendedDVDStorageBus(StorageBus_T *aStorageBusType)
[28825]328{
329 /* storage controller type is constant during life time, no need to lock */
[42551]330 *aStorageBusType = mDVDStorageBusType;
[28825]331
332 return S_OK;
333}
334
[49644]335
336HRESULT GuestOSType::getRecommendedHDStorageController(StorageControllerType_T *aStorageControllerType)
[28825]337{
338 /* storage controller type is constant during life time, no need to lock */
[42551]339 *aStorageControllerType = mHDStorageControllerType;
[28825]340
341 return S_OK;
342}
343
[49644]344
345HRESULT GuestOSType::getRecommendedHDStorageBus(StorageBus_T *aStorageBusType)
[28825]346{
347 /* storage controller type is constant during life time, no need to lock */
[42551]348 *aStorageBusType = mHDStorageBusType;
[28825]349
350 return S_OK;
351}
352
[49644]353
354HRESULT GuestOSType::getRecommendedUSBHID(BOOL *aRecommendedUSBHID)
[26440]355{
356 /* HID type is constant during life time, no need to lock */
[42551]357 *aRecommendedUSBHID = !!(mOSHint & VBOXOSHINT_USBHID);
[26440]358
359 return S_OK;
360}
361
[49644]362
363HRESULT GuestOSType::getRecommendedHPET(BOOL *aRecommendedHPET)
[26548]364{
[33540]365 /* HPET recommendation is constant during life time, no need to lock */
[101215]366 *aRecommendedHPET = !!(mOSHint & VBOXOSHINT_X86_HPET);
[26548]367
368 return S_OK;
369}
370
[49644]371
372HRESULT GuestOSType::getRecommendedUSBTablet(BOOL *aRecommendedUSBTablet)
[27382]373{
374 /* HID type is constant during life time, no need to lock */
[42551]375 *aRecommendedUSBTablet = !!(mOSHint & VBOXOSHINT_USBTABLET);
[27382]376
377 return S_OK;
378}
379
[49644]380
381HRESULT GuestOSType::getRecommendedRTCUseUTC(BOOL *aRecommendedRTCUseUTC)
[27820]382{
[39058]383 /* Value is constant during life time, no need to lock */
[42551]384 *aRecommendedRTCUseUTC = !!(mOSHint & VBOXOSHINT_RTCUTC);
[27820]385
386 return S_OK;
387}
388
[49644]389
390HRESULT GuestOSType::getRecommendedChipset(ChipsetType_T *aChipsetType)
[32120]391{
392 /* chipset type is constant during life time, no need to lock */
393 *aChipsetType = mChipsetType;
394
395 return S_OK;
396}
397
[49644]398
[87241]399HRESULT GuestOSType::getRecommendedIommuType(IommuType_T *aIommuType)
400{
401 /* IOMMU type is constant during life time, no need to lock */
402 *aIommuType = mIommuType;
403
404 return S_OK;
405}
406
407
[49644]408HRESULT GuestOSType::getRecommendedAudioController(AudioControllerType_T *aAudioController)
[33447]409{
410 *aAudioController = mAudioControllerType;
411
412 return S_OK;
413}
414
[49644]415
[56459]416HRESULT GuestOSType::getRecommendedAudioCodec(AudioCodecType_T *aAudioCodec)
417{
418 *aAudioCodec = mAudioCodecType;
419
420 return S_OK;
421}
422
423
[49644]424HRESULT GuestOSType::getRecommendedFloppy(BOOL *aRecommendedFloppy)
[39058]425{
426 /* Value is constant during life time, no need to lock */
427 *aRecommendedFloppy = !!(mOSHint & VBOXOSHINT_FLOPPY);
428
429 return S_OK;
430}
431
[49644]432
433HRESULT GuestOSType::getRecommendedUSB(BOOL *aRecommendedUSB)
[39058]434{
435 /* Value is constant during life time, no need to lock */
[42551]436 *aRecommendedUSB = !(mOSHint & VBOXOSHINT_NOUSB);
[39058]437
438 return S_OK;
439}
440
[58677]441HRESULT GuestOSType::getRecommendedUSB3(BOOL *aRecommendedUSB3)
442{
443 /* Value is constant during life time, no need to lock */
444 *aRecommendedUSB3 = !!(mOSHint & VBOXOSHINT_USB3);
445
446 return S_OK;
447}
448
[49644]449HRESULT GuestOSType::getRecommendedTFReset(BOOL *aRecommendedTFReset)
[49074]450{
451 /* recommended triple fault behavior is constant during life time, no need to lock */
452 *aRecommendedTFReset = !!(mOSHint & VBOXOSHINT_TFRESET);
453
454 return S_OK;
455}
[61747]456
457HRESULT GuestOSType::getRecommendedX2APIC(BOOL *aRecommendedX2APIC)
458{
459 /* mRecommendedX2APIC is constant during life time, no need to lock */
[101215]460 *aRecommendedX2APIC = !!(mOSHint & VBOXOSHINT_X86_X2APIC);
[61747]461
462 return S_OK;
463}
464
[91470]465HRESULT GuestOSType::getRecommendedCPUCount(ULONG *aRecommendedCPUCount)
466{
[91614]467 /* mCPUCount is constant during life time, no need to lock */
[91470]468 *aRecommendedCPUCount = mCPUCount;
[61747]469
[91470]470 return S_OK;
471}
472
[91614]473HRESULT GuestOSType::getRecommendedTpmType(TpmType_T *aRecommendedTpmType)
474{
475 /* Value is constant during life time, no need to lock */
476 if (mOSHint & VBOXOSHINT_TPM2)
477 *aRecommendedTpmType = TpmType_v2_0;
478 else if (mOSHint & VBOXOSHINT_TPM)
479 *aRecommendedTpmType = TpmType_v1_2;
480 else
481 *aRecommendedTpmType = TpmType_None;
[91470]482
[91614]483 return S_OK;
484}
485
486HRESULT GuestOSType::getRecommendedSecureBoot(BOOL *aRecommendedSecureBoot)
487{
488 /* Value is constant during life time, no need to lock */
489 *aRecommendedSecureBoot = !!(mOSHint & VBOXOSHINT_EFI_SECUREBOOT);
490
491 return S_OK;
492}
493
[92154]494HRESULT GuestOSType::getRecommendedWDDMGraphics(BOOL *aRecommendedWDDMGraphics)
495{
496 /* Value is constant during life time, no need to lock */
497 *aRecommendedWDDMGraphics = !!(mOSHint & VBOXOSHINT_WDDM_GRAPHICS);
498
499 return S_OK;
500}
501
[101683]502HRESULT GuestOSType::getGuestAdditionsInstallPackageName(com::Utf8Str &aGuestAdditionsInstallPkgName)
503{
504 /* mGuestAdditionsInstallPackageName is constant during life time, no need to lock */
505 aGuestAdditionsInstallPkgName = mGuestAdditionsInstallPackageName;
506 return S_OK;
507}
508
[14772]509/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use