VirtualBox

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

Last change on this file since 30716 was 30716, checked in by vboxsync, 15 years ago

release build fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.2 KB
Line 
1/* $Id: ApplianceImpl.h 30716 2010-07-07 16:40:45Z 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;
30
31namespace ovf
32{
33 struct HardDiskController;
34 struct VirtualSystem;
35 class OVFReader;
36 struct DiskImage;
37}
38
39namespace xml
40{
41 class ElementNode;
42}
43
44namespace settings
45{
46 class MachineConfigFile;
47}
48
49class ATL_NO_VTABLE Appliance :
50 public VirtualBoxBase,
51 public VirtualBoxSupportTranslation<Appliance>,
52 VBOX_SCRIPTABLE_IMPL(IAppliance)
53{
54public:
55 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Appliance, IAppliance)
56
57 DECLARE_NOT_AGGREGATABLE(Appliance)
58
59 DECLARE_PROTECT_FINAL_CONSTRUCT()
60
61 BEGIN_COM_MAP(Appliance)
62 COM_INTERFACE_ENTRY(ISupportErrorInfo)
63 COM_INTERFACE_ENTRY(IAppliance)
64 COM_INTERFACE_ENTRY(IDispatch)
65 END_COM_MAP()
66
67 DECLARE_EMPTY_CTOR_DTOR (Appliance)
68
69 enum OVFFormat
70 {
71 unspecified,
72 OVF_0_9,
73 OVF_1_0
74 };
75
76 // public initializer/uninitializer for internal purposes only
77 HRESULT FinalConstruct() { return S_OK; }
78 void FinalRelease() { uninit(); }
79
80 HRESULT init(VirtualBox *aVirtualBox);
81 void uninit();
82
83 /* IAppliance properties */
84 STDMETHOD(COMGETTER(Path))(BSTR *aPath);
85 STDMETHOD(COMGETTER(Disks))(ComSafeArrayOut(BSTR, aDisks));
86 STDMETHOD(COMGETTER(VirtualSystemDescriptions))(ComSafeArrayOut(IVirtualSystemDescription*, aVirtualSystemDescriptions));
87
88 /* IAppliance methods */
89 /* Import methods */
90 STDMETHOD(Read)(IN_BSTR path, IProgress **aProgress);
91 STDMETHOD(Interpret)(void);
92 STDMETHOD(ImportMachines)(IProgress **aProgress);
93 /* Export methods */
94 STDMETHOD(CreateVFSExplorer)(IN_BSTR aURI, IVFSExplorer **aExplorer);
95 STDMETHOD(Write)(IN_BSTR format, IN_BSTR path, IProgress **aProgress);
96
97 STDMETHOD(GetWarnings)(ComSafeArrayOut(BSTR, aWarnings));
98
99 /* public methods only for internal purposes */
100
101 static HRESULT setErrorStatic(HRESULT aResultCode,
102 const Utf8Str &aText)
103 {
104 return setErrorInternal(aResultCode, getStaticClassIID(), getStaticComponentName(), aText, false, true);
105 }
106
107 /* private instance data */
108private:
109 /** weak VirtualBox parent */
110 VirtualBox* const mVirtualBox;
111
112 struct Data; // opaque, defined in ApplianceImpl.cpp
113 Data *m;
114
115 bool isApplianceIdle();
116
117 HRESULT searchUniqueVMName(Utf8Str& aName) const;
118 HRESULT searchUniqueDiskImageFilePath(Utf8Str& aName) const;
119 HRESULT getDefaultHardDiskFolder(Utf8Str &str) const;
120 void waitForAsyncProgress(ComObjPtr<Progress> &pProgressThis, ComPtr<IProgress> &pProgressAsync);
121 void addWarning(const char* aWarning, ...);
122
123 void disksWeight();
124 enum SetUpProgressMode { ImportFileWithManifest, ImportFileNoManifest, ImportS3, WriteFile, WriteS3 };
125 HRESULT setUpProgress(ComObjPtr<Progress> &pProgress,
126 const Bstr &bstrDescription,
127 SetUpProgressMode mode);
128
129 struct LocationInfo;
130 void parseURI(Utf8Str strUri, LocationInfo &locInfo) const;
131 void parseBucket(Utf8Str &aPath, Utf8Str &aBucket);
132 Utf8Str manifestFileName(Utf8Str aPath) const;
133
134 HRESULT readImpl(const LocationInfo &aLocInfo, ComObjPtr<Progress> &aProgress);
135
136 struct TaskOVF;
137 static DECLCALLBACK(int) taskThreadImportOrExport(RTTHREAD aThread, void *pvUser);
138
139 HRESULT readFS(const LocationInfo &locInfo);
140 HRESULT readS3(TaskOVF *pTask);
141
142 void convertDiskAttachmentValues(const ovf::HardDiskController &hdc,
143 uint32_t ulAddressOnParent,
144 Bstr &controllerType,
145 int32_t &lControllerPort,
146 int32_t &lDevice);
147
148 HRESULT importImpl(const LocationInfo &aLocInfo, ComObjPtr<Progress> &aProgress);
149 HRESULT manifestVerify(const LocationInfo &locInfo, const ovf::OVFReader &reader, ComObjPtr<Progress> &pProgress);
150
151 HRESULT importFS(const LocationInfo &locInfo, ComObjPtr<Progress> &aProgress);
152
153 struct ImportStack;
154 void importOneDiskImage(const ovf::DiskImage &di,
155 const Utf8Str &strTargetPath,
156 ComPtr<IMedium> &pTargetHD,
157 ImportStack &stack);
158 void importMachineGeneric(const ovf::VirtualSystem &vsysThis,
159 ComObjPtr<VirtualSystemDescription> &vsdescThis,
160 ComPtr<IMachine> &pNewMachine,
161 ImportStack &stack);
162 void importVBoxMachine(ComObjPtr<VirtualSystemDescription> &vsdescThis,
163 ComPtr<IMachine> &pNewMachine,
164 ImportStack &stack);
165
166 HRESULT importS3(TaskOVF *pTask);
167
168 HRESULT writeImpl(OVFFormat aFormat, const LocationInfo &aLocInfo, ComObjPtr<Progress> &aProgress);
169
170 struct XMLStack;
171 void buildXMLForOneVirtualSystem(xml::ElementNode &elmToAddVirtualSystemsTo,
172 std::list<xml::ElementNode*> *pllElementsWithUuidAttributes,
173 ComObjPtr<VirtualSystemDescription> &vsdescThis,
174 OVFFormat enFormat,
175 XMLStack &stack);
176
177 HRESULT writeFS(const LocationInfo &locInfo, const OVFFormat enFormat, ComObjPtr<Progress> &pProgress);
178 HRESULT writeS3(TaskOVF *pTask);
179
180 friend class Machine;
181};
182
183struct VirtualSystemDescriptionEntry
184{
185 uint32_t ulIndex; // zero-based index of this entry within array
186 VirtualSystemDescriptionType_T type; // type of this entry
187 Utf8Str strRef; // reference number (hard disk controllers only)
188 Utf8Str strOvf; // original OVF value (type-dependent)
189 Utf8Str strVboxSuggested; // configuration value (type-dependent); original value suggested by interpret()
190 Utf8Str strVboxCurrent; // configuration value (type-dependent); current value, either from interpret() or setFinalValue()
191 Utf8Str strExtraConfigSuggested; // extra configuration key=value strings (type-dependent); original value suggested by interpret()
192 Utf8Str strExtraConfigCurrent; // extra configuration key=value strings (type-dependent); current value, either from interpret() or setFinalValue()
193
194 uint32_t ulSizeMB; // hard disk images only: a copy of ovf::DiskImage::ulSuggestedSizeMB
195};
196
197class ATL_NO_VTABLE VirtualSystemDescription :
198 public VirtualBoxBase,
199 public VirtualBoxSupportTranslation<VirtualSystemDescription>,
200 VBOX_SCRIPTABLE_IMPL(IVirtualSystemDescription)
201{
202 friend class Appliance;
203
204public:
205 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(VirtualSystemDescription, IVirtualSystemDescription)
206
207 DECLARE_NOT_AGGREGATABLE(VirtualSystemDescription)
208
209 DECLARE_PROTECT_FINAL_CONSTRUCT()
210
211 BEGIN_COM_MAP(VirtualSystemDescription)
212 COM_INTERFACE_ENTRY(ISupportErrorInfo)
213 COM_INTERFACE_ENTRY(IVirtualSystemDescription)
214 COM_INTERFACE_ENTRY(IDispatch)
215 END_COM_MAP()
216
217 DECLARE_EMPTY_CTOR_DTOR (VirtualSystemDescription)
218
219 // public initializer/uninitializer for internal purposes only
220 HRESULT FinalConstruct() { return S_OK; }
221 void FinalRelease() { uninit(); }
222
223 HRESULT init();
224 void uninit();
225
226 /* IVirtualSystemDescription properties */
227 STDMETHOD(COMGETTER(Count))(ULONG *aCount);
228
229 /* IVirtualSystemDescription methods */
230 STDMETHOD(GetDescription)(ComSafeArrayOut(VirtualSystemDescriptionType_T, aTypes),
231 ComSafeArrayOut(BSTR, aRefs),
232 ComSafeArrayOut(BSTR, aOvfValues),
233 ComSafeArrayOut(BSTR, aVboxValues),
234 ComSafeArrayOut(BSTR, aExtraConfigValues));
235
236 STDMETHOD(GetDescriptionByType)(VirtualSystemDescriptionType_T aType,
237 ComSafeArrayOut(VirtualSystemDescriptionType_T, aTypes),
238 ComSafeArrayOut(BSTR, aRefs),
239 ComSafeArrayOut(BSTR, aOvfValues),
240 ComSafeArrayOut(BSTR, aVboxValues),
241 ComSafeArrayOut(BSTR, aExtraConfigValues));
242
243 STDMETHOD(GetValuesByType)(VirtualSystemDescriptionType_T aType,
244 VirtualSystemDescriptionValueType_T aWhich,
245 ComSafeArrayOut(BSTR, aValues));
246
247 STDMETHOD(SetFinalValues)(ComSafeArrayIn(BOOL, aEnabled),
248 ComSafeArrayIn(IN_BSTR, aVboxValues),
249 ComSafeArrayIn(IN_BSTR, aExtraConfigValues));
250
251 STDMETHOD(AddDescription)(VirtualSystemDescriptionType_T aType,
252 IN_BSTR aVboxValue,
253 IN_BSTR aExtraConfigValue);
254
255 /* public methods only for internal purposes */
256
257 void addEntry(VirtualSystemDescriptionType_T aType,
258 const Utf8Str &strRef,
259 const Utf8Str &aOvfValue,
260 const Utf8Str &aVboxValue,
261 uint32_t ulSizeMB = 0,
262 const Utf8Str &strExtraConfig = "");
263
264 std::list<VirtualSystemDescriptionEntry*> findByType(VirtualSystemDescriptionType_T aType);
265 const VirtualSystemDescriptionEntry* findControllerFromID(uint32_t id);
266
267 void importVboxMachineXML(const xml::ElementNode &elmMachine);
268 const settings::MachineConfigFile* getMachineConfig() const;
269
270 /* private instance data */
271private:
272 struct Data;
273 Data *m;
274
275 friend class Machine;
276};
277
278#endif // ____H_APPLIANCEIMPL
279/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette