VirtualBox

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

Last change on this file since 71018 was 70999, checked in by vboxsync, 7 years ago

Main/Unattended: Started to detect RHEL and OEL iso images.

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