VirtualBox

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

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

Main/OVF: fix IDE controller export broken by r60336

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.0 KB
Line 
1/* $Id: ApplianceImpl.h 28596 2010-04-22 14:02:59Z vboxsync $ */
2
3/** @file
4 *
5 * VirtualBox COM class implementation
6 */
7
8/*
9 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
20 * Clara, CA 95054 USA or visit http://www.sun.com if you need
21 * additional information or have any questions.
22 */
23
24#ifndef ____H_APPLIANCEIMPL
25#define ____H_APPLIANCEIMPL
26
27/* VBox includes */
28#include "VirtualBoxBase.h"
29
30/* VBox forward declarations */
31class Progress;
32class VirtualSystemDescription;
33struct VirtualSystemDescriptionEntry;
34
35namespace ovf
36{
37 struct HardDiskController;
38 struct VirtualSystem;
39 class OVFReader;
40 struct DiskImage;
41}
42
43namespace xml
44{
45 class ElementNode;
46}
47
48namespace settings
49{
50 class MachineConfigFile;
51}
52
53class ATL_NO_VTABLE Appliance :
54 public VirtualBoxBase,
55 public VirtualBoxSupportErrorInfoImpl<Appliance, IAppliance>,
56 public VirtualBoxSupportTranslation<Appliance>,
57 VBOX_SCRIPTABLE_IMPL(IAppliance)
58{
59public:
60 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Appliance)
61
62 DECLARE_NOT_AGGREGATABLE(Appliance)
63
64 DECLARE_PROTECT_FINAL_CONSTRUCT()
65
66 BEGIN_COM_MAP(Appliance)
67 COM_INTERFACE_ENTRY(ISupportErrorInfo)
68 COM_INTERFACE_ENTRY(IAppliance)
69 COM_INTERFACE_ENTRY(IDispatch)
70 END_COM_MAP()
71
72 DECLARE_EMPTY_CTOR_DTOR (Appliance)
73
74 enum OVFFormat
75 {
76 unspecified,
77 OVF_0_9,
78 OVF_1_0
79 };
80
81 // public initializer/uninitializer for internal purposes only
82 HRESULT FinalConstruct() { return S_OK; }
83 void FinalRelease() { uninit(); }
84
85 HRESULT init(VirtualBox *aVirtualBox);
86 void uninit();
87
88 // for VirtualBoxSupportErrorInfoImpl
89 static const wchar_t *getComponentName() { return L"Appliance"; }
90
91 /* IAppliance properties */
92 STDMETHOD(COMGETTER(Path))(BSTR *aPath);
93 STDMETHOD(COMGETTER(Disks))(ComSafeArrayOut(BSTR, aDisks));
94 STDMETHOD(COMGETTER(VirtualSystemDescriptions))(ComSafeArrayOut(IVirtualSystemDescription*, aVirtualSystemDescriptions));
95
96 /* IAppliance methods */
97 /* Import methods */
98 STDMETHOD(Read)(IN_BSTR path, IProgress **aProgress);
99 STDMETHOD(Interpret)(void);
100 STDMETHOD(ImportMachines)(IProgress **aProgress);
101 /* Export methods */
102 STDMETHOD(CreateVFSExplorer)(IN_BSTR aURI, IVFSExplorer **aExplorer);
103 STDMETHOD(Write)(IN_BSTR format, IN_BSTR path, IProgress **aProgress);
104
105 STDMETHOD(GetWarnings)(ComSafeArrayOut(BSTR, aWarnings));
106
107 /* public methods only for internal purposes */
108
109 /* private instance data */
110private:
111 /** weak VirtualBox parent */
112 VirtualBox* const mVirtualBox;
113
114 struct Data; // opaque, defined in ApplianceImpl.cpp
115 Data *m;
116
117 bool isApplianceIdle() const;
118
119 HRESULT searchUniqueVMName(Utf8Str& aName) const;
120 HRESULT searchUniqueDiskImageFilePath(Utf8Str& aName) const;
121 HRESULT getDefaultHardDiskFolder(Utf8Str &str) const;
122 void waitForAsyncProgress(ComObjPtr<Progress> &pProgressThis, ComPtr<IProgress> &pProgressAsync);
123 void addWarning(const char* aWarning, ...);
124
125 void disksWeight();
126 enum SetUpProgressMode { Regular, ImportS3, WriteS3 };
127 HRESULT setUpProgress(ComObjPtr<Progress> &pProgress,
128 const Bstr &bstrDescription,
129 SetUpProgressMode mode);
130
131 struct LocationInfo;
132 void parseURI(Utf8Str strUri, LocationInfo &locInfo) const;
133 void parseBucket(Utf8Str &aPath, Utf8Str &aBucket) const;
134 Utf8Str manifestFileName(Utf8Str aPath) const;
135
136 HRESULT readImpl(const LocationInfo &aLocInfo, ComObjPtr<Progress> &aProgress);
137
138 struct TaskOVF;
139 static DECLCALLBACK(int) taskThreadImportOrExport(RTTHREAD aThread, void *pvUser);
140
141 HRESULT readFS(const LocationInfo &locInfo);
142 HRESULT readS3(TaskOVF *pTask);
143
144 void convertDiskAttachmentValues(const ovf::HardDiskController &hdc,
145 uint32_t ulAddressOnParent,
146 Bstr &controllerType,
147 int32_t &lChannel,
148 int32_t &lDevice);
149
150 HRESULT importImpl(const LocationInfo &aLocInfo, ComObjPtr<Progress> &aProgress);
151 HRESULT manifestVerify(const LocationInfo &locInfo, const ovf::OVFReader &reader);
152
153 HRESULT importFS(const LocationInfo &locInfo, ComObjPtr<Progress> &aProgress);
154
155 struct ImportStack;
156 void importOneDiskImage(const ovf::DiskImage &di,
157 const Utf8Str &strTargetPath,
158 ComPtr<IMedium> &pTargetHD,
159 ImportStack &stack);
160 void importMachineGeneric(const ovf::VirtualSystem &vsysThis,
161 ComObjPtr<VirtualSystemDescription> &vsdescThis,
162 ComPtr<IMachine> &pNewMachine,
163 ImportStack &stack);
164 void importVBoxMachine(ComObjPtr<VirtualSystemDescription> &vsdescThis,
165 ComPtr<IMachine> &pNewMachine,
166 ImportStack &stack);
167
168 HRESULT importS3(TaskOVF *pTask);
169
170 HRESULT writeImpl(OVFFormat aFormat, const LocationInfo &aLocInfo, ComObjPtr<Progress> &aProgress);
171
172 struct XMLStack;
173 void buildXMLForOneVirtualSystem(xml::ElementNode &elmToAddVirtualSystemsTo,
174 ComObjPtr<VirtualSystemDescription> &vsdescThis,
175 OVFFormat enFormat,
176 XMLStack &stack);
177
178 HRESULT writeFS(const LocationInfo &locInfo, const OVFFormat enFormat, ComObjPtr<Progress> &pProgress);
179 HRESULT writeS3(TaskOVF *pTask);
180
181 friend class Machine;
182};
183
184struct VirtualSystemDescriptionEntry
185{
186 uint32_t ulIndex; // zero-based index of this entry within array
187 VirtualSystemDescriptionType_T type; // type of this entry
188 Utf8Str strRef; // reference number (hard disk controllers only)
189 Utf8Str strOvf; // original OVF value (type-dependent)
190 Utf8Str strVbox; // configuration value (type-dependent)
191 Utf8Str strExtraConfig; // extra configuration key=value strings (type-dependent)
192
193 uint32_t ulSizeMB; // hard disk images only: a copy of ovf::DiskImage::ulSuggestedSizeMB
194};
195
196class ATL_NO_VTABLE VirtualSystemDescription :
197 public VirtualBoxBase,
198 public VirtualBoxSupportErrorInfoImpl<VirtualSystemDescription, IVirtualSystemDescription>,
199 public VirtualBoxSupportTranslation<VirtualSystemDescription>,
200 VBOX_SCRIPTABLE_IMPL(IVirtualSystemDescription)
201{
202 friend class Appliance;
203
204public:
205 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (VirtualSystemDescription)
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 // for VirtualBoxSupportErrorInfoImpl
227 static const wchar_t *getComponentName() { return L"VirtualSystemDescription"; }
228
229 /* IVirtualSystemDescription properties */
230 STDMETHOD(COMGETTER(Count))(ULONG *aCount);
231
232 /* IVirtualSystemDescription methods */
233 STDMETHOD(GetDescription)(ComSafeArrayOut(VirtualSystemDescriptionType_T, aTypes),
234 ComSafeArrayOut(BSTR, aRefs),
235 ComSafeArrayOut(BSTR, aOvfValues),
236 ComSafeArrayOut(BSTR, aVboxValues),
237 ComSafeArrayOut(BSTR, aExtraConfigValues));
238
239 STDMETHOD(GetDescriptionByType)(VirtualSystemDescriptionType_T aType,
240 ComSafeArrayOut(VirtualSystemDescriptionType_T, aTypes),
241 ComSafeArrayOut(BSTR, aRefs),
242 ComSafeArrayOut(BSTR, aOvfValues),
243 ComSafeArrayOut(BSTR, aVboxValues),
244 ComSafeArrayOut(BSTR, aExtraConfigValues));
245
246 STDMETHOD(GetValuesByType)(VirtualSystemDescriptionType_T aType,
247 VirtualSystemDescriptionValueType_T aWhich,
248 ComSafeArrayOut(BSTR, aValues));
249
250 STDMETHOD(SetFinalValues)(ComSafeArrayIn(BOOL, aEnabled),
251 ComSafeArrayIn(IN_BSTR, aVboxValues),
252 ComSafeArrayIn(IN_BSTR, aExtraConfigValues));
253
254 STDMETHOD(AddDescription)(VirtualSystemDescriptionType_T aType,
255 IN_BSTR aVboxValue,
256 IN_BSTR aExtraConfigValue);
257
258 /* public methods only for internal purposes */
259
260 void addEntry(VirtualSystemDescriptionType_T aType,
261 const Utf8Str &strRef,
262 const Utf8Str &aOvfValue,
263 const Utf8Str &aVboxValue,
264 uint32_t ulSizeMB = 0,
265 const Utf8Str &strExtraConfig = "");
266
267 std::list<VirtualSystemDescriptionEntry*> findByType(VirtualSystemDescriptionType_T aType);
268 const VirtualSystemDescriptionEntry* findControllerFromID(uint32_t id);
269
270 void importVboxMachineXML(const xml::ElementNode &elmMachine);
271 const settings::MachineConfigFile* getMachineConfig() const;
272
273 /* private instance data */
274private:
275 struct Data;
276 Data *m;
277
278 friend class Machine;
279};
280
281#endif // ____H_APPLIANCEIMPL
282/* 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