VirtualBox

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

Last change on this file since 38395 was 37862, checked in by vboxsync, 13 years ago

Main-OVF;FE/*: allow to specify if MAC addresses should be reinitialized on OVF/OVA import

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