VirtualBox

source: vbox/trunk/src/VBox/Main/include/UnattendedImpl.h@ 93444

Last change on this file since 93444 was 93405, checked in by vboxsync, 3 years ago

Main/Unattended: Use the detected guest OS type instead of the configured VM guest OS type for picking the installer. bugref:10186 bugref:9515

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.3 KB
Line 
1/* $Id: UnattendedImpl.h 93405 2022-01-24 09:56:23Z vboxsync $ */
2/** @file
3 * Unattended class header
4 */
5
6/*
7 * Copyright (C) 2006-2022 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 MAIN_INCLUDED_UnattendedImpl_h
19#define MAIN_INCLUDED_UnattendedImpl_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include <VBox/ostypes.h>
25#include <iprt/time.h>
26#include "UnattendedWrap.h"
27
28/* Forward declarations. */
29class UnattendedInstaller;
30struct UnattendedInstallationDisk;
31struct ControllerSlot;
32
33
34/**
35 * Class implementing the IUnattended interface.
36 *
37 * This class is instantiated on the request by IMachine::getUnattended.
38 */
39class ATL_NO_VTABLE Unattended
40 : public UnattendedWrap
41{
42public:
43 DECLARE_COMMON_CLASS_METHODS(Unattended)
44
45 HRESULT FinalConstruct();
46 void FinalRelease();
47
48 // public initializer/uninitializer for internal purposes only
49 HRESULT initUnattended(VirtualBox *aParent);
50 void uninit();
51
52 // public methods for internal purposes
53 Utf8Str const &i_getIsoPath() const;
54 Utf8Str const &i_getUser() const;
55 Utf8Str const &i_getPassword() const;
56 Utf8Str const &i_getFullUserName() const;
57 Utf8Str const &i_getProductKey() const;
58 Utf8Str const &i_getProxy() const;
59 Utf8Str const &i_getAdditionsIsoPath() const;
60 bool i_getInstallGuestAdditions() const;
61 Utf8Str const &i_getValidationKitIsoPath() const;
62 bool i_getInstallTestExecService() const;
63 Utf8Str const &i_getTimeZone() const;
64 PCRTTIMEZONEINFO i_getTimeZoneInfo() const;
65 Utf8Str const &i_getLocale() const;
66 Utf8Str const &i_getLanguage() const;
67 Utf8Str const &i_getCountry() const;
68 bool i_isMinimalInstallation() const;
69 Utf8Str const &i_getHostname() const;
70 Utf8Str const &i_getAuxiliaryBasePath() const;
71 ULONG i_getImageIndex() const;
72 Utf8Str const &i_getScriptTemplatePath() const;
73 Utf8Str const &i_getPostInstallScriptTemplatePath() const;
74 Utf8Str const &i_getPostInstallCommand() const;
75 /** The directory where the unattended install config and script is
76 * located, from the perspective of the running unattended install. */
77 Utf8Str const &i_getAuxiliaryInstallDir() const;
78 Utf8Str const &i_getExtraInstallKernelParameters() const;
79
80 bool i_isRtcUsingUtc() const;
81 bool i_isGuestOs64Bit() const;
82 bool i_isFirmwareEFI() const;
83 Utf8Str const &i_getDetectedOSVersion();
84
85
86private:
87 ComPtr<VirtualBox> const mParent; /**< Strong reference to the parent object (VirtualBox/IMachine). */
88 ComPtr<Machine> mMachine; /**< Strong reference to the machine object (Machine/IMachine). */
89 Guid mMachineUuid; /**< The machine UUID. */
90 RTNATIVETHREAD mhThreadReconfigureVM; /**< Set when reconfigureVM is running. */
91 Utf8Str mStrGuestOsTypeId; /**< Guest OS type ID (set by prepare). */
92 bool mfRtcUseUtc; /**< Copy of IMachine::RTCUseUTC (locking reasons). */
93 bool mfGuestOs64Bit; /**< 64-bit (true) or 32-bit guest OS (set by prepare). */
94 FirmwareType_T menmFirmwareType; /**< Firmware type BIOS/EFI (set by prepare). */
95 UnattendedInstaller *mpInstaller; /**< The installer instance (set by prepare, deleted by done). */
96
97 /** @name Values of the IUnattended attributes.
98 * @{ */
99 Utf8Str mStrUser;
100 Utf8Str mStrPassword;
101 Utf8Str mStrFullUserName;
102 Utf8Str mStrProductKey;
103 Utf8Str mStrIsoPath;
104 Utf8Str mStrAdditionsIsoPath;
105 bool mfInstallGuestAdditions;
106 bool mfInstallTestExecService;
107 Utf8Str mStrValidationKitIsoPath;
108 Utf8Str mStrTimeZone;
109 PCRTTIMEZONEINFO mpTimeZoneInfo;
110 Utf8Str mStrLocale;
111 Utf8Str mStrLanguage; /**< (only relevant for windows at the moment) */
112 Utf8Str mStrCountry;
113 RTCList<RTCString, RTCString *> mPackageSelectionAdjustments;
114 Utf8Str mStrHostname;
115 Utf8Str mStrAuxiliaryBasePath;
116 bool mfIsDefaultAuxiliaryBasePath;
117 ULONG midxImage;
118 Utf8Str mStrScriptTemplatePath;
119 Utf8Str mStrPostInstallScriptTemplatePath;
120 Utf8Str mStrPostInstallCommand;
121 Utf8Str mStrExtraInstallKernelParameters;
122 Utf8Str mStrProxy;
123
124 bool mfDoneDetectIsoOS; /**< Set by detectIsoOS(), cleared by setIsoPath(). */
125 Utf8Str mStrDetectedOSTypeId;
126 Utf8Str mStrDetectedOSVersion;
127 Utf8Str mStrDetectedOSFlavor;
128 RTCList<RTCString, RTCString *> mDetectedOSLanguages; /**< (only relevant for windows at the moment) */
129 Utf8Str mStrDetectedOSHints;
130 /** @} */
131
132 // wrapped IUnattended functions:
133
134 /**
135 * Checks what mStrIsoPath points to and sets the detectedOS* properties.
136 */
137 HRESULT detectIsoOS();
138
139 /**
140 * Prepare any data, environment, etc.
141 */
142 HRESULT prepare();
143
144 /**
145 * Prepare installation ISO/floppy.
146 */
147 HRESULT constructMedia();
148
149 /**
150 * Prepare a VM to run an unattended installation
151 */
152 HRESULT reconfigureVM();
153
154 /**
155 * Done with all media construction and VM configuration and stuff.
156 */
157 HRESULT done();
158
159 // wrapped IUnattended attributes:
160 HRESULT getIsoPath(com::Utf8Str &isoPath);
161 HRESULT setIsoPath(const com::Utf8Str &isoPath);
162 HRESULT getUser(com::Utf8Str &user);
163 HRESULT setUser(const com::Utf8Str &user);
164 HRESULT getPassword(com::Utf8Str &password);
165 HRESULT setPassword(const com::Utf8Str &password);
166 HRESULT getFullUserName(com::Utf8Str &user);
167 HRESULT setFullUserName(const com::Utf8Str &user);
168 HRESULT getProductKey(com::Utf8Str &productKey);
169 HRESULT setProductKey(const com::Utf8Str &productKey);
170 HRESULT getAdditionsIsoPath(com::Utf8Str &additionsIsoPath);
171 HRESULT setAdditionsIsoPath(const com::Utf8Str &additionsIsoPath);
172 HRESULT getInstallGuestAdditions(BOOL *installGuestAdditions);
173 HRESULT setInstallGuestAdditions(BOOL installGuestAdditions);
174 HRESULT getValidationKitIsoPath(com::Utf8Str &aValidationKitIsoPath);
175 HRESULT setValidationKitIsoPath(const com::Utf8Str &aValidationKitIsoPath);
176 HRESULT getInstallTestExecService(BOOL *aInstallTestExecService);
177 HRESULT setInstallTestExecService(BOOL aInstallTestExecService);
178 HRESULT getTimeZone(com::Utf8Str &aTimezone);
179 HRESULT setTimeZone(const com::Utf8Str &aTimezone);
180 HRESULT getLocale(com::Utf8Str &aLocale);
181 HRESULT setLocale(const com::Utf8Str &aLocale);
182 HRESULT getLanguage(com::Utf8Str &aLanguage);
183 HRESULT setLanguage(const com::Utf8Str &aLanguage);
184 HRESULT getCountry(com::Utf8Str &aCountry);
185 HRESULT setCountry(const com::Utf8Str &aCountry);
186 HRESULT getProxy(com::Utf8Str &aProxy);
187 HRESULT setProxy(const com::Utf8Str &aProxy);
188 HRESULT getPackageSelectionAdjustments(com::Utf8Str &aPackageSelectionAdjustments);
189 HRESULT setPackageSelectionAdjustments(const com::Utf8Str &aPackageSelectionAdjustments);
190 HRESULT getHostname(com::Utf8Str &aHostname);
191 HRESULT setHostname(const com::Utf8Str &aHostname);
192 HRESULT getAuxiliaryBasePath(com::Utf8Str &aAuxiliaryBasePath);
193 HRESULT setAuxiliaryBasePath(const com::Utf8Str &aAuxiliaryBasePath);
194 HRESULT getImageIndex(ULONG *index);
195 HRESULT setImageIndex(ULONG index);
196 HRESULT getMachine(ComPtr<IMachine> &aMachine);
197 HRESULT setMachine(const ComPtr<IMachine> &aMachine);
198 HRESULT getScriptTemplatePath(com::Utf8Str &aScriptTemplatePath);
199 HRESULT setScriptTemplatePath(const com::Utf8Str &aScriptTemplatePath);
200 HRESULT getPostInstallScriptTemplatePath(com::Utf8Str &aPostInstallScriptTemplatePath);
201 HRESULT setPostInstallScriptTemplatePath(const com::Utf8Str &aPostInstallScriptTemplatePath);
202 HRESULT getPostInstallCommand(com::Utf8Str &aPostInstallCommand);
203 HRESULT setPostInstallCommand(const com::Utf8Str &aPostInstallCommand);
204 HRESULT getExtraInstallKernelParameters(com::Utf8Str &aExtraInstallKernelParameters);
205 HRESULT setExtraInstallKernelParameters(const com::Utf8Str &aExtraInstallKernelParameters);
206 HRESULT getDetectedOSTypeId(com::Utf8Str &aDetectedOSTypeId);
207 HRESULT getDetectedOSVersion(com::Utf8Str &aDetectedOSVersion);
208 HRESULT getDetectedOSLanguages(com::Utf8Str &aDetectedOSLanguages);
209 HRESULT getDetectedOSFlavor(com::Utf8Str &aDetectedOSFlavor);
210 HRESULT getDetectedOSHints(com::Utf8Str &aDetectedOSHints);
211 //internal functions
212
213 /**
214 * Worker for detectIsoOs().
215 *
216 * @returns COM status code.
217 * @retval S_OK if detected.
218 * @retval S_FALSE if not detected.
219 *
220 * @param hVfsIso The ISO file system handle.
221 */
222 HRESULT i_innerDetectIsoOS(RTVFS hVfsIso);
223 typedef union DETECTBUFFER
224 {
225 char sz[4096];
226 char ach[4096];
227 uint8_t ab[4096];
228 uint32_t au32[1024];
229 } DETECTBUFFER;
230 HRESULT i_innerDetectIsoOSWindows(RTVFS hVfsIso, DETECTBUFFER *puBuf, VBOXOSTYPE *penmOsType);
231 HRESULT i_innerDetectIsoOSLinux(RTVFS hVfsIso, DETECTBUFFER *puBuf, VBOXOSTYPE *penmOsType);
232 HRESULT i_innerDetectIsoOSOs2(RTVFS hVfsIso, DETECTBUFFER *puBuf, VBOXOSTYPE *penmOsType);
233
234 /**
235 * Worker for reconfigureVM().
236 * The caller makes sure to close the session whatever happens.
237 */
238 HRESULT i_innerReconfigureVM(AutoMultiWriteLock2 &rAutoLock, StorageBus_T enmRecommendedStorageBus,
239 ComPtr<IMachine> const &rPtrSessionMachine);
240 HRESULT i_reconfigureFloppy(com::SafeIfaceArray<IStorageController> &rControllers,
241 std::vector<UnattendedInstallationDisk> &rVecInstallatationDisks,
242 ComPtr<IMachine> const &rPtrSessionMachine,
243 AutoMultiWriteLock2 &rAutoLock);
244 HRESULT i_reconfigureIsos(com::SafeIfaceArray<IStorageController> &rControllers,
245 std::vector<UnattendedInstallationDisk> &rVecInstallatationDisks,
246 ComPtr<IMachine> const &rPtrSessionMachine,
247 AutoMultiWriteLock2 &rAutoLock, StorageBus_T enmRecommendedStorageBus);
248
249 /**
250 * Adds all free slots on the controller to @a rOutput.
251 */
252 HRESULT i_findOrCreateNeededFreeSlots(const Utf8Str &rStrControllerName, StorageBus_T enmStorageBus,
253 ComPtr<IMachine> const &rPtrSessionMachine, uint32_t cSlotsNeeded,
254 std::list<ControllerSlot> &rDvdSlots);
255
256 /**
257 * Attach to VM a disk
258 */
259 HRESULT i_attachImage(UnattendedInstallationDisk const *pImage, ComPtr<IMachine> const &rPtrSessionMachine,
260 AutoMultiWriteLock2 &rLock);
261
262 /*
263 * Wrapper functions
264 */
265
266 /**
267 * Check whether guest is 64bit platform or not
268 */
269 bool i_isGuestOSArchX64(Utf8Str const &rStrGuestOsTypeId);
270};
271
272#endif /* !MAIN_INCLUDED_UnattendedImpl_h */
273
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