VirtualBox

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

Last change on this file since 37618 was 34101, checked in by vboxsync, 14 years ago

Main-OVF: address r67784

  • 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
76 ovf::OVFReader *pReader;
77
78 std::list< ComObjPtr<VirtualSystemDescription> >
79 virtualSystemDescriptions;
80
81 std::list<Utf8Str> llWarnings;
82
83 ULONG ulWeightForXmlOperation;
84 ULONG ulWeightForManifestOperation;
85 ULONG ulTotalDisksMB;
86 ULONG cDisks;
87 Utf8Str strOVFSHA1Digest;
88
89 std::list<Guid> llGuidsMachinesCreated;
90};
91
92struct Appliance::XMLStack
93{
94 std::map<Utf8Str, const VirtualSystemDescriptionEntry*> mapDisks;
95 std::map<Utf8Str, bool> mapNetworks;
96};
97
98struct Appliance::TaskOVF
99{
100 enum TaskType
101 {
102 Read,
103 Import,
104 Write
105 };
106
107 TaskOVF(Appliance *aThat,
108 TaskType aType,
109 LocationInfo aLocInfo,
110 ComObjPtr<Progress> &aProgress)
111 : pAppliance(aThat),
112 taskType(aType),
113 locInfo(aLocInfo),
114 pProgress(aProgress),
115 enFormat(unspecified),
116 rc(S_OK)
117 {}
118
119 static int updateProgress(unsigned uPercent, void *pvUser);
120
121 int startThread();
122
123 Appliance *pAppliance;
124 TaskType taskType;
125 const LocationInfo locInfo;
126 ComObjPtr<Progress> pProgress;
127
128 OVFFormat enFormat;
129
130 HRESULT rc;
131};
132
133struct MyHardDiskAttachment
134{
135 ComPtr<IMachine> pMachine;
136 Bstr controllerType;
137 int32_t lControllerPort; // 0-29 for SATA
138 int32_t lDevice; // IDE: 0 or 1, otherwise 0 always
139};
140
141/**
142 * Used by Appliance::importMachineGeneric() to store
143 * input parameters and rollback information.
144 */
145struct Appliance::ImportStack
146{
147 // input pointers
148 const LocationInfo &locInfo; // ptr to location info from Appliance::importFS()
149 Utf8Str strSourceDir; // directory where source files reside
150 const ovf::DiskImagesMap &mapDisks; // ptr to disks map in OVF
151 ComObjPtr<Progress> &pProgress; // progress object passed into Appliance::importFS()
152
153 // input parameters from VirtualSystemDescriptions
154 Utf8Str strNameVBox; // VM name
155 Utf8Str strMachineFolder; // FQ host folder where the VirtualBox machine would be created
156 Utf8Str strOsTypeVBox; // VirtualBox guest OS type as string
157 Utf8Str strDescription;
158 uint32_t cCPUs; // CPU count
159 bool fForceHWVirt; // if true, we force enabling hardware virtualization
160 bool fForceIOAPIC; // if true, we force enabling the IOAPIC
161 uint32_t ulMemorySizeMB; // virtual machine RAM in megabytes
162#ifdef VBOX_WITH_USB
163 bool fUSBEnabled;
164#endif
165 Utf8Str strAudioAdapter; // if not empty, then the guest has audio enabled, and this is the decimal
166 // representation of the audio adapter (should always be "0" for AC97 presently)
167
168 // session (not initially created)
169 ComPtr<ISession> pSession; // session opened in Appliance::importFS() for machine manipulation
170 bool fSessionOpen; // true if the pSession is currently open and needs closing
171
172 // a list of images that we created/imported; this is initially empty
173 // and will be cleaned up on errors
174 std::list<MyHardDiskAttachment> llHardDiskAttachments; // disks that were attached
175 std::list<STRPAIR> llSrcDisksDigest; // Digests of the source disks
176
177 ImportStack(const LocationInfo &aLocInfo,
178 const ovf::DiskImagesMap &aMapDisks,
179 ComObjPtr<Progress> &aProgress)
180 : locInfo(aLocInfo),
181 mapDisks(aMapDisks),
182 pProgress(aProgress),
183 cCPUs(1),
184 fForceHWVirt(false),
185 fForceIOAPIC(false),
186 ulMemorySizeMB(0),
187 fSessionOpen(false)
188 {
189 // disk images have to be on the same place as the OVF file. So
190 // strip the filename out of the full file path
191 strSourceDir = aLocInfo.strPath;
192 strSourceDir.stripFilename();
193 }
194};
195
196////////////////////////////////////////////////////////////////////////////////
197//
198// VirtualSystemDescription data definition
199//
200////////////////////////////////////////////////////////////////////////////////
201
202struct VirtualSystemDescription::Data
203{
204 std::list<VirtualSystemDescriptionEntry>
205 llDescriptions; // item descriptions
206
207 ComPtr<Machine> pMachine; // VirtualBox machine this description was exported from (export only)
208
209 settings::MachineConfigFile
210 *pConfig; // machine config created from <vbox:Machine> element if found (import only)
211};
212
213////////////////////////////////////////////////////////////////////////////////
214//
215// Internal helpers
216//
217////////////////////////////////////////////////////////////////////////////////
218
219void convertCIMOSType2VBoxOSType(Utf8Str &strType, ovf::CIMOSType_T c, const Utf8Str &cStr);
220
221ovf::CIMOSType_T convertVBoxOSType2CIMOSType(const char *pcszVbox);
222
223Utf8Str convertNetworkAttachmentTypeToString(NetworkAttachmentType_T type);
224
225typedef struct SHA1STORAGE
226{
227 PVDINTERFACE pVDImageIfaces;
228 bool fCreateDigest;
229 Utf8Str strDigest;
230} SHA1STORAGE, *PSHA1STORAGE;
231
232PVDINTERFACEIO Sha1CreateInterface();
233PVDINTERFACEIO FileCreateInterface();
234PVDINTERFACEIO TarCreateInterface();
235int Sha1ReadBuf(const char *pcszFilename, void **ppvBuf, size_t *pcbSize, PVDINTERFACEIO pCallbacks, void *pvUser);
236int Sha1WriteBuf(const char *pcszFilename, void *pvBuf, size_t cbSize, PVDINTERFACEIO pCallbacks, void *pvUser);
237
238#endif // ____H_APPLIANCEIMPLPRIVATE
239
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