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 |
|
---|
21 | class 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. */
|
---|
33 | struct 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
|
---|
45 | struct 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 |
|
---|
84 | struct Appliance::XMLStack
|
---|
85 | {
|
---|
86 | std::map<Utf8Str, const VirtualSystemDescriptionEntry*> mapDisks;
|
---|
87 | std::map<Utf8Str, bool> mapNetworks;
|
---|
88 | };
|
---|
89 |
|
---|
90 | struct 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 |
|
---|
125 | struct 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 | */
|
---|
138 | struct 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 | 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 | std::list<Bstr> llMachinesRegistered; // machines that were registered; list of string UUIDs
|
---|
168 |
|
---|
169 | ImportStack(const LocationInfo &aLocInfo,
|
---|
170 | const ovf::DiskImagesMap &aMapDisks,
|
---|
171 | ComObjPtr<Progress> &aProgress)
|
---|
172 | : locInfo(aLocInfo),
|
---|
173 | mapDisks(aMapDisks),
|
---|
174 | pProgress(aProgress),
|
---|
175 | cCPUs(1),
|
---|
176 | fForceHWVirt(false),
|
---|
177 | fForceIOAPIC(false),
|
---|
178 | ulMemorySizeMB(0),
|
---|
179 | fSessionOpen(false)
|
---|
180 | {
|
---|
181 | // disk images have to be on the same place as the OVF file. So
|
---|
182 | // strip the filename out of the full file path
|
---|
183 | strSourceDir = aLocInfo.strPath;
|
---|
184 | strSourceDir.stripFilename();
|
---|
185 | }
|
---|
186 | };
|
---|
187 |
|
---|
188 | ////////////////////////////////////////////////////////////////////////////////
|
---|
189 | //
|
---|
190 | // VirtualSystemDescription data definition
|
---|
191 | //
|
---|
192 | ////////////////////////////////////////////////////////////////////////////////
|
---|
193 |
|
---|
194 | struct VirtualSystemDescription::Data
|
---|
195 | {
|
---|
196 | std::list<VirtualSystemDescriptionEntry>
|
---|
197 | llDescriptions; // item descriptions
|
---|
198 |
|
---|
199 | ComPtr<Machine> pMachine; // VirtualBox machine this description was exported from (export only)
|
---|
200 |
|
---|
201 | settings::MachineConfigFile
|
---|
202 | *pConfig; // machine config created from <vbox:Machine> element if found (import only)
|
---|
203 | };
|
---|
204 |
|
---|
205 | ////////////////////////////////////////////////////////////////////////////////
|
---|
206 | //
|
---|
207 | // Internal helpers
|
---|
208 | //
|
---|
209 | ////////////////////////////////////////////////////////////////////////////////
|
---|
210 |
|
---|
211 | void convertCIMOSType2VBoxOSType(Utf8Str &strType, ovf::CIMOSType_T c, const Utf8Str &cStr);
|
---|
212 |
|
---|
213 | ovf::CIMOSType_T convertVBoxOSType2CIMOSType(const char *pcszVbox);
|
---|
214 |
|
---|
215 | #endif // ____H_APPLIANCEIMPLPRIVATE
|
---|