VirtualBox

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

Last change on this file since 49038 was 49038, checked in by vboxsync, 12 years ago

Main/Appliance: change API of IAppliance::write, allowing easy handling of multiple options, needed for making the DVD image export optional
Frontends/VirtualBox+VBoxManage: corresponding adaptions
doc/SDKRef: mention incompatible API change

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