VirtualBox

source: vbox/trunk/src/VBox/Main/include/ApplianceImplPrivate.h@ 50197

Last change on this file since 50197 was 50197, checked in by vboxsync, 11 years ago

Appliance::TaskOVF::startThread: Corrected the return type and selected a better thread name.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.2 KB
Line 
1/** @file
2 * VirtualBox Appliance private data definitions
3 */
4
5/* Copyright (C) 2006-2013 Oracle Corporation
6 *
7 * This file is part of VirtualBox Open Source Edition (OSE), as
8 * available from http://www.virtualbox.org. This file is free software;
9 * you can redistribute it and/or modify it under the terms of the GNU
10 * General Public License (GPL) as published by the Free Software
11 * Foundation, in version 2 as it comes in the "COPYING" file of the
12 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
13 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
14 */
15
16#ifndef ____H_APPLIANCEIMPLPRIVATE
17#define ____H_APPLIANCEIMPLPRIVATE
18
19class VirtualSystemDescription;
20
21#include "ovfreader.h"
22#include <map>
23
24////////////////////////////////////////////////////////////////////////////////
25//
26// Appliance data definition
27//
28////////////////////////////////////////////////////////////////////////////////
29
30typedef std::pair<Utf8Str, Utf8Str> STRPAIR;
31
32/* Describe a location for the import/export. The location could be a file on a
33 * local hard disk or a remote target based on the supported inet protocols. */
34struct LocationInfo
35{
36 LocationInfo()
37 : storageType(VFSType_File) {}
38 VFSType_T storageType; /* Which type of storage should be handled */
39 Utf8Str strPath; /* File path for the import/export */
40 Utf8Str strHostname; /* Hostname on remote storage locations (could be empty) */
41 Utf8Str strUsername; /* Username on remote storage locations (could be empty) */
42 Utf8Str strPassword; /* Password on remote storage locations (could be empty) */
43};
44
45// opaque private instance data of Appliance class
46struct Appliance::Data
47{
48 enum ApplianceState { ApplianceIdle, ApplianceImporting, ApplianceExporting };
49 enum digest_T {SHA1, SHA256};
50
51 Data()
52 : state(ApplianceIdle)
53 , fManifest(true)
54 , fSha256(false)
55 , fExportISOImages(false)
56 , pReader(NULL)
57 , ulWeightForXmlOperation(0)
58 , ulWeightForManifestOperation(0)
59 , ulTotalDisksMB(0)
60 , cDisks(0)
61 {
62 }
63
64 ~Data()
65 {
66 if (pReader)
67 {
68 delete pReader;
69 pReader = NULL;
70 }
71 }
72
73 ApplianceState state;
74
75 LocationInfo locInfo; // location info for the currently processed OVF
76 bool fManifest; // Create a manifest file on export
77 bool fSha256; // true = SHA256 (OVF 2.0), false = SHA1 (OVF 1.0)
78 Utf8Str strOVFSHADigest;//SHA digest of OVf file. It is stored here after reading OVF file (before import)
79
80 bool fExportISOImages;// when 1 the ISO images are exported
81 bool fX509;// wether X509 is used or not
82
83 RTCList<ImportOptions_T> optListImport;
84 RTCList<ExportOptions_T> optListExport;
85
86 ovf::OVFReader *pReader;
87
88 std::list< ComObjPtr<VirtualSystemDescription> >
89 virtualSystemDescriptions;
90
91 std::list<Utf8Str> llWarnings;
92
93 ULONG ulWeightForXmlOperation;
94 ULONG ulWeightForManifestOperation;
95 ULONG ulTotalDisksMB;
96 ULONG cDisks;
97
98 std::list<Guid> llGuidsMachinesCreated;
99};
100
101struct Appliance::XMLStack
102{
103 std::map<Utf8Str, const VirtualSystemDescriptionEntry*> mapDisks;
104 std::map<Utf8Str, bool> mapNetworks;
105};
106
107struct Appliance::TaskOVF
108{
109 enum TaskType
110 {
111 Read,
112 Import,
113 Write
114 };
115
116 TaskOVF(Appliance *aThat,
117 TaskType aType,
118 LocationInfo aLocInfo,
119 ComObjPtr<Progress> &aProgress)
120 : pAppliance(aThat),
121 taskType(aType),
122 locInfo(aLocInfo),
123 pProgress(aProgress),
124 enFormat(ovf::OVFVersion_unknown),
125 rc(S_OK)
126 {}
127
128 static int updateProgress(unsigned uPercent, void *pvUser);
129
130 HRESULT startThread();
131
132 Appliance *pAppliance;
133 TaskType taskType;
134 const LocationInfo locInfo;
135 ComObjPtr<Progress> pProgress;
136
137 ovf::OVFVersion_T enFormat;
138
139 HRESULT rc;
140};
141
142struct MyHardDiskAttachment
143{
144 ComPtr<IMachine> pMachine;
145 Bstr controllerType;
146 int32_t lControllerPort; // 0-29 for SATA
147 int32_t lDevice; // IDE: 0 or 1, otherwise 0 always
148};
149
150/**
151 * Used by Appliance::importMachineGeneric() to store
152 * input parameters and rollback information.
153 */
154struct Appliance::ImportStack
155{
156 // input pointers
157 const LocationInfo &locInfo; // ptr to location info from Appliance::importFS()
158 Utf8Str strSourceDir; // directory where source files reside
159 const ovf::DiskImagesMap &mapDisks; // ptr to disks map in OVF
160 ComObjPtr<Progress> &pProgress; // progress object passed into Appliance::importFS()
161
162 // input parameters from VirtualSystemDescriptions
163 Utf8Str strNameVBox; // VM name
164 Utf8Str strMachineFolder; // FQ host folder where the VirtualBox machine would be created
165 Utf8Str strOsTypeVBox; // VirtualBox guest OS type as string
166 Utf8Str strDescription;
167 uint32_t cCPUs; // CPU count
168 bool fForceHWVirt; // if true, we force enabling hardware virtualization
169 bool fForceIOAPIC; // if true, we force enabling the IOAPIC
170 uint32_t ulMemorySizeMB; // virtual machine RAM in megabytes
171#ifdef VBOX_WITH_USB
172 bool fUSBEnabled;
173#endif
174 Utf8Str strAudioAdapter; // if not empty, then the guest has audio enabled, and this is the decimal
175 // representation of the audio adapter (should always be "0" for AC97 presently)
176
177 // session (not initially created)
178 ComPtr<ISession> pSession; // session opened in Appliance::importFS() for machine manipulation
179 bool fSessionOpen; // true if the pSession is currently open and needs closing
180
181 // a list of images that we created/imported; this is initially empty
182 // and will be cleaned up on errors
183 std::list<MyHardDiskAttachment> llHardDiskAttachments; // disks that were attached
184 std::list<STRPAIR> llSrcDisksDigest; // Digests of the source disks
185 std::map<Utf8Str , Utf8Str> mapNewUUIDsToOriginalUUIDs;
186
187 ImportStack(const LocationInfo &aLocInfo,
188 const ovf::DiskImagesMap &aMapDisks,
189 ComObjPtr<Progress> &aProgress)
190 : locInfo(aLocInfo),
191 mapDisks(aMapDisks),
192 pProgress(aProgress),
193 cCPUs(1),
194 fForceHWVirt(false),
195 fForceIOAPIC(false),
196 ulMemorySizeMB(0),
197 fSessionOpen(false)
198 {
199 // disk images have to be on the same place as the OVF file. So
200 // strip the filename out of the full file path
201 strSourceDir = aLocInfo.strPath;
202 strSourceDir.stripFilename();
203 }
204
205 HRESULT restoreOriginalUUIDOfAttachedDevice(settings::MachineConfigFile *config);
206 HRESULT saveOriginalUUIDOfAttachedDevice(settings::AttachedDevice &device,
207 const Utf8Str &newlyUuid);
208};
209
210////////////////////////////////////////////////////////////////////////////////
211//
212// VirtualSystemDescription data definition
213//
214////////////////////////////////////////////////////////////////////////////////
215
216struct VirtualSystemDescription::Data
217{
218 std::vector<VirtualSystemDescriptionEntry>
219 maDescriptions; // item descriptions
220
221 ComPtr<Machine> pMachine; // VirtualBox machine this description was exported from (export only)
222
223 settings::MachineConfigFile
224 *pConfig; // machine config created from <vbox:Machine> element if found (import only)
225};
226
227////////////////////////////////////////////////////////////////////////////////
228//
229// Internal helpers
230//
231////////////////////////////////////////////////////////////////////////////////
232
233void convertCIMOSType2VBoxOSType(Utf8Str &strType, ovf::CIMOSType_T c, const Utf8Str &cStr);
234
235ovf::CIMOSType_T convertVBoxOSType2CIMOSType(const char *pcszVBox, BOOL fLongMode);
236
237Utf8Str convertNetworkAttachmentTypeToString(NetworkAttachmentType_T type);
238
239
240typedef struct SHASTORAGE
241{
242 PVDINTERFACE pVDImageIfaces;
243 bool fCreateDigest;
244 bool fSha256; /* false = SHA1 (OVF 1.x), true = SHA256 (OVF 2.0) */
245 Utf8Str strDigest;
246} SHASTORAGE, *PSHASTORAGE;
247
248PVDINTERFACEIO ShaCreateInterface();
249PVDINTERFACEIO FileCreateInterface();
250PVDINTERFACEIO TarCreateInterface();
251int ShaReadBuf(const char *pcszFilename, void **ppvBuf, size_t *pcbSize, PVDINTERFACEIO pIfIo, void *pvUser);
252int ShaWriteBuf(const char *pcszFilename, void *pvBuf, size_t cbSize, PVDINTERFACEIO pIfIo, void *pvUser);
253int decompressImageAndSave(const char *pcszFullFilenameIn, const char *pcszFullFilenameOut, PVDINTERFACEIO pIfIo, void *pvUser);
254int copyFileAndCalcShaDigest(const char *pcszSourceFilename, const char *pcszTargetFilename, PVDINTERFACEIO pIfIo, void *pvUser);
255#endif // !____H_APPLIANCEIMPLPRIVATE
256
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette