VirtualBox

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

Last change on this file since 32736 was 32448, checked in by vboxsync, 14 years ago

Main-OVF: make manifest file creation optional

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.3 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 , fManifest(true)
52 , pReader(NULL)
53 {
54 }
55
56 ~Data()
57 {
58 if (pReader)
59 {
60 delete pReader;
61 pReader = NULL;
62 }
63 }
64
65 ApplianceState state;
66
67 LocationInfo locInfo; // location info for the currently processed OVF
68 bool fManifest; // Create a manifest file on export
69
70 ovf::OVFReader *pReader;
71
72 std::list< ComObjPtr<VirtualSystemDescription> >
73 virtualSystemDescriptions;
74
75 std::list<Utf8Str> llWarnings;
76
77 ULONG ulWeightForXmlOperation;
78 ULONG ulWeightForManifestOperation;
79 ULONG ulTotalDisksMB;
80 ULONG cDisks;
81 Utf8Str strOVFSHA1Digest;
82
83 std::list<Guid> llGuidsMachinesCreated;
84};
85
86struct Appliance::XMLStack
87{
88 std::map<Utf8Str, const VirtualSystemDescriptionEntry*> mapDisks;
89 std::map<Utf8Str, bool> mapNetworks;
90};
91
92struct Appliance::TaskOVF
93{
94 enum TaskType
95 {
96 Read,
97 Import,
98 Write
99 };
100
101 TaskOVF(Appliance *aThat,
102 TaskType aType,
103 LocationInfo aLocInfo,
104 ComObjPtr<Progress> &aProgress)
105 : pAppliance(aThat),
106 taskType(aType),
107 locInfo(aLocInfo),
108 pProgress(aProgress),
109 enFormat(unspecified),
110 rc(S_OK)
111 {}
112
113 static int updateProgress(unsigned uPercent, void *pvUser);
114
115 int startThread();
116
117 Appliance *pAppliance;
118 TaskType taskType;
119 const LocationInfo locInfo;
120 ComObjPtr<Progress> pProgress;
121
122 OVFFormat enFormat;
123
124 HRESULT rc;
125};
126
127struct MyHardDiskAttachment
128{
129 ComPtr<IMachine> pMachine;
130 Bstr controllerType;
131 int32_t lControllerPort; // 0-29 for SATA
132 int32_t lDevice; // IDE: 0 or 1, otherwise 0 always
133};
134
135/**
136 * Used by Appliance::importMachineGeneric() to store
137 * input parameters and rollback information.
138 */
139struct Appliance::ImportStack
140{
141 // input pointers
142 const LocationInfo &locInfo; // ptr to location info from Appliance::importFS()
143 Utf8Str strSourceDir; // directory where source files reside
144 const ovf::DiskImagesMap &mapDisks; // ptr to disks map in OVF
145 ComObjPtr<Progress> &pProgress; // progress object passed into Appliance::importFS()
146
147 // input parameters from VirtualSystemDescriptions
148 Utf8Str strNameVBox; // VM name
149 Utf8Str strOsTypeVBox; // VirtualBox guest OS type as string
150 Utf8Str strDescription;
151 uint32_t cCPUs; // CPU count
152 bool fForceHWVirt; // if true, we force enabling hardware virtualization
153 bool fForceIOAPIC; // if true, we force enabling the IOAPIC
154 uint32_t ulMemorySizeMB; // virtual machien RAM in megabytes
155#ifdef VBOX_WITH_USB
156 bool fUSBEnabled;
157#endif
158 Utf8Str strAudioAdapter; // if not empty, then the guest has audio enabled, and this is the decimal
159 // representation of the audio adapter (should always be "0" for AC97 presently)
160
161 // session (not initially created)
162 ComPtr<ISession> pSession; // session opened in Appliance::importFS() for machine manipulation
163 bool fSessionOpen; // true if the pSession is currently open and needs closing
164
165 // a list of images that we created/imported; this is initially empty
166 // and will be cleaned up on errors
167 std::list<MyHardDiskAttachment> llHardDiskAttachments; // disks that were attached
168 std::list< ComPtr<IMedium> > llHardDisksCreated; // media that were created
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