VirtualBox

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

Last change on this file since 55361 was 55184, checked in by vboxsync, 10 years ago

Missing files

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