VirtualBox

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

Last change on this file since 85549 was 84645, checked in by vboxsync, 5 years ago

OCI: (bugref:9469) partial proxy implementation.

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