VirtualBox

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

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

Main: separate internal machine data structs into MachineImplPrivate.h to significantly speed up compilation and for better interface separation; remove obsolete ConsoleEvents.h file

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