VirtualBox

source: vbox/trunk/src/VBox/Main/include/ApplianceImpl.h@ 33238

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

Main: new VirtualBox::ComposeMachineFilename() API; remove the 'default hard disk folder' concept and related APIs; GUI wizards need fixing

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.0 KB
Line 
1/* $Id: ApplianceImpl.h 33238 2010-10-19 15:41:23Z vboxsync $ */
2
3/** @file
4 *
5 * VirtualBox COM class implementation
6 */
7
8/*
9 * Copyright (C) 2006-2009 Oracle Corporation
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 */
19
20#ifndef ____H_APPLIANCEIMPL
21#define ____H_APPLIANCEIMPL
22
23/* VBox includes */
24#include "VirtualBoxBase.h"
25
26/* VBox forward declarations */
27class Progress;
28class VirtualSystemDescription;
29struct VirtualSystemDescriptionEntry;
30typedef struct VDINTERFACE *PVDINTERFACE;
31typedef struct VDINTERFACEIO *PVDINTERFACEIO;
32typedef struct SHA1STORAGE *PSHA1STORAGE;
33
34namespace ovf
35{
36 struct HardDiskController;
37 struct VirtualSystem;
38 class OVFReader;
39 struct DiskImage;
40}
41
42namespace xml
43{
44 class Document;
45 class ElementNode;
46}
47
48namespace settings
49{
50 class MachineConfigFile;
51}
52
53class ATL_NO_VTABLE Appliance :
54 public VirtualBoxBase,
55 VBOX_SCRIPTABLE_IMPL(IAppliance)
56{
57public:
58 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Appliance, IAppliance)
59
60 DECLARE_NOT_AGGREGATABLE(Appliance)
61
62 DECLARE_PROTECT_FINAL_CONSTRUCT()
63
64 BEGIN_COM_MAP(Appliance)
65 COM_INTERFACE_ENTRY(ISupportErrorInfo)
66 COM_INTERFACE_ENTRY(IAppliance)
67 COM_INTERFACE_ENTRY(IDispatch)
68 END_COM_MAP()
69
70 DECLARE_EMPTY_CTOR_DTOR (Appliance)
71
72 enum OVFFormat
73 {
74 unspecified,
75 OVF_0_9,
76 OVF_1_0
77 };
78
79 // public initializer/uninitializer for internal purposes only
80 HRESULT FinalConstruct() { return S_OK; }
81 void FinalRelease() { uninit(); }
82
83 HRESULT init(VirtualBox *aVirtualBox);
84 void uninit();
85
86 /* IAppliance properties */
87 STDMETHOD(COMGETTER(Path))(BSTR *aPath);
88 STDMETHOD(COMGETTER(Disks))(ComSafeArrayOut(BSTR, aDisks));
89 STDMETHOD(COMGETTER(VirtualSystemDescriptions))(ComSafeArrayOut(IVirtualSystemDescription*, aVirtualSystemDescriptions));
90 STDMETHOD(COMGETTER(Machines))(ComSafeArrayOut(BSTR, aMachines));
91
92 /* IAppliance methods */
93 /* Import methods */
94 STDMETHOD(Read)(IN_BSTR path, IProgress **aProgress);
95 STDMETHOD(Interpret)(void);
96 STDMETHOD(ImportMachines)(IProgress **aProgress);
97 /* Export methods */
98 STDMETHOD(CreateVFSExplorer)(IN_BSTR aURI, IVFSExplorer **aExplorer);
99 STDMETHOD(Write)(IN_BSTR format, BOOL fManifest, IN_BSTR path, IProgress **aProgress);
100
101 STDMETHOD(GetWarnings)(ComSafeArrayOut(BSTR, aWarnings));
102
103 /* public methods only for internal purposes */
104
105 static HRESULT setErrorStatic(HRESULT aResultCode,
106 const Utf8Str &aText)
107 {
108 return setErrorInternal(aResultCode, getStaticClassIID(), getStaticComponentName(), aText, false, true);
109 }
110
111 /* private instance data */
112private:
113 /** weak VirtualBox parent */
114 VirtualBox* const mVirtualBox;
115
116 struct Data; // opaque, defined in ApplianceImpl.cpp
117 Data *m;
118
119 bool isApplianceIdle();
120
121 HRESULT searchUniqueVMName(Utf8Str& aName) const;
122 HRESULT searchUniqueDiskImageFilePath(Utf8Str& aName) const;
123 void waitForAsyncProgress(ComObjPtr<Progress> &pProgressThis, ComPtr<IProgress> &pProgressAsync);
124 void addWarning(const char* aWarning, ...);
125
126 void disksWeight();
127 struct LocationInfo;
128 enum SetUpProgressMode { ImportFileWithManifest, ImportFileNoManifest, ImportS3, WriteFile, WriteS3 };
129 HRESULT setUpProgress(const LocationInfo &locInfo,
130 ComObjPtr<Progress> &pProgress,
131 const Bstr &bstrDescription,
132 SetUpProgressMode mode);
133
134 void parseURI(Utf8Str strUri, LocationInfo &locInfo) const;
135 void parseBucket(Utf8Str &aPath, Utf8Str &aBucket);
136 Utf8Str manifestFileName(const Utf8Str& aPath) const;
137 Utf8Str queryManifestFileName(const Utf8Str& aPath) const;
138
139 HRESULT readImpl(const LocationInfo &aLocInfo, ComObjPtr<Progress> &aProgress);
140
141 struct TaskOVF;
142 static DECLCALLBACK(int) taskThreadImportOrExport(RTTHREAD aThread, void *pvUser);
143
144 HRESULT readFS(const LocationInfo &locInfo, ComObjPtr<Progress> &pProgress);
145 HRESULT readFSOVF(const LocationInfo &locInfo, ComObjPtr<Progress> &pProgress);
146 HRESULT readFSOVA(const LocationInfo &locInfo, ComObjPtr<Progress> &pProgress);
147 HRESULT readS3(TaskOVF *pTask);
148
149 void convertDiskAttachmentValues(const ovf::HardDiskController &hdc,
150 uint32_t ulAddressOnParent,
151 Bstr &controllerType,
152 int32_t &lControllerPort,
153 int32_t &lDevice);
154
155 HRESULT importImpl(const LocationInfo &aLocInfo, ComObjPtr<Progress> &aProgress);
156 HRESULT manifestVerify(const LocationInfo &locInfo, const ovf::OVFReader &reader, ComObjPtr<Progress> &pProgress);
157
158 HRESULT importFS(TaskOVF *pTask);
159 HRESULT importFSOVF(TaskOVF *pTask);
160 HRESULT importFSOVA(TaskOVF *pTask);
161
162 struct ImportStack;
163 void importOneDiskImage(const ovf::DiskImage &di,
164 const Utf8Str &strTargetPath,
165 ComPtr<IMedium> &pTargetHD,
166 ImportStack &stack);
167 void importMachineGeneric(const ovf::VirtualSystem &vsysThis,
168 ComObjPtr<VirtualSystemDescription> &vsdescThis,
169 ComPtr<IMachine> &pNewMachine,
170 ImportStack &stack);
171 void importVBoxMachine(ComObjPtr<VirtualSystemDescription> &vsdescThis,
172 ComPtr<IMachine> &pNewMachine,
173 ImportStack &stack);
174
175 HRESULT importS3(TaskOVF *pTask);
176
177 HRESULT writeImpl(OVFFormat aFormat, const LocationInfo &aLocInfo, ComObjPtr<Progress> &aProgress);
178
179 struct XMLStack;
180 void buildXML(AutoWriteLockBase& writeLock, xml::Document &doc, XMLStack &stack, const Utf8Str &strPath, OVFFormat enFormat);
181 void buildXMLForOneVirtualSystem(AutoWriteLockBase& writeLock,
182 xml::ElementNode &elmToAddVirtualSystemsTo,
183 std::list<xml::ElementNode*> *pllElementsWithUuidAttributes,
184 ComObjPtr<VirtualSystemDescription> &vsdescThis,
185 OVFFormat enFormat,
186 XMLStack &stack);
187
188 HRESULT writeFS(TaskOVF *pTask);
189 HRESULT writeFSOVF(TaskOVF *pTask, AutoWriteLockBase& writeLock);
190 HRESULT writeFSOVA(TaskOVF *pTask, AutoWriteLockBase& writeLock);
191 HRESULT writeFSImpl(TaskOVF *pTask, AutoWriteLockBase& writeLock, PVDINTERFACEIO pCallbacks, PSHA1STORAGE pStorage);
192 HRESULT writeS3(TaskOVF *pTask);
193
194 friend class Machine;
195};
196
197struct VirtualSystemDescriptionEntry
198{
199 uint32_t ulIndex; // zero-based index of this entry within array
200 VirtualSystemDescriptionType_T type; // type of this entry
201 Utf8Str strRef; // reference number (hard disk controllers only)
202 Utf8Str strOvf; // original OVF value (type-dependent)
203 Utf8Str strVboxSuggested; // configuration value (type-dependent); original value suggested by interpret()
204 Utf8Str strVboxCurrent; // configuration value (type-dependent); current value, either from interpret() or setFinalValue()
205 Utf8Str strExtraConfigSuggested; // extra configuration key=value strings (type-dependent); original value suggested by interpret()
206 Utf8Str strExtraConfigCurrent; // extra configuration key=value strings (type-dependent); current value, either from interpret() or setFinalValue()
207
208 uint32_t ulSizeMB; // hard disk images only: a copy of ovf::DiskImage::ulSuggestedSizeMB
209};
210
211class ATL_NO_VTABLE VirtualSystemDescription :
212 public VirtualBoxBase,
213 VBOX_SCRIPTABLE_IMPL(IVirtualSystemDescription)
214{
215 friend class Appliance;
216
217public:
218 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(VirtualSystemDescription, IVirtualSystemDescription)
219
220 DECLARE_NOT_AGGREGATABLE(VirtualSystemDescription)
221
222 DECLARE_PROTECT_FINAL_CONSTRUCT()
223
224 BEGIN_COM_MAP(VirtualSystemDescription)
225 COM_INTERFACE_ENTRY(ISupportErrorInfo)
226 COM_INTERFACE_ENTRY(IVirtualSystemDescription)
227 COM_INTERFACE_ENTRY(IDispatch)
228 END_COM_MAP()
229
230 DECLARE_EMPTY_CTOR_DTOR (VirtualSystemDescription)
231
232 // public initializer/uninitializer for internal purposes only
233 HRESULT FinalConstruct() { return S_OK; }
234 void FinalRelease() { uninit(); }
235
236 HRESULT init();
237 void uninit();
238
239 /* IVirtualSystemDescription properties */
240 STDMETHOD(COMGETTER(Count))(ULONG *aCount);
241
242 /* IVirtualSystemDescription methods */
243 STDMETHOD(GetDescription)(ComSafeArrayOut(VirtualSystemDescriptionType_T, aTypes),
244 ComSafeArrayOut(BSTR, aRefs),
245 ComSafeArrayOut(BSTR, aOvfValues),
246 ComSafeArrayOut(BSTR, aVboxValues),
247 ComSafeArrayOut(BSTR, aExtraConfigValues));
248
249 STDMETHOD(GetDescriptionByType)(VirtualSystemDescriptionType_T aType,
250 ComSafeArrayOut(VirtualSystemDescriptionType_T, aTypes),
251 ComSafeArrayOut(BSTR, aRefs),
252 ComSafeArrayOut(BSTR, aOvfValues),
253 ComSafeArrayOut(BSTR, aVboxValues),
254 ComSafeArrayOut(BSTR, aExtraConfigValues));
255
256 STDMETHOD(GetValuesByType)(VirtualSystemDescriptionType_T aType,
257 VirtualSystemDescriptionValueType_T aWhich,
258 ComSafeArrayOut(BSTR, aValues));
259
260 STDMETHOD(SetFinalValues)(ComSafeArrayIn(BOOL, aEnabled),
261 ComSafeArrayIn(IN_BSTR, aVboxValues),
262 ComSafeArrayIn(IN_BSTR, aExtraConfigValues));
263
264 STDMETHOD(AddDescription)(VirtualSystemDescriptionType_T aType,
265 IN_BSTR aVboxValue,
266 IN_BSTR aExtraConfigValue);
267
268 /* public methods only for internal purposes */
269
270 void addEntry(VirtualSystemDescriptionType_T aType,
271 const Utf8Str &strRef,
272 const Utf8Str &aOvfValue,
273 const Utf8Str &aVboxValue,
274 uint32_t ulSizeMB = 0,
275 const Utf8Str &strExtraConfig = "");
276
277 std::list<VirtualSystemDescriptionEntry*> findByType(VirtualSystemDescriptionType_T aType);
278 const VirtualSystemDescriptionEntry* findControllerFromID(uint32_t id);
279
280 void importVboxMachineXML(const xml::ElementNode &elmMachine);
281 const settings::MachineConfigFile* getMachineConfig() const;
282
283 /* private instance data */
284private:
285 struct Data;
286 Data *m;
287
288 friend class Machine;
289};
290
291#endif // ____H_APPLIANCEIMPL
292/* vi: set tabstop=4 shiftwidth=4 expandtab: */
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