VirtualBox

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

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

added a couple of missing Id headers

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