VirtualBox

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

Last change on this file since 83489 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

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