VirtualBox

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

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

pr6927. ISO images are skipped by default during export. The command "VBoxManage export" has a new argument "--iso" to explicitly export ISO images.

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