VirtualBox

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

Last change on this file since 32059 was 31676, checked in by vboxsync, 14 years ago

Main/FE/Qt4: add initial OVA support

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.2 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 ULONG ulWeightForXmlOperation;
76 ULONG ulWeightForManifestOperation;
77 ULONG ulTotalDisksMB;
78 ULONG cDisks;
79 Utf8Str strOVFSHA1Digest;
80
81 std::list<Guid> llGuidsMachinesCreated;
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 ComPtr<IMachine> pMachine;
128 Bstr controllerType;
129 int32_t lControllerPort; // 0-29 for SATA
130 int32_t lDevice; // IDE: 0 or 1, otherwise 0 always
131};
132
133/**
134 * Used by Appliance::importMachineGeneric() to store
135 * input parameters and rollback information.
136 */
137struct Appliance::ImportStack
138{
139 // input pointers
140 const LocationInfo &locInfo; // ptr to location info from Appliance::importFS()
141 Utf8Str strSourceDir; // directory where source files reside
142 const ovf::DiskImagesMap &mapDisks; // ptr to disks map in OVF
143 ComObjPtr<Progress> &pProgress; // progress object passed into Appliance::importFS()
144
145 // input parameters from VirtualSystemDescriptions
146 Utf8Str strNameVBox; // VM name
147 Utf8Str strOsTypeVBox; // VirtualBox guest OS type as string
148 Utf8Str strDescription;
149 uint32_t cCPUs; // CPU count
150 bool fForceHWVirt; // if true, we force enabling hardware virtualization
151 bool fForceIOAPIC; // if true, we force enabling the IOAPIC
152 uint32_t ulMemorySizeMB; // virtual machien RAM in megabytes
153#ifdef VBOX_WITH_USB
154 bool fUSBEnabled;
155#endif
156 Utf8Str strAudioAdapter; // if not empty, then the guest has audio enabled, and this is the decimal
157 // representation of the audio adapter (should always be "0" for AC97 presently)
158
159 // session (not initially created)
160 ComPtr<ISession> pSession; // session opened in Appliance::importFS() for machine manipulation
161 bool fSessionOpen; // true if the pSession is currently open and needs closing
162
163 // a list of images that we created/imported; this is initially empty
164 // and will be cleaned up on errors
165 std::list<MyHardDiskAttachment> llHardDiskAttachments; // disks that were attached
166 std::list< ComPtr<IMedium> > llHardDisksCreated; // media that were created
167
168 ImportStack(const LocationInfo &aLocInfo,
169 const ovf::DiskImagesMap &aMapDisks,
170 ComObjPtr<Progress> &aProgress)
171 : locInfo(aLocInfo),
172 mapDisks(aMapDisks),
173 pProgress(aProgress),
174 cCPUs(1),
175 fForceHWVirt(false),
176 fForceIOAPIC(false),
177 ulMemorySizeMB(0),
178 fSessionOpen(false)
179 {
180 // disk images have to be on the same place as the OVF file. So
181 // strip the filename out of the full file path
182 strSourceDir = aLocInfo.strPath;
183 strSourceDir.stripFilename();
184 }
185};
186
187////////////////////////////////////////////////////////////////////////////////
188//
189// VirtualSystemDescription data definition
190//
191////////////////////////////////////////////////////////////////////////////////
192
193struct VirtualSystemDescription::Data
194{
195 std::list<VirtualSystemDescriptionEntry>
196 llDescriptions; // item descriptions
197
198 ComPtr<Machine> pMachine; // VirtualBox machine this description was exported from (export only)
199
200 settings::MachineConfigFile
201 *pConfig; // machine config created from <vbox:Machine> element if found (import only)
202};
203
204////////////////////////////////////////////////////////////////////////////////
205//
206// Internal helpers
207//
208////////////////////////////////////////////////////////////////////////////////
209
210void convertCIMOSType2VBoxOSType(Utf8Str &strType, ovf::CIMOSType_T c, const Utf8Str &cStr);
211
212ovf::CIMOSType_T convertVBoxOSType2CIMOSType(const char *pcszVbox);
213
214#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