VirtualBox

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

Last change on this file since 30670 was 30008, checked in by vboxsync, 14 years ago

Main/OVF: fix 3.2.2 regression that OVFs with a VM description (annotation) could not be imported

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