VirtualBox

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

Last change on this file since 94660 was 94533, checked in by vboxsync, 3 years ago

Main/Unattended: ​​bugref:9781. Renaming the newly added attribute.

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