Changeset 49742 in vbox
- Timestamp:
- Dec 2, 2013 5:59:21 PM (11 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/ApplianceImpl.h
r49620 r49742 22 22 23 23 /* VBox includes */ 24 #include "VirtualBoxBase.h" 24 #include "VirtualSystemDescriptionWrap.h" 25 #include "ApplianceWrap.h" 25 26 #include "MediumFormatImpl.h" 26 27 … … 28 29 * private classes. */ 29 30 #include <iprt/tar.h> 30 #include <iprt/circbuf.h>31 #include <VBox/vd.h>32 #include <iprt/sha.h>33 34 31 #include "ovfreader.h" 35 32 #include <set> … … 50 47 struct HardDiskController; 51 48 struct VirtualSystem; 52 class OVFReader;49 class OVFReader; 53 50 struct DiskImage; 54 51 struct EnvelopeData; … … 67 64 68 65 class ATL_NO_VTABLE Appliance : 69 public VirtualBoxBase, 70 VBOX_SCRIPTABLE_IMPL(IAppliance) 66 public ApplianceWrap 71 67 { 72 68 public: 73 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Appliance, IAppliance) 74 75 DECLARE_NOT_AGGREGATABLE(Appliance) 76 77 DECLARE_PROTECT_FINAL_CONSTRUCT() 78 79 BEGIN_COM_MAP(Appliance) 80 VBOX_DEFAULT_INTERFACE_ENTRIES(IAppliance) 81 END_COM_MAP() 82 83 DECLARE_EMPTY_CTOR_DTOR (Appliance) 84 85 86 87 // public initializer/uninitializer for internal purposes only 88 HRESULT FinalConstruct() { return BaseFinalConstruct(); } 89 void FinalRelease() { uninit(); BaseFinalRelease(); } 69 70 DECLARE_EMPTY_CTOR_DTOR(Appliance) 71 72 HRESULT FinalConstruct(); 73 void FinalRelease(); 74 90 75 91 76 HRESULT init(VirtualBox *aVirtualBox); 92 77 void uninit(); 93 78 94 /* IAppliance properties */95 STDMETHOD(COMGETTER(Path))(BSTR *aPath);96 STDMETHOD(COMGETTER(Disks))(ComSafeArrayOut(BSTR, aDisks));97 STDMETHOD(COMGETTER(VirtualSystemDescriptions))(ComSafeArrayOut(IVirtualSystemDescription*, aVirtualSystemDescriptions));98 STDMETHOD(COMGETTER(Machines))(ComSafeArrayOut(BSTR, aMachines));99 100 /* IAppliance methods */101 /* Import methods */102 STDMETHOD(Read)(IN_BSTR path, IProgress **aProgress);103 STDMETHOD(Interpret)(void);104 STDMETHOD(ImportMachines)(ComSafeArrayIn(ImportOptions_T, options), IProgress **aProgress);105 /* Export methods */106 STDMETHOD(CreateVFSExplorer)(IN_BSTR aURI, IVFSExplorer **aExplorer);107 STDMETHOD(Write)(IN_BSTR format, ComSafeArrayIn(ExportOptions_T, options), IN_BSTR path, IProgress **aProgress);108 109 STDMETHOD(GetWarnings)(ComSafeArrayOut(BSTR, aWarnings));110 111 79 /* public methods only for internal purposes */ 112 80 113 static HRESULT setErrorStatic(HRESULT aResultCode,114 const Utf8Str &aText)81 static HRESULT i_setErrorStatic(HRESULT aResultCode, 82 const Utf8Str &aText) 115 83 { 116 84 return setErrorInternal(aResultCode, getStaticClassIID(), getStaticComponentName(), aText, false, true); … … 120 88 private: 121 89 /** weak VirtualBox parent */ 90 // wrapped IAppliance properties 91 HRESULT getPath(com::Utf8Str &aPath); 92 HRESULT getDisks(std::vector<com::Utf8Str> &aDisks); 93 HRESULT getVirtualSystemDescriptions(std::vector<ComPtr<IVirtualSystemDescription> > &aVirtualSystemDescriptions); 94 HRESULT getMachines(std::vector<com::Utf8Str> &aMachines); 95 96 // wrapped IAppliance methods 97 HRESULT read(const com::Utf8Str &aFile, 98 ComPtr<IProgress> &aProgress); 99 HRESULT interpret(); 100 HRESULT importMachines(const std::vector<ImportOptions_T> &aOptions, 101 ComPtr<IProgress> &aProgress); 102 HRESULT createVFSExplorer(const com::Utf8Str &aURI, 103 ComPtr<IVFSExplorer> &aExplorer); 104 HRESULT write(const com::Utf8Str &aFormat, 105 const std::vector<ExportOptions_T> &aOptions, 106 const com::Utf8Str &aPath, 107 ComPtr<IProgress> &aProgress); 108 HRESULT getWarnings(std::vector<com::Utf8Str> &aWarnings); 109 110 122 111 VirtualBox* const mVirtualBox; 123 112 … … 133 122 ******************************************************************************/ 134 123 135 bool i sApplianceIdle();136 HRESULT searchUniqueVMName(Utf8Str& aName) const;137 HRESULT searchUniqueDiskImageFilePath(Utf8Str& aName) const;138 HRESULT setUpProgress(ComObjPtr<Progress> &pProgress,139 const Bstr &bstrDescription,140 SetUpProgressMode mode);141 void waitForAsyncProgress(ComObjPtr<Progress> &pProgressThis, ComPtr<IProgress> &pProgressAsync);142 void addWarning(const char* aWarning, ...);143 void disksWeight();144 void parseBucket(Utf8Str &aPath, Utf8Str &aBucket);145 146 static DECLCALLBACK(int) taskThreadImportOrExport(RTTHREAD aThread, void *pvUser);147 148 HRESULT i nitSetOfSupportedStandardsURI();149 150 Utf8Str typeOfVirtualDiskFormatFromURI(Utf8Str type) const;151 152 std::set<Utf8Str> URIFromTypeOfVirtualDiskFormat(Utf8Str type);153 154 HRESULT i nitApplianceIONameMap();155 156 Utf8Str applianceIOName(APPLIANCEIONAME type) const;157 158 HRESULT findMediumFormatFromDiskImage(const ovf::DiskImage &di, ComObjPtr<MediumFormat>& mf);124 bool i_isApplianceIdle(); 125 HRESULT i_searchUniqueVMName(Utf8Str& aName) const; 126 HRESULT i_searchUniqueDiskImageFilePath(Utf8Str& aName) const; 127 HRESULT i_setUpProgress(ComObjPtr<Progress> &pProgress, 128 const Bstr &bstrDescription, 129 SetUpProgressMode mode); 130 void i_waitForAsyncProgress(ComObjPtr<Progress> &pProgressThis, ComPtr<IProgress> &pProgressAsync); 131 void i_addWarning(const char* aWarning, ...); 132 void i_disksWeight(); 133 void i_parseBucket(Utf8Str &aPath, Utf8Str &aBucket); 134 135 static DECLCALLBACK(int) i_taskThreadImportOrExport(RTTHREAD aThread, void *pvUser); 136 137 HRESULT i_initSetOfSupportedStandardsURI(); 138 139 Utf8Str i_typeOfVirtualDiskFormatFromURI(Utf8Str type) const; 140 141 std::set<Utf8Str> i_URIFromTypeOfVirtualDiskFormat(Utf8Str type); 142 143 HRESULT i_initApplianceIONameMap(); 144 145 Utf8Str i_applianceIOName(APPLIANCEIONAME type) const; 146 147 HRESULT i_findMediumFormatFromDiskImage(const ovf::DiskImage &di, ComObjPtr<MediumFormat>& mf); 159 148 160 149 /******************************************************************************* … … 162 151 ******************************************************************************/ 163 152 164 HRESULT readImpl(const LocationInfo &aLocInfo, ComObjPtr<Progress> &aProgress);165 166 HRESULT readFS(TaskOVF *pTask);167 HRESULT readFSOVF(TaskOVF *pTask);168 HRESULT readFSOVA(TaskOVF *pTask);169 HRESULT readFSImpl(TaskOVF *pTask, const RTCString &strFilename, PVDINTERFACEIO pCallbacks, PSHASTORAGE pStorage);170 HRESULT readS3(TaskOVF *pTask);153 HRESULT i_readImpl(const LocationInfo &aLocInfo, ComObjPtr<Progress> &aProgress); 154 155 HRESULT i_readFS(TaskOVF *pTask); 156 HRESULT i_readFSOVF(TaskOVF *pTask); 157 HRESULT i_readFSOVA(TaskOVF *pTask); 158 HRESULT i_readFSImpl(TaskOVF *pTask, const RTCString &strFilename, PVDINTERFACEIO pCallbacks, PSHASTORAGE pStorage); 159 HRESULT i_readS3(TaskOVF *pTask); 171 160 172 161 /******************************************************************************* … … 174 163 ******************************************************************************/ 175 164 176 HRESULT importImpl(const LocationInfo &aLocInfo, ComObjPtr<Progress> &aProgress); 177 178 HRESULT importFS(TaskOVF *pTask); 179 HRESULT importFSOVF(TaskOVF *pTask, AutoWriteLockBase& writeLock); 180 HRESULT importFSOVA(TaskOVF *pTask, AutoWriteLockBase& writeLock); 181 HRESULT importS3(TaskOVF *pTask); 182 183 HRESULT readFileToBuf(const Utf8Str &strFile, 184 void **ppvBuf, 185 size_t *pcbSize, 186 bool fCreateDigest, 187 PVDINTERFACEIO pCallbacks, 188 PSHASTORAGE pStorage); 189 HRESULT readTarFileToBuf(RTTAR tar, 190 const Utf8Str &strFile, 191 void **ppvBuf, 192 size_t *pcbSize, 193 bool fCreateDigest, 194 PVDINTERFACEIO pCallbacks, 195 PSHASTORAGE pStorage); 196 HRESULT verifyManifestFile(const Utf8Str &strFile, ImportStack &stack, void *pvBuf, size_t cbSize); 197 198 void convertDiskAttachmentValues(const ovf::HardDiskController &hdc, 199 uint32_t ulAddressOnParent, 200 Bstr &controllerType, 201 int32_t &lControllerPort, 202 int32_t &lDevice); 203 204 void importOneDiskImage(const ovf::DiskImage &di, 205 Utf8Str *strTargetPath, 206 ComObjPtr<Medium> &pTargetHD, 207 ImportStack &stack, 165 HRESULT i_importImpl(const LocationInfo &aLocInfo, ComObjPtr<Progress> &aProgress); 166 167 HRESULT i_importFS(TaskOVF *pTask); 168 HRESULT i_importFSOVF(TaskOVF *pTask, AutoWriteLockBase& writeLock); 169 HRESULT i_importFSOVA(TaskOVF *pTask, AutoWriteLockBase& writeLock); 170 HRESULT i_importS3(TaskOVF *pTask); 171 172 HRESULT i_readFileToBuf(const Utf8Str &strFile, 173 void **ppvBuf, 174 size_t *pcbSize, 175 bool fCreateDigest, 208 176 PVDINTERFACEIO pCallbacks, 209 177 PSHASTORAGE pStorage); 210 211 void importMachineGeneric(const ovf::VirtualSystem &vsysThis, 212 ComObjPtr<VirtualSystemDescription> &vsdescThis, 213 ComPtr<IMachine> &pNewMachine, 178 HRESULT i_readTarFileToBuf(RTTAR tar, 179 const Utf8Str &strFile, 180 void **ppvBuf, 181 size_t *pcbSize, 182 bool fCreateDigest, 183 PVDINTERFACEIO pCallbacks, 184 PSHASTORAGE pStorage); 185 HRESULT i_verifyManifestFile(const Utf8Str &strFile, ImportStack &stack, void *pvBuf, size_t cbSize); 186 187 void i_convertDiskAttachmentValues(const ovf::HardDiskController &hdc, 188 uint32_t ulAddressOnParent, 189 Bstr &controllerType, 190 int32_t &lControllerPort, 191 int32_t &lDevice); 192 193 void i_importOneDiskImage(const ovf::DiskImage &di, 194 Utf8Str *strTargetPath, 195 ComObjPtr<Medium> &pTargetHD, 214 196 ImportStack &stack, 215 197 PVDINTERFACEIO pCallbacks, 216 198 PSHASTORAGE pStorage); 217 void importVBoxMachine(ComObjPtr<VirtualSystemDescription> &vsdescThis, 218 ComPtr<IMachine> &pNewMachine, 219 ImportStack &stack, 220 PVDINTERFACEIO pCallbacks, 221 PSHASTORAGE pStorage); 222 void importMachines(ImportStack &stack, 223 PVDINTERFACEIO pCallbacks, 224 PSHASTORAGE pStorage); 199 200 void i_importMachineGeneric(const ovf::VirtualSystem &vsysThis, 201 ComObjPtr<VirtualSystemDescription> &vsdescThis, 202 ComPtr<IMachine> &pNewMachine, 203 ImportStack &stack, 204 PVDINTERFACEIO pCallbacks, 205 PSHASTORAGE pStorage); 206 void i_importVBoxMachine(ComObjPtr<VirtualSystemDescription> &vsdescThis, 207 ComPtr<IMachine> &pNewMachine, 208 ImportStack &stack, 209 PVDINTERFACEIO pCallbacks, 210 PSHASTORAGE pStorage); 211 void i_importMachines(ImportStack &stack, 212 PVDINTERFACEIO pCallbacks, 213 PSHASTORAGE pStorage); 225 214 226 215 /******************************************************************************* … … 228 217 ******************************************************************************/ 229 218 230 HRESULT writeImpl(ovf::OVFVersion_T aFormat, const LocationInfo &aLocInfo, ComObjPtr<Progress> &aProgress);231 232 HRESULT writeFS(TaskOVF *pTask);233 HRESULT writeFSOVF(TaskOVF *pTask, AutoWriteLockBase& writeLock);234 HRESULT writeFSOVA(TaskOVF *pTask, AutoWriteLockBase& writeLock);235 HRESULT writeFSImpl(TaskOVF *pTask, AutoWriteLockBase& writeLock, PVDINTERFACEIO pCallbacks, PSHASTORAGE pStorage);236 HRESULT writeS3(TaskOVF *pTask);219 HRESULT i_writeImpl(ovf::OVFVersion_T aFormat, const LocationInfo &aLocInfo, ComObjPtr<Progress> &aProgress); 220 221 HRESULT i_writeFS(TaskOVF *pTask); 222 HRESULT i_writeFSOVF(TaskOVF *pTask, AutoWriteLockBase& writeLock); 223 HRESULT i_writeFSOVA(TaskOVF *pTask, AutoWriteLockBase& writeLock); 224 HRESULT i_writeFSImpl(TaskOVF *pTask, AutoWriteLockBase& writeLock, PVDINTERFACEIO pCallbacks, PSHASTORAGE pStorage); 225 HRESULT i_writeS3(TaskOVF *pTask); 237 226 238 227 struct XMLStack; 239 228 240 void buildXML(AutoWriteLockBase& writeLock,241 xml::Document &doc,242 XMLStack &stack,243 const Utf8Str &strPath,244 ovf::OVFVersion_T enFormat);245 void buildXMLForOneVirtualSystem(AutoWriteLockBase& writeLock,246 xml::ElementNode &elmToAddVirtualSystemsTo,247 std::list<xml::ElementNode*> *pllElementsWithUuidAttributes,248 ComObjPtr<VirtualSystemDescription> &vsdescThis,249 ovf::OVFVersion_T enFormat,250 XMLStack &stack);251 252 HRESULT preCheckImageAvailability(PSHASTORAGE pSHAStorage,253 RTCString &availableImage);229 void i_buildXML(AutoWriteLockBase& writeLock, 230 xml::Document &doc, 231 XMLStack &stack, 232 const Utf8Str &strPath, 233 ovf::OVFVersion_T enFormat); 234 void i_buildXMLForOneVirtualSystem(AutoWriteLockBase& writeLock, 235 xml::ElementNode &elmToAddVirtualSystemsTo, 236 std::list<xml::ElementNode*> *pllElementsWithUuidAttributes, 237 ComObjPtr<VirtualSystemDescription> &vsdescThis, 238 ovf::OVFVersion_T enFormat, 239 XMLStack &stack); 240 241 HRESULT i_preCheckImageAvailability(PSHASTORAGE pSHAStorage, 242 RTCString &availableImage); 254 243 255 244 friend class Machine; 256 245 }; 257 246 258 void parseURI(Utf8Str strUri, LocationInfo &locInfo);247 void i_parseURI(Utf8Str strUri, LocationInfo &locInfo); 259 248 260 249 struct VirtualSystemDescriptionEntry … … 273 262 274 263 class ATL_NO_VTABLE VirtualSystemDescription : 275 public VirtualBoxBase, 276 VBOX_SCRIPTABLE_IMPL(IVirtualSystemDescription) 264 public VirtualSystemDescriptionWrap 277 265 { 278 266 friend class Appliance; 279 267 280 268 public: 281 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(VirtualSystemDescription, IVirtualSystemDescription) 282 283 DECLARE_NOT_AGGREGATABLE(VirtualSystemDescription) 284 285 DECLARE_PROTECT_FINAL_CONSTRUCT() 286 287 BEGIN_COM_MAP(VirtualSystemDescription) 288 VBOX_DEFAULT_INTERFACE_ENTRIES(IVirtualSystemDescription) 289 END_COM_MAP() 290 291 DECLARE_EMPTY_CTOR_DTOR (VirtualSystemDescription) 292 293 // public initializer/uninitializer for internal purposes only 294 HRESULT FinalConstruct() { return BaseFinalConstruct(); } 295 void FinalRelease() { uninit(); BaseFinalRelease(); } 269 270 DECLARE_EMPTY_CTOR_DTOR(VirtualSystemDescription) 271 272 HRESULT FinalConstruct(); 273 void FinalRelease(); 296 274 297 275 HRESULT init(); 298 276 void uninit(); 299 277 300 /* IVirtualSystemDescription properties */301 STDMETHOD(COMGETTER(Count))(ULONG *aCount);302 303 /* IVirtualSystemDescription methods */304 STDMETHOD(GetDescription)(ComSafeArrayOut(VirtualSystemDescriptionType_T, aTypes),305 ComSafeArrayOut(BSTR, aRefs),306 ComSafeArrayOut(BSTR, aOvfValues),307 ComSafeArrayOut(BSTR, aVboxValues),308 ComSafeArrayOut(BSTR, aExtraConfigValues));309 310 STDMETHOD(GetDescriptionByType)(VirtualSystemDescriptionType_T aType,311 ComSafeArrayOut(VirtualSystemDescriptionType_T, aTypes),312 ComSafeArrayOut(BSTR, aRefs),313 ComSafeArrayOut(BSTR, aOvfValues),314 ComSafeArrayOut(BSTR, aVboxValues),315 ComSafeArrayOut(BSTR, aExtraConfigValues));316 317 STDMETHOD(GetValuesByType)(VirtualSystemDescriptionType_T aType,318 VirtualSystemDescriptionValueType_T aWhich,319 ComSafeArrayOut(BSTR, aValues));320 321 STDMETHOD(SetFinalValues)(ComSafeArrayIn(BOOL, aEnabled),322 ComSafeArrayIn(IN_BSTR, aVboxValues),323 ComSafeArrayIn(IN_BSTR, aExtraConfigValues));324 325 STDMETHOD(AddDescription)(VirtualSystemDescriptionType_T aType,326 IN_BSTR aVboxValue,327 IN_BSTR aExtraConfigValue);328 329 278 /* public methods only for internal purposes */ 330 331 void addEntry(VirtualSystemDescriptionType_T aType, 332 const Utf8Str &strRef, 333 const Utf8Str &aOvfValue, 334 const Utf8Str &aVboxValue, 335 uint32_t ulSizeMB = 0, 336 const Utf8Str &strExtraConfig = ""); 337 338 std::list<VirtualSystemDescriptionEntry*> findByType(VirtualSystemDescriptionType_T aType); 339 const VirtualSystemDescriptionEntry* findControllerFromID(uint32_t id); 340 341 void importVboxMachineXML(const xml::ElementNode &elmMachine); 342 const settings::MachineConfigFile* getMachineConfig() const; 343 344 void removeByType(VirtualSystemDescriptionType_T aType); 279 void i_addEntry(VirtualSystemDescriptionType_T aType, 280 const Utf8Str &strRef, 281 const Utf8Str &aOvfValue, 282 const Utf8Str &aVboxValue, 283 uint32_t ulSizeMB = 0, 284 const Utf8Str &strExtraConfig = ""); 285 286 std::list<VirtualSystemDescriptionEntry*> i_findByType(VirtualSystemDescriptionType_T aType); 287 const VirtualSystemDescriptionEntry* i_findControllerFromID(uint32_t id); 288 289 void i_importVboxMachineXML(const xml::ElementNode &elmMachine); 290 const settings::MachineConfigFile* i_getMachineConfig() const; 345 291 346 292 /* private instance data */ 347 293 private: 294 295 // wrapped IVirtualSystemDescription properties 296 HRESULT getCount(ULONG *aCount); 297 298 // wrapped IVirtualSystemDescription methods 299 HRESULT getDescription(std::vector<VirtualSystemDescriptionType_T> &aTypes, 300 std::vector<com::Utf8Str> &aRefs, 301 std::vector<com::Utf8Str> &aOVFValues, 302 std::vector<com::Utf8Str> &aVBoxValues, 303 std::vector<com::Utf8Str> &aExtraConfigValues); 304 HRESULT getDescriptionByType(VirtualSystemDescriptionType_T aType, 305 std::vector<VirtualSystemDescriptionType_T> &aTypes, 306 std::vector<com::Utf8Str> &aRefs, 307 std::vector<com::Utf8Str> &aOVFValues, 308 std::vector<com::Utf8Str> &aVBoxValues, 309 std::vector<com::Utf8Str> &aExtraConfigValues); 310 HRESULT getValuesByType(VirtualSystemDescriptionType_T aType, 311 VirtualSystemDescriptionValueType_T aWhich, 312 std::vector<com::Utf8Str> &aValues); 313 HRESULT setFinalValues(const std::vector<BOOL> &aEnabled, 314 const std::vector<com::Utf8Str> &aVBoxValues, 315 const std::vector<com::Utf8Str> &aExtraConfigValues); 316 HRESULT addDescription(VirtualSystemDescriptionType_T aType, 317 const com::Utf8Str &aVBoxValue, 318 const com::Utf8Str &aExtraConfigValue); 319 void i_removeByType(VirtualSystemDescriptionType_T aType); 320 348 321 struct Data; 349 322 Data *m; -
trunk/src/VBox/Main/include/ApplianceImplPrivate.h
r49103 r49742 4 4 */ 5 5 6 /* 7 * Copyright (C) 2006-2013 Oracle Corporation 6 /* Copyright (C) 2006-2013 Oracle Corporation 8 7 * 9 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 212 211 struct VirtualSystemDescription::Data 213 212 { 214 std:: list<VirtualSystemDescriptionEntry>215 llDescriptions; // item descriptions213 std::vector<VirtualSystemDescriptionEntry> 214 maDescriptions; // item descriptions 216 215 217 216 ComPtr<Machine> pMachine; // VirtualBox machine this description was exported from (export only) -
trunk/src/VBox/Main/include/HostImpl.h
r48765 r49742 19 19 #define ____H_HOSTIMPL 20 20 21 #include " VirtualBoxBase.h"21 #include "HostWrap.h" 22 22 23 23 class HostUSBDeviceFilter; … … 35 35 36 36 class ATL_NO_VTABLE Host : 37 public VirtualBoxBase, 38 VBOX_SCRIPTABLE_IMPL(IHost) 37 public HostWrap 39 38 { 40 39 public: 41 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Host, IHost)42 40 43 DECLARE_NOT_AGGREGATABLE(Host) 44 45 DECLARE_PROTECT_FINAL_CONSTRUCT() 46 47 BEGIN_COM_MAP(Host) 48 VBOX_DEFAULT_INTERFACE_ENTRIES(IHost) 49 END_COM_MAP() 41 DECLARE_EMPTY_CTOR_DTOR(Host) 50 42 51 43 HRESULT FinalConstruct(); … … 55 47 HRESULT init(VirtualBox *aParent); 56 48 void uninit(); 57 58 // IHost properties59 STDMETHOD(COMGETTER(DVDDrives))(ComSafeArrayOut(IMedium *, drives));60 STDMETHOD(COMGETTER(FloppyDrives))(ComSafeArrayOut(IMedium *, drives));61 STDMETHOD(COMGETTER(USBDevices))(ComSafeArrayOut(IHostUSBDevice *, aUSBDevices));62 STDMETHOD(COMGETTER(USBDeviceFilters))(ComSafeArrayOut(IHostUSBDeviceFilter *, aUSBDeviceFilters));63 STDMETHOD(COMGETTER(NetworkInterfaces))(ComSafeArrayOut(IHostNetworkInterface *, aNetworkInterfaces));64 STDMETHOD(COMGETTER(NameServers))(ComSafeArrayOut(BSTR, aNameServers));65 STDMETHOD(COMGETTER(DomainName))(BSTR *aDomainName);66 STDMETHOD(COMGETTER(SearchStrings))(ComSafeArrayOut(BSTR, aSearchStrings));67 STDMETHOD(COMGETTER(ProcessorCount))(ULONG *count);68 STDMETHOD(COMGETTER(ProcessorOnlineCount))(ULONG *count);69 STDMETHOD(COMGETTER(ProcessorCoreCount))(ULONG *count);70 STDMETHOD(COMGETTER(ProcessorOnlineCoreCount))(ULONG *count);71 STDMETHOD(GetProcessorSpeed)(ULONG cpuId, ULONG *speed);72 STDMETHOD(GetProcessorDescription)(ULONG cpuId, BSTR *description);73 STDMETHOD(GetProcessorFeature)(ProcessorFeature_T feature, BOOL *supported);74 STDMETHOD(GetProcessorCPUIDLeaf)(ULONG aCpuId, ULONG aLeaf, ULONG aSubLeaf, ULONG *aValEAX, ULONG *aValEBX, ULONG *aValECX, ULONG *aValEDX);75 STDMETHOD(COMGETTER(MemorySize))(ULONG *size);76 STDMETHOD(COMGETTER(MemoryAvailable))(ULONG *available);77 STDMETHOD(COMGETTER(OperatingSystem))(BSTR *os);78 STDMETHOD(COMGETTER(OSVersion))(BSTR *version);79 STDMETHOD(COMGETTER(UTCTime))(LONG64 *aUTCTime);80 STDMETHOD(COMGETTER(Acceleration3DAvailable))(BOOL *aSupported);81 STDMETHOD(COMGETTER(VideoInputDevices))(ComSafeArrayOut(IHostVideoInputDevice*, aVideoInputDevices));82 83 // IHost methods84 STDMETHOD(CreateHostOnlyNetworkInterface)(IHostNetworkInterface **aHostNetworkInterface,85 IProgress **aProgress);86 STDMETHOD(RemoveHostOnlyNetworkInterface)(IN_BSTR aId, IProgress **aProgress);87 STDMETHOD(CreateUSBDeviceFilter)(IN_BSTR aName, IHostUSBDeviceFilter **aFilter);88 STDMETHOD(InsertUSBDeviceFilter)(ULONG aPosition, IHostUSBDeviceFilter *aFilter);89 STDMETHOD(RemoveUSBDeviceFilter)(ULONG aPosition);90 91 STDMETHOD(FindHostDVDDrive)(IN_BSTR aName, IMedium **aDrive);92 STDMETHOD(FindHostFloppyDrive)(IN_BSTR aName, IMedium **aDrive);93 STDMETHOD(FindHostNetworkInterfaceByName)(IN_BSTR aName, IHostNetworkInterface **networkInterface);94 STDMETHOD(FindHostNetworkInterfaceById)(IN_BSTR id, IHostNetworkInterface **networkInterface);95 STDMETHOD(FindHostNetworkInterfacesOfType)(HostNetworkInterfaceType_T type, ComSafeArrayOut(IHostNetworkInterface *, aNetworkInterfaces));96 STDMETHOD(FindUSBDeviceByAddress)(IN_BSTR aAddress, IHostUSBDevice **aDevice);97 STDMETHOD(FindUSBDeviceById)(IN_BSTR aId, IHostUSBDevice **aDevice);98 STDMETHOD(GenerateMACAddress)(BSTR *aAddress);99 49 100 50 // public methods only for internal purposes … … 109 59 } 110 60 111 HRESULT loadSettings(const settings::Host &data);112 HRESULT saveSettings(settings::Host &data);61 HRESULT i_loadSettings(const settings::Host &data); 62 HRESULT i_saveSettings(settings::Host &data); 113 63 114 HRESULT getDrives(DeviceType_T mediumType, bool fRefresh, MediaList *&pll);115 HRESULT findHostDriveById(DeviceType_T mediumType, const Guid &uuid, bool fRefresh, ComObjPtr<Medium> &pMedium);116 HRESULT findHostDriveByName(DeviceType_T mediumType, const Utf8Str &strLocationFull, bool fRefresh, ComObjPtr<Medium> &pMedium);64 HRESULT i_getDrives(DeviceType_T mediumType, bool fRefresh, MediaList *&pll); 65 HRESULT i_findHostDriveById(DeviceType_T mediumType, const Guid &uuid, bool fRefresh, ComObjPtr<Medium> &pMedium); 66 HRESULT i_findHostDriveByName(DeviceType_T mediumType, const Utf8Str &strLocationFull, bool fRefresh, ComObjPtr<Medium> &pMedium); 117 67 118 68 #ifdef VBOX_WITH_USB … … 120 70 121 71 /** Must be called from under this object's lock. */ 122 USBProxyService* usbProxyService();72 USBProxyService* i_usbProxyService(); 123 73 124 HRESULT addChild(HostUSBDeviceFilter *pChild);125 HRESULT removeChild(HostUSBDeviceFilter *pChild);126 VirtualBox* parent();74 HRESULT i_addChild(HostUSBDeviceFilter *pChild); 75 HRESULT i_removeChild(HostUSBDeviceFilter *pChild); 76 VirtualBox* i_parent(); 127 77 128 HRESULT onUSBDeviceFilterChange(HostUSBDeviceFilter *aFilter, BOOL aActiveChanged = FALSE);129 void getUSBFilters(USBDeviceFilterList *aGlobalFiltes);130 HRESULT checkUSBProxyService();78 HRESULT i_onUSBDeviceFilterChange(HostUSBDeviceFilter *aFilter, BOOL aActiveChanged = FALSE); 79 void i_getUSBFilters(USBDeviceFilterList *aGlobalFiltes); 80 HRESULT i_checkUSBProxyService(); 131 81 #endif /* !VBOX_WITH_USB */ 132 82 133 static void generateMACAddress(Utf8Str &mac);83 static void i_generateMACAddress(Utf8Str &mac); 134 84 135 85 private: 136 86 137 HRESULT buildDVDDrivesList(MediaList &list); 138 HRESULT buildFloppyDrivesList(MediaList &list); 139 HRESULT findHostDriveByNameOrId(DeviceType_T mediumType, const Utf8Str &strNameOrId, ComObjPtr<Medium> &pMedium); 87 // wrapped IHost properties 88 HRESULT getDVDDrives(std::vector<ComPtr<IMedium> > &aDVDDrives); 89 HRESULT getFloppyDrives(std::vector<ComPtr<IMedium> > &aFloppyDrives); 90 HRESULT getUSBDevices(std::vector<ComPtr<IHostUSBDevice> > &aUSBDevices); 91 HRESULT getUSBDeviceFilters(std::vector<ComPtr<IHostUSBDeviceFilter> > &aUSBDeviceFilters); 92 HRESULT getNetworkInterfaces(std::vector<ComPtr<IHostNetworkInterface> > &aNetworkInterfaces); 93 HRESULT getNameServers(std::vector<com::Utf8Str> &aNameServers); 94 HRESULT getDomainName(com::Utf8Str &aDomainName); 95 HRESULT getSearchStrings(std::vector<com::Utf8Str> &aSearchStrings); 96 HRESULT getProcessorCount(ULONG *aProcessorCount); 97 HRESULT getProcessorOnlineCount(ULONG *aProcessorOnlineCount); 98 HRESULT getProcessorCoreCount(ULONG *aProcessorCoreCount); 99 HRESULT getProcessorOnlineCoreCount(ULONG *aProcessorOnlineCoreCount); 100 HRESULT getMemorySize(ULONG *aMemorySize); 101 HRESULT getMemoryAvailable(ULONG *aMemoryAvailable); 102 HRESULT getOperatingSystem(com::Utf8Str &aOperatingSystem); 103 HRESULT getOSVersion(com::Utf8Str &aOSVersion); 104 HRESULT getUTCTime(LONG64 *aUTCTime); 105 HRESULT getAcceleration3DAvailable(BOOL *aAcceleration3DAvailable); 106 HRESULT getVideoInputDevices(std::vector<ComPtr<IHostVideoInputDevice> > &aVideoInputDevices); 107 108 // wrapped IHost methods 109 HRESULT getProcessorSpeed(ULONG aCpuId, 110 ULONG *aSpeed); 111 HRESULT getProcessorFeature(ProcessorFeature_T aFeature, 112 BOOL *aSupported); 113 HRESULT getProcessorDescription(ULONG aCpuId, 114 com::Utf8Str &aDescription); 115 HRESULT getProcessorCPUIDLeaf(ULONG aCpuId, 116 ULONG aLeaf, 117 ULONG aSubLeaf, 118 ULONG *aValEax, 119 ULONG *aValEbx, 120 ULONG *aValEcx, 121 ULONG *aValEdx); 122 HRESULT createHostOnlyNetworkInterface(ComPtr<IHostNetworkInterface> &aHostInterface, 123 ComPtr<IProgress> &aProgress); 124 HRESULT removeHostOnlyNetworkInterface(const com::Guid &aId, 125 ComPtr<IProgress> &aProgress); 126 HRESULT createUSBDeviceFilter(const com::Utf8Str &aName, 127 ComPtr<IHostUSBDeviceFilter> &aFilter); 128 HRESULT insertUSBDeviceFilter(ULONG aPosition, 129 const ComPtr<IHostUSBDeviceFilter> &aFilter); 130 HRESULT removeUSBDeviceFilter(ULONG aPosition); 131 HRESULT findHostDVDDrive(const com::Utf8Str &aName, 132 ComPtr<IMedium> &aDrive); 133 HRESULT findHostFloppyDrive(const com::Utf8Str &aName, 134 ComPtr<IMedium> &aDrive); 135 HRESULT findHostNetworkInterfaceByName(const com::Utf8Str &aName, 136 ComPtr<IHostNetworkInterface> &aNetworkInterface); 137 HRESULT findHostNetworkInterfaceById(const com::Guid &aId, 138 ComPtr<IHostNetworkInterface> &aNetworkInterface); 139 HRESULT findHostNetworkInterfacesOfType(HostNetworkInterfaceType_T aType, 140 std::vector<ComPtr<IHostNetworkInterface> > &aNetworkInterfaces); 141 HRESULT findUSBDeviceById(const com::Guid &aId, 142 ComPtr<IHostUSBDevice> &aDevice); 143 HRESULT findUSBDeviceByAddress(const com::Utf8Str &aName, 144 ComPtr<IHostUSBDevice> &aDevice); 145 HRESULT generateMACAddress(com::Utf8Str &aAddress); 146 147 // Internal Methods. 148 149 HRESULT i_buildDVDDrivesList(MediaList &list); 150 HRESULT i_buildFloppyDrivesList(MediaList &list); 151 HRESULT i_findHostDriveByNameOrId(DeviceType_T mediumType, const Utf8Str &strNameOrId, ComObjPtr<Medium> &pMedium); 140 152 141 153 #if defined(RT_OS_SOLARIS) && defined(VBOX_USE_LIBHAL) 142 bool getDVDInfoFromHal(std::list< ComObjPtr<Medium> > &list);143 bool getFloppyInfoFromHal(std::list< ComObjPtr<Medium> > &list);154 bool i_getDVDInfoFromHal(std::list< ComObjPtr<Medium> > &list); 155 bool i_getFloppyInfoFromHal(std::list< ComObjPtr<Medium> > &list); 144 156 #endif 145 157 146 158 #if defined(RT_OS_SOLARIS) 147 void getDVDInfoFromDevTree(std::list< ComObjPtr<Medium> > &list);148 void parseMountTable(char *mountTable, std::list< ComObjPtr<Medium> > &list);149 bool validateDevice(const char *deviceNode, bool isCDROM);159 void i_getDVDInfoFromDevTree(std::list< ComObjPtr<Medium> > &list); 160 void i_parseMountTable(char *mountTable, std::list< ComObjPtr<Medium> > &list); 161 bool i_validateDevice(const char *deviceNode, bool isCDROM); 150 162 #endif 151 163 152 HRESULT updateNetIfList();164 HRESULT i_updateNetIfList(); 153 165 154 166 #ifndef RT_OS_WINDOWS 155 HRESULT parseResolvConf();167 HRESULT i_parseResolvConf(); 156 168 #else 157 HRESULT fetchNameResolvingInformation();169 HRESULT i_fetchNameResolvingInformation(); 158 170 #endif 159 171 160 172 #ifdef VBOX_WITH_RESOURCE_USAGE_API 161 void registerMetrics(PerformanceCollector *aCollector);162 void registerDiskMetrics(PerformanceCollector *aCollector);163 void unregisterMetrics(PerformanceCollector *aCollector);173 void i_registerMetrics(PerformanceCollector *aCollector); 174 void i_registerDiskMetrics(PerformanceCollector *aCollector); 175 void i_unregisterMetrics(PerformanceCollector *aCollector); 164 176 #endif /* VBOX_WITH_RESOURCE_USAGE_API */ 165 177 -
trunk/src/VBox/Main/include/NATNetworkImpl.h
r49494 r49742 5 5 6 6 /* 7 * Copyright (C) 2006-201 1Oracle Corporation7 * Copyright (C) 2006-2013 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 18 18 #ifndef ____H_H_NATNETWORKIMPL 19 19 #define ____H_H_NATNETWORKIMPL 20 21 #include " VirtualBoxBase.h"20 #include "VBoxEvents.h" 21 #include "NATNetworkWrap.h" 22 22 23 23 #ifdef VBOX_WITH_HOSTNETIF_API … … 53 53 54 54 class ATL_NO_VTABLE NATNetwork : 55 public VirtualBoxBase, 56 VBOX_SCRIPTABLE_IMPL(INATNetwork) 55 public NATNetworkWrap 57 56 { 58 57 public: 59 58 60 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(NATNetwork, INATNetwork) 61 62 DECLARE_NOT_AGGREGATABLE (NATNetwork) 63 64 DECLARE_PROTECT_FINAL_CONSTRUCT() 65 66 BEGIN_COM_MAP (NATNetwork) 67 VBOX_DEFAULT_INTERFACE_ENTRIES(INATNetwork) 68 END_COM_MAP() 69 70 DECLARE_EMPTY_CTOR_DTOR (NATNetwork) 59 DECLARE_EMPTY_CTOR_DTOR(NATNetwork) 71 60 72 61 HRESULT FinalConstruct(); … … 74 63 75 64 HRESULT init(VirtualBox *aVirtualBox, 76 IN_BSTRaName);65 com::Utf8Str aName); 77 66 78 67 79 68 HRESULT init(VirtualBox *aVirtualBox, 80 69 const settings::NATNetwork &data); 81 HRESULT saveSettings(settings::NATNetwork &data);82 70 void uninit(); 83 // INATNetwork::EventSource 84 STDMETHOD(COMGETTER(EventSource))(IEventSource **IEventSource); 85 // INATNetwork properties 86 STDMETHOD(COMGETTER(Enabled))(BOOL *aEnabled); 87 STDMETHOD(COMSETTER(Enabled))(BOOL aEnabled); 88 89 STDMETHOD(COMGETTER(NetworkName))(BSTR *aName); 90 STDMETHOD(COMSETTER(NetworkName))(IN_BSTR aName); 91 92 STDMETHOD(COMGETTER(Gateway))(BSTR *aIPGateway); 93 94 STDMETHOD(COMGETTER(Network))(BSTR *aIPNetwork); 95 STDMETHOD(COMSETTER(Network))(IN_BSTR aIPNetwork); 96 97 STDMETHOD(COMGETTER(IPv6Enabled))(BOOL *aEnabled); 98 STDMETHOD(COMSETTER(IPv6Enabled))(BOOL aEnabled); 99 100 STDMETHOD(COMGETTER(IPv6Prefix))(BSTR *aName); 101 STDMETHOD(COMSETTER(IPv6Prefix))(IN_BSTR aName); 102 103 STDMETHOD(COMGETTER(AdvertiseDefaultIPv6RouteEnabled))(BOOL *aEnabled); 104 STDMETHOD(COMSETTER(AdvertiseDefaultIPv6RouteEnabled))(BOOL aEnabled); 105 106 STDMETHOD(COMGETTER(NeedDhcpServer))(BOOL *aEnabled); 107 STDMETHOD(COMSETTER(NeedDhcpServer))(BOOL aEnabled); 108 109 STDMETHOD(COMGETTER(LocalMappings))(ComSafeArrayOut(BSTR, aLocalMappings)); 110 STDMETHOD(AddLocalMapping)(IN_BSTR aHostId, LONG aOffset); 111 112 STDMETHOD(COMGETTER(LoopbackIp6))(LONG *aLoopbackIp6); 113 STDMETHOD(COMSETTER(LoopbackIp6))(LONG aLoopbackIp6); 114 115 STDMETHOD(COMGETTER(PortForwardRules4))(ComSafeArrayOut(BSTR, aPortForwardRules4)); 116 STDMETHOD(COMGETTER(PortForwardRules6))(ComSafeArrayOut(BSTR, aPortForwardRules6)); 117 118 STDMETHOD(AddPortForwardRule)(BOOL aIsIpv6, 119 IN_BSTR aPortForwardRuleName, 120 NATProtocol_T aProto, 121 IN_BSTR aHostIp, 122 USHORT aHostPort, 123 IN_BSTR aGuestIp, 124 USHORT aGuestPort); 125 STDMETHOD(RemovePortForwardRule)(BOOL aIsIpv6, IN_BSTR aPortForwardRuleName); 126 127 STDMETHOD(Start)(IN_BSTR aTrunkType); 128 STDMETHOD(Stop)(); 71 HRESULT i_saveSettings(settings::NATNetwork &data); 129 72 130 73 private: 131 int recalculateIpv4AddressAssignments(); 132 int findFirstAvailableOffset(ADDRESSLOOKUPTYPE, uint32_t *); 74 75 // Wrapped INATNetwork properties 76 HRESULT getNetworkName(com::Utf8Str &aNetworkName); 77 HRESULT setNetworkName(const com::Utf8Str &aNetworkName); 78 HRESULT getEnabled(BOOL *aEnabled); 79 HRESULT setEnabled(BOOL aEnabled); 80 HRESULT getNetwork(com::Utf8Str &aNetwork); 81 HRESULT setNetwork(const com::Utf8Str &aNetwork); 82 HRESULT getGateway(com::Utf8Str &aGateway); 83 HRESULT getIPv6Enabled(BOOL *aIPv6Enabled); 84 HRESULT setIPv6Enabled(BOOL aIPv6Enabled); 85 HRESULT getIPv6Prefix(com::Utf8Str &aIPv6Prefix); 86 HRESULT setIPv6Prefix(const com::Utf8Str &aIPv6Prefix); 87 HRESULT getAdvertiseDefaultIPv6RouteEnabled(BOOL *aAdvertiseDefaultIPv6RouteEnabled); 88 HRESULT setAdvertiseDefaultIPv6RouteEnabled(BOOL aAdvertiseDefaultIPv6RouteEnabled); 89 HRESULT getNeedDhcpServer(BOOL *aNeedDhcpServer); 90 HRESULT setNeedDhcpServer(BOOL aNeedDhcpServer); 91 HRESULT getEventSource(ComPtr<IEventSource> &aEventSource); 92 HRESULT getPortForwardRules4(std::vector<com::Utf8Str> &aPortForwardRules4); 93 HRESULT getLocalMappings(std::vector<com::Utf8Str> &aLocalMappings); 94 HRESULT getLoopbackIp6(LONG *aLoopbackIp6); 95 HRESULT setLoopbackIp6(LONG aLoopbackIp6); 96 HRESULT getPortForwardRules6(std::vector<com::Utf8Str> &aPortForwardRules6); 97 98 // wrapped INATNetwork methods 99 HRESULT addLocalMapping(const com::Utf8Str &aHostid, 100 LONG aOffset); 101 HRESULT addPortForwardRule(BOOL aIsIpv6, 102 const com::Utf8Str &aRuleName, 103 NATProtocol_T aProto, 104 const com::Utf8Str &aHostIP, 105 USHORT aHostPort, 106 const com::Utf8Str &aGuestIP, 107 USHORT aGuestPort); 108 HRESULT removePortForwardRule(BOOL aISipv6, 109 const com::Utf8Str &aRuleName); 110 HRESULT start(const com::Utf8Str &aTrunkType); 111 HRESULT stop(); 112 113 // Internal methods 114 int i_recalculateIpv4AddressAssignments(); 115 int i_findFirstAvailableOffset(ADDRESSLOOKUPTYPE, uint32_t *); 133 116 134 117 typedef std::map<Utf8Str, settings::NATRule> NATRuleMap; 135 118 typedef NATRuleMap::const_iterator constNATRuleMapIterator; 136 119 137 void GetPortForwardRulesFromMap(ComSafeArrayOut(BSTR, aPortForwardRules), NATRuleMap& aRules); 120 void i_getPortForwardRulesFromMap(std::vector<Utf8Str> &aPortForwardRules, NATRuleMap& aRules); 121 138 122 /** weak VirtualBox parent */ 139 123 VirtualBox * const mVirtualBox; 140 124 141 const Bstr mName; 125 const com::Utf8Str mName; 126 142 127 struct Data; 143 128 struct Data *m; -
trunk/src/VBox/Main/src-server/ApplianceImpl.cpp
r49620 r49742 36 36 37 37 using namespace std; 38 39 //////////////////////////////////////////////////////////////////////////////// 40 // 41 // Appliance constructor / destructor 42 // 43 // //////////////////////////////////////////////////////////////////////////////// 44 45 DEFINE_EMPTY_CTOR_DTOR(VirtualSystemDescription) 46 47 HRESULT VirtualSystemDescription::FinalConstruct() 48 { 49 return BaseFinalConstruct(); 50 } 51 52 void VirtualSystemDescription::FinalRelease() 53 { 54 uninit(); 55 56 BaseFinalRelease(); 57 } 58 59 Appliance::Appliance() 60 : mVirtualBox(NULL) 61 { 62 } 63 64 Appliance::~Appliance() 65 { 66 } 67 68 69 HRESULT Appliance::FinalConstruct() 70 { 71 return BaseFinalConstruct(); 72 } 73 74 void Appliance::FinalRelease() 75 { 76 uninit(); 77 78 BaseFinalRelease(); 79 } 80 38 81 39 82 //////////////////////////////////////////////////////////////////////////////// … … 344 387 } 345 388 346 ////////////////////////////////////////////////////////////////////////////////347 //348 // Appliance constructor / destructor349 //350 ////////////////////////////////////////////////////////////////////////////////351 352 Appliance::Appliance()353 : mVirtualBox(NULL)354 {355 }356 357 Appliance::~Appliance()358 {359 }360 361 389 /** 362 390 * Appliance COM initializer. … … 377 405 m = new Data; 378 406 379 i nitApplianceIONameMap();380 381 rc = i nitSetOfSupportedStandardsURI();407 i_initApplianceIONameMap(); 408 409 rc = i_initSetOfSupportedStandardsURI(); 382 410 383 411 /* Confirm a successful initialization */ … … 413 441 * @return 414 442 */ 415 STDMETHODIMP Appliance::COMGETTER(Path)(BSTR *aPath) 416 { 417 if (!aPath) 418 return E_POINTER; 419 420 AutoCaller autoCaller(this); 421 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 422 443 HRESULT Appliance::getPath(com::Utf8Str &aPath) 444 { 423 445 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 424 446 425 if (!i sApplianceIdle())447 if (!i_isApplianceIdle()) 426 448 return E_ACCESSDENIED; 427 449 428 Bstr bstrPath(m->locInfo.strPath); 429 bstrPath.cloneTo(aPath); 450 aPath = m->locInfo.strPath; 430 451 431 452 return S_OK; … … 437 458 * @return 438 459 */ 439 STDMETHODIMP Appliance::COMGETTER(Disks)(ComSafeArrayOut(BSTR, aDisks)) 440 { 441 CheckComArgOutSafeArrayPointerValid(aDisks); 442 443 AutoCaller autoCaller(this); 444 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 445 460 HRESULT Appliance::getDisks(std::vector<com::Utf8Str> &aDisks) 461 { 446 462 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 447 463 448 if (!isApplianceIdle()) 464 aDisks.resize(0); 465 if (!i_isApplianceIdle()) 449 466 return E_ACCESSDENIED; 450 467 451 468 if (m->pReader) // OVFReader instantiated? 452 469 { 453 size_t c = m->pReader->m_mapDisks.size(); 454 com::SafeArray<BSTR> sfaDisks(c); 470 aDisks.resize(m->pReader->m_mapDisks.size()); 455 471 456 472 ovf::DiskImagesMap::const_iterator it; … … 481 497 d.strCompression.c_str()); 482 498 Utf8Str utf(psz); 483 Bstr bstr(utf); 484 // push to safearray 485 bstr.cloneTo(&sfaDisks[i]); 499 aDisks[i] = utf; 486 500 RTStrFree(psz); 487 501 } 488 489 sfaDisks.detachTo(ComSafeArrayOutArg(aDisks));490 502 } 491 503 … … 498 510 * @return 499 511 */ 500 STDMETHODIMP Appliance::COMGETTER(VirtualSystemDescriptions)(ComSafeArrayOut(IVirtualSystemDescription*, aVirtualSystemDescriptions)) 501 { 502 CheckComArgOutSafeArrayPointerValid(aVirtualSystemDescriptions); 503 504 AutoCaller autoCaller(this); 505 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 506 512 HRESULT Appliance::getVirtualSystemDescriptions(std::vector<ComPtr<IVirtualSystemDescription> > &aVirtualSystemDescriptions) 513 { 507 514 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 508 515 509 if (!i sApplianceIdle())516 if (!i_isApplianceIdle()) 510 517 return E_ACCESSDENIED; 511 518 512 SafeIfaceArray<IVirtualSystemDescription> sfaVSD(m->virtualSystemDescriptions); 513 sfaVSD.detachTo(ComSafeArrayOutArg(aVirtualSystemDescriptions)); 514 519 aVirtualSystemDescriptions.resize(m->virtualSystemDescriptions.size()); 520 std::list< ComObjPtr<VirtualSystemDescription> > vsds(m->virtualSystemDescriptions); 521 size_t i = 0; 522 for (std::list< ComObjPtr<VirtualSystemDescription> >::iterator it = vsds.begin(); it != vsds.end(); ++it, ++i) 523 { 524 (*it).queryInterfaceTo(aVirtualSystemDescriptions[i].asOutParam()); 525 } 515 526 return S_OK; 516 527 } … … 521 532 * @return 522 533 */ 523 STDMETHODIMP Appliance::COMGETTER(Machines)(ComSafeArrayOut(BSTR, aMachines)) 524 { 525 CheckComArgOutSafeArrayPointerValid(aMachines); 526 527 AutoCaller autoCaller(this); 528 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 529 534 HRESULT Appliance::getMachines(std::vector<com::Utf8Str> &aMachines) 535 { 530 536 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 531 537 532 if (!i sApplianceIdle())538 if (!i_isApplianceIdle()) 533 539 return E_ACCESSDENIED; 534 540 535 com::SafeArray<BSTR> sfaMachines(m->llGuidsMachinesCreated.size());536 size_t u= 0;541 aMachines.resize(m->llGuidsMachinesCreated.size()); 542 size_t i = 0; 537 543 for (std::list<Guid>::const_iterator it = m->llGuidsMachinesCreated.begin(); 538 544 it != m->llGuidsMachinesCreated.end(); 539 ++it )545 ++it, ++i) 540 546 { 541 547 const Guid &uuid = *it; 542 Bstr bstr(uuid.toUtf16()); 543 bstr.detachTo(&sfaMachines[u]); 544 ++u; 545 } 546 547 sfaMachines.detachTo(ComSafeArrayOutArg(aMachines)); 548 548 aMachines[i] = uuid.toUtf16(); 549 } 549 550 return S_OK; 550 551 } 551 552 552 STDMETHODIMP Appliance::CreateVFSExplorer(IN_BSTR aURI, IVFSExplorer **aExplorer) 553 { 554 CheckComArgOutPointerValid(aExplorer); 555 556 AutoCaller autoCaller(this); 557 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 558 553 HRESULT Appliance::createVFSExplorer(const com::Utf8Str &aURI, ComPtr<IVFSExplorer> &aExplorer) 554 { 559 555 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 560 556 … … 566 562 /* Check which kind of export the user has requested */ 567 563 LocationInfo li; 568 parseURI(uri, li);564 i_parseURI(aURI, li); 569 565 /* Create the explorer object */ 570 566 explorer.createObject(); … … 578 574 if (SUCCEEDED(rc)) 579 575 /* Return explorer to the caller */ 580 explorer.queryInterfaceTo(aExplorer );576 explorer.queryInterfaceTo(aExplorer.asOutParam()); 581 577 582 578 return rc; … … 587 583 * @return 588 584 */ 589 STDMETHODIMP Appliance::GetWarnings(ComSafeArrayOut(BSTR, aWarnings)) 590 { 591 if (ComSafeArrayOutIsNull(aWarnings)) 592 return E_POINTER; 593 594 AutoCaller autoCaller(this); 595 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 596 585 HRESULT Appliance::getWarnings(std::vector<com::Utf8Str> &aWarnings) 586 { 597 587 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 598 588 599 com::SafeArray<BSTR> sfaWarnings(m->llWarnings.size());589 aWarnings.resize(m->llWarnings.size()); 600 590 601 591 list<Utf8Str>::const_iterator it; … … 605 595 ++it, ++i) 606 596 { 607 Bstr bstr = *it; 608 bstr.cloneTo(&sfaWarnings[i]); 609 } 610 611 sfaWarnings.detachTo(ComSafeArrayOutArg(aWarnings)); 597 aWarnings[i] = *it; 598 } 612 599 613 600 return S_OK; … … 619 606 // 620 607 //////////////////////////////////////////////////////////////////////////////// 621 622 HRESULT Appliance::i nitSetOfSupportedStandardsURI()608 // 609 HRESULT Appliance::i_initSetOfSupportedStandardsURI() 623 610 { 624 611 HRESULT rc = S_OK; … … 676 663 } 677 664 678 Utf8Str Appliance:: typeOfVirtualDiskFormatFromURI(Utf8Str uri) const665 Utf8Str Appliance::i_typeOfVirtualDiskFormatFromURI(Utf8Str uri) const 679 666 { 680 667 Utf8Str type; … … 688 675 } 689 676 690 std::set<Utf8Str> Appliance:: URIFromTypeOfVirtualDiskFormat(Utf8Str type)677 std::set<Utf8Str> Appliance::i_URIFromTypeOfVirtualDiskFormat(Utf8Str type) 691 678 { 692 679 std::set<Utf8Str> uri; … … 702 689 } 703 690 704 HRESULT Appliance::i nitApplianceIONameMap()691 HRESULT Appliance::i_initApplianceIONameMap() 705 692 { 706 693 HRESULT rc = S_OK; … … 715 702 } 716 703 717 Utf8Str Appliance:: applianceIOName(APPLIANCEIONAME type) const704 Utf8Str Appliance::i_applianceIOName(APPLIANCEIONAME type) const 718 705 { 719 706 Utf8Str name; … … 729 716 730 717 /** 731 * Returns a medium format object corresponding to the given 732 * disk image or null if no such format. 718 * Returns a medium format object corresponding to the given 719 * disk image or null if no such format. 733 720 * 734 721 * @param di Disk Image … … 737 724 * @return ComObjPtr<MediumFormat> 738 725 */ 739 HRESULT Appliance::findMediumFormatFromDiskImage(const ovf::DiskImage &di, ComObjPtr<MediumFormat>& mf) 726 727 HRESULT Appliance::i_findMediumFormatFromDiskImage(const ovf::DiskImage &di, ComObjPtr<MediumFormat>& mf) 740 728 { 741 729 HRESULT rc = S_OK; … … 746 734 /* We need a proper source format description */ 747 735 /* Which format to use? */ 748 Utf8Str strSrcFormat = typeOfVirtualDiskFormatFromURI(di.strFormat);736 Utf8Str strSrcFormat = i_typeOfVirtualDiskFormatFromURI(di.strFormat); 749 737 750 738 /* … … 789 777 * @return 790 778 */ 791 bool Appliance::i sApplianceIdle()779 bool Appliance::i_isApplianceIdle() 792 780 { 793 781 if (m->state == Data::ApplianceImporting) … … 801 789 } 802 790 803 HRESULT Appliance:: searchUniqueVMName(Utf8Str& aName) const791 HRESULT Appliance::i_searchUniqueVMName(Utf8Str& aName) const 804 792 { 805 793 IMachine *machine = NULL; … … 819 807 } 820 808 821 HRESULT Appliance:: searchUniqueDiskImageFilePath(Utf8Str& aName) const809 HRESULT Appliance::i_searchUniqueDiskImageFilePath(Utf8Str& aName) const 822 810 { 823 811 IMedium *harddisk = NULL; … … 857 845 * @return 858 846 */ 859 HRESULT Appliance:: setUpProgress(ComObjPtr<Progress> &pProgress,860 const Bstr &bstrDescription,861 SetUpProgressMode mode)847 HRESULT Appliance::i_setUpProgress(ComObjPtr<Progress> &pProgress, 848 const Bstr &bstrDescription, 849 SetUpProgressMode mode) 862 850 { 863 851 HRESULT rc; … … 867 855 868 856 // compute the disks weight (this sets ulTotalDisksMB and cDisks in the instance data) 869 disksWeight();857 i_disksWeight(); 870 858 871 859 m->ulWeightForManifestOperation = 0; … … 965 953 * @param pProgressAsync Progress object of asynchronous task running in background. 966 954 */ 967 void Appliance:: waitForAsyncProgress(ComObjPtr<Progress> &pProgressThis,968 ComPtr<IProgress> &pProgressAsync)955 void Appliance::i_waitForAsyncProgress(ComObjPtr<Progress> &pProgressThis, 956 ComPtr<IProgress> &pProgressAsync) 969 957 { 970 958 HRESULT rc; … … 1033 1021 } 1034 1022 1035 void Appliance:: addWarning(const char* aWarning, ...)1023 void Appliance::i_addWarning(const char* aWarning, ...) 1036 1024 { 1037 1025 va_list args; … … 1046 1034 * Requires that virtual system descriptions are present. 1047 1035 */ 1048 void Appliance:: disksWeight()1036 void Appliance::i_disksWeight() 1049 1037 { 1050 1038 m->ulTotalDisksMB = 0; … … 1058 1046 ComObjPtr<VirtualSystemDescription> vsdescThis = (*it); 1059 1047 /* One for every hard disk of the Virtual System */ 1060 std::list<VirtualSystemDescriptionEntry*> avsdeHDs = vsdescThis-> findByType(VirtualSystemDescriptionType_HardDiskImage);1048 std::list<VirtualSystemDescriptionEntry*> avsdeHDs = vsdescThis->i_findByType(VirtualSystemDescriptionType_HardDiskImage); 1061 1049 std::list<VirtualSystemDescriptionEntry*>::const_iterator itH; 1062 1050 for (itH = avsdeHDs.begin(); … … 1069 1057 } 1070 1058 1071 avsdeHDs = vsdescThis-> findByType(VirtualSystemDescriptionType_CDROM);1059 avsdeHDs = vsdescThis->i_findByType(VirtualSystemDescriptionType_CDROM); 1072 1060 for (itH = avsdeHDs.begin(); 1073 1061 itH != avsdeHDs.end(); … … 1082 1070 } 1083 1071 1084 void Appliance:: parseBucket(Utf8Str &aPath, Utf8Str &aBucket)1072 void Appliance::i_parseBucket(Utf8Str &aPath, Utf8Str &aBucket) 1085 1073 { 1086 1074 /* Buckets are S3 specific. So parse the bucket out of the file path */ … … 1106 1094 int Appliance::TaskOVF::startThread() 1107 1095 { 1108 int vrc = RTThreadCreate(NULL, Appliance:: taskThreadImportOrExport, this,1096 int vrc = RTThreadCreate(NULL, Appliance::i_taskThreadImportOrExport, this, 1109 1097 0, RTTHREADTYPE_MAIN_HEAVY_WORKER, 0, 1110 1098 "Appliance::Task"); 1111 1099 1112 1100 if (RT_FAILURE(vrc)) 1113 return Appliance:: setErrorStatic(E_FAIL,1101 return Appliance::i_setErrorStatic(E_FAIL, 1114 1102 Utf8StrFmt("Could not create OVF task thread (%Rrc)\n", vrc)); 1115 1103 … … 1127 1115 */ 1128 1116 /* static */ 1129 DECLCALLBACK(int) Appliance:: taskThreadImportOrExport(RTTHREAD /* aThread */, void *pvUser)1117 DECLCALLBACK(int) Appliance::i_taskThreadImportOrExport(RTTHREAD /* aThread */, void *pvUser) 1130 1118 { 1131 1119 std::auto_ptr<TaskOVF> task(static_cast<TaskOVF*>(pvUser)); … … 1143 1131 case TaskOVF::Read: 1144 1132 if (task->locInfo.storageType == VFSType_File) 1145 taskrc = pAppliance-> readFS(task.get());1133 taskrc = pAppliance->i_readFS(task.get()); 1146 1134 else if (task->locInfo.storageType == VFSType_S3) 1147 1135 #ifdef VBOX_WITH_S3 1148 taskrc = pAppliance-> readS3(task.get());1136 taskrc = pAppliance->i_readS3(task.get()); 1149 1137 #else 1150 1138 taskrc = VERR_NOT_IMPLEMENTED; … … 1154 1142 case TaskOVF::Import: 1155 1143 if (task->locInfo.storageType == VFSType_File) 1156 taskrc = pAppliance->i mportFS(task.get());1144 taskrc = pAppliance->i_importFS(task.get()); 1157 1145 else if (task->locInfo.storageType == VFSType_S3) 1158 1146 #ifdef VBOX_WITH_S3 1159 taskrc = pAppliance->i mportS3(task.get());1147 taskrc = pAppliance->i_importS3(task.get()); 1160 1148 #else 1161 1149 taskrc = VERR_NOT_IMPLEMENTED; … … 1165 1153 case TaskOVF::Write: 1166 1154 if (task->locInfo.storageType == VFSType_File) 1167 taskrc = pAppliance-> writeFS(task.get());1155 taskrc = pAppliance->i_writeFS(task.get()); 1168 1156 else if (task->locInfo.storageType == VFSType_S3) 1169 1157 #ifdef VBOX_WITH_S3 1170 taskrc = pAppliance-> writeS3(task.get());1158 taskrc = pAppliance->i_writeS3(task.get()); 1171 1159 #else 1172 1160 taskrc = VERR_NOT_IMPLEMENTED; … … 1202 1190 } 1203 1191 1204 void parseURI(Utf8Str strUri, LocationInfo &locInfo)1192 void i_parseURI(Utf8Str strUri, LocationInfo &locInfo) 1205 1193 { 1206 1194 /* Check the URI for the protocol */ … … 1255 1243 //////////////////////////////////////////////////////////////////////////////// 1256 1244 1257 DEFINE_EMPTY_CTOR_DTOR(VirtualSystemDescription)1258 1245 1259 1246 /** … … 1299 1286 * @return 1300 1287 */ 1301 STDMETHODIMP VirtualSystemDescription::COMGETTER(Count)(ULONG *aCount)1288 HRESULT VirtualSystemDescription::getCount(ULONG *aCount) 1302 1289 { 1303 1290 if (!aCount) 1304 1291 return E_POINTER; 1305 1292 1306 AutoCaller autoCaller(this);1307 if (FAILED(autoCaller.rc())) return autoCaller.rc();1308 1309 1293 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 1310 1294 1311 *aCount = (ULONG)m->llDescriptions.size(); 1312 1295 *aCount = (ULONG)m->maDescriptions.size(); 1313 1296 return S_OK; 1314 1297 } … … 1318 1301 * @return 1319 1302 */ 1320 STDMETHODIMP VirtualSystemDescription::GetDescription(ComSafeArrayOut(VirtualSystemDescriptionType_T, aTypes), 1321 ComSafeArrayOut(BSTR, aRefs), 1322 ComSafeArrayOut(BSTR, aOrigValues), 1323 ComSafeArrayOut(BSTR, aVboxValues), 1324 ComSafeArrayOut(BSTR, aExtraConfigValues)) 1325 { 1326 if (ComSafeArrayOutIsNull(aTypes) || 1327 ComSafeArrayOutIsNull(aRefs) || 1328 ComSafeArrayOutIsNull(aOrigValues) || 1329 ComSafeArrayOutIsNull(aVboxValues) || 1330 ComSafeArrayOutIsNull(aExtraConfigValues)) 1331 return E_POINTER; 1332 1333 AutoCaller autoCaller(this); 1334 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1335 1303 HRESULT VirtualSystemDescription::getDescription(std::vector<VirtualSystemDescriptionType_T> &aTypes, 1304 std::vector<com::Utf8Str> &aRefs, 1305 std::vector<com::Utf8Str> &aOVFValues, 1306 std::vector<com::Utf8Str> &aVBoxValues, 1307 std::vector<com::Utf8Str> &aExtraConfigValues) 1308 1309 { 1336 1310 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 1337 1338 ULONG c = (ULONG)m->llDescriptions.size(); 1339 com::SafeArray<VirtualSystemDescriptionType_T> sfaTypes(c); 1340 com::SafeArray<BSTR> sfaRefs(c); 1341 com::SafeArray<BSTR> sfaOrigValues(c); 1342 com::SafeArray<BSTR> sfaVboxValues(c); 1343 com::SafeArray<BSTR> sfaExtraConfigValues(c); 1344 1345 list<VirtualSystemDescriptionEntry>::const_iterator it; 1311 size_t c = m->maDescriptions.size(); 1312 aTypes.resize(c); 1313 aRefs.resize(c); 1314 aOVFValues.resize(c); 1315 aVBoxValues.resize(c); 1316 aExtraConfigValues.resize(c); 1317 1318 for (size_t i = 0; i < c; i++) 1319 { 1320 const VirtualSystemDescriptionEntry &vsde = m->maDescriptions[i]; 1321 aTypes[i] = vsde.type; 1322 aRefs[i] = vsde.strRef; 1323 aOVFValues[i] = vsde.strOvf; 1324 aVBoxValues[i] = vsde.strVboxCurrent; 1325 aExtraConfigValues[i] = vsde.strExtraConfigCurrent; 1326 } 1327 return S_OK; 1328 } 1329 1330 /** 1331 * Public method implementation. 1332 * @return 1333 */ 1334 HRESULT VirtualSystemDescription::getDescriptionByType(VirtualSystemDescriptionType_T aType, 1335 std::vector<VirtualSystemDescriptionType_T> &aTypes, 1336 std::vector<com::Utf8Str> &aRefs, 1337 std::vector<com::Utf8Str> &aOVFValues, 1338 std::vector<com::Utf8Str> &aVBoxValues, 1339 std::vector<com::Utf8Str> &aExtraConfigValues) 1340 { 1341 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 1342 std::list<VirtualSystemDescriptionEntry*> vsd = i_findByType(aType); 1343 1344 size_t c = vsd.size(); 1345 aTypes.resize(c); 1346 aRefs.resize(c); 1347 aOVFValues.resize(c); 1348 aVBoxValues.resize(c); 1349 aExtraConfigValues.resize(c); 1350 1346 1351 size_t i = 0; 1347 for (it = m->llDescriptions.begin(); 1348 it != m->llDescriptions.end(); 1349 ++it, ++i) 1350 { 1351 const VirtualSystemDescriptionEntry &vsde = (*it); 1352 1353 sfaTypes[i] = vsde.type; 1354 1355 Bstr bstr = vsde.strRef; 1356 bstr.cloneTo(&sfaRefs[i]); 1357 1358 bstr = vsde.strOvf; 1359 bstr.cloneTo(&sfaOrigValues[i]); 1360 1361 bstr = vsde.strVboxCurrent; 1362 bstr.cloneTo(&sfaVboxValues[i]); 1363 1364 bstr = vsde.strExtraConfigCurrent; 1365 bstr.cloneTo(&sfaExtraConfigValues[i]); 1366 } 1367 1368 sfaTypes.detachTo(ComSafeArrayOutArg(aTypes)); 1369 sfaRefs.detachTo(ComSafeArrayOutArg(aRefs)); 1370 sfaOrigValues.detachTo(ComSafeArrayOutArg(aOrigValues)); 1371 sfaVboxValues.detachTo(ComSafeArrayOutArg(aVboxValues)); 1372 sfaExtraConfigValues.detachTo(ComSafeArrayOutArg(aExtraConfigValues)); 1352 for (list<VirtualSystemDescriptionEntry*>::const_iterator it = vsd.begin(); it != vsd.end(); ++it, ++i) 1353 { 1354 const VirtualSystemDescriptionEntry *vsde = (*it); 1355 aTypes[i] = vsde->type; 1356 aRefs[i] = vsde->strRef; 1357 aOVFValues[i] = vsde->strOvf; 1358 aVBoxValues[i] = vsde->strVboxCurrent; 1359 aExtraConfigValues[i] = vsde->strExtraConfigCurrent; 1360 } 1373 1361 1374 1362 return S_OK; … … 1379 1367 * @return 1380 1368 */ 1381 STDMETHODIMP VirtualSystemDescription::GetDescriptionByType(VirtualSystemDescriptionType_T aType, 1382 ComSafeArrayOut(VirtualSystemDescriptionType_T, aTypes), 1383 ComSafeArrayOut(BSTR, aRefs), 1384 ComSafeArrayOut(BSTR, aOrigValues), 1385 ComSafeArrayOut(BSTR, aVboxValues), 1386 ComSafeArrayOut(BSTR, aExtraConfigValues)) 1387 { 1388 if (ComSafeArrayOutIsNull(aTypes) || 1389 ComSafeArrayOutIsNull(aRefs) || 1390 ComSafeArrayOutIsNull(aOrigValues) || 1391 ComSafeArrayOutIsNull(aVboxValues) || 1392 ComSafeArrayOutIsNull(aExtraConfigValues)) 1393 return E_POINTER; 1394 1395 AutoCaller autoCaller(this); 1396 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1397 1369 HRESULT VirtualSystemDescription::getValuesByType(VirtualSystemDescriptionType_T aType, 1370 VirtualSystemDescriptionValueType_T aWhich, 1371 std::vector<com::Utf8Str> &aValues) 1372 { 1398 1373 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 1399 1374 1400 std::list<VirtualSystemDescriptionEntry*> vsd = findByType (aType); 1401 ULONG c = (ULONG)vsd.size(); 1402 com::SafeArray<VirtualSystemDescriptionType_T> sfaTypes(c); 1403 com::SafeArray<BSTR> sfaRefs(c); 1404 com::SafeArray<BSTR> sfaOrigValues(c); 1405 com::SafeArray<BSTR> sfaVboxValues(c); 1406 com::SafeArray<BSTR> sfaExtraConfigValues(c); 1375 std::list<VirtualSystemDescriptionEntry*> vsd = i_findByType (aType); 1376 aValues.resize((ULONG)vsd.size()); 1407 1377 1408 1378 list<VirtualSystemDescriptionEntry*>::const_iterator it; … … 1414 1384 const VirtualSystemDescriptionEntry *vsde = (*it); 1415 1385 1416 sfaTypes[i] = vsde->type;1417 1418 Bstr bstr = vsde->strRef;1419 bstr.cloneTo(&sfaRefs[i]);1420 1421 bstr = vsde->strOvf;1422 bstr.cloneTo(&sfaOrigValues[i]);1423 1424 bstr = vsde->strVboxCurrent;1425 bstr.cloneTo(&sfaVboxValues[i]);1426 1427 bstr = vsde->strExtraConfigCurrent;1428 bstr.cloneTo(&sfaExtraConfigValues[i]);1429 }1430 1431 sfaTypes.detachTo(ComSafeArrayOutArg(aTypes));1432 sfaRefs.detachTo(ComSafeArrayOutArg(aRefs));1433 sfaOrigValues.detachTo(ComSafeArrayOutArg(aOrigValues));1434 sfaVboxValues.detachTo(ComSafeArrayOutArg(aVboxValues));1435 sfaExtraConfigValues.detachTo(ComSafeArrayOutArg(aExtraConfigValues));1436 1437 return S_OK;1438 }1439 1440 /**1441 * Public method implementation.1442 * @return1443 */1444 STDMETHODIMP VirtualSystemDescription::GetValuesByType(VirtualSystemDescriptionType_T aType,1445 VirtualSystemDescriptionValueType_T aWhich,1446 ComSafeArrayOut(BSTR, aValues))1447 {1448 if (ComSafeArrayOutIsNull(aValues))1449 return E_POINTER;1450 1451 AutoCaller autoCaller(this);1452 if (FAILED(autoCaller.rc())) return autoCaller.rc();1453 1454 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);1455 1456 std::list<VirtualSystemDescriptionEntry*> vsd = findByType (aType);1457 com::SafeArray<BSTR> sfaValues((ULONG)vsd.size());1458 1459 list<VirtualSystemDescriptionEntry*>::const_iterator it;1460 size_t i = 0;1461 for (it = vsd.begin();1462 it != vsd.end();1463 ++it, ++i)1464 {1465 const VirtualSystemDescriptionEntry *vsde = (*it);1466 1467 1386 Bstr bstr; 1468 1387 switch (aWhich) 1469 1388 { 1470 case VirtualSystemDescriptionValueType_Reference: bstr= vsde->strRef; break;1471 case VirtualSystemDescriptionValueType_Original: bstr= vsde->strOvf; break;1472 case VirtualSystemDescriptionValueType_Auto: bstr= vsde->strVboxCurrent; break;1473 case VirtualSystemDescriptionValueType_ExtraConfig: bstr= vsde->strExtraConfigCurrent; break;1389 case VirtualSystemDescriptionValueType_Reference: aValues[i] = vsde->strRef; break; 1390 case VirtualSystemDescriptionValueType_Original: aValues[i] = vsde->strOvf; break; 1391 case VirtualSystemDescriptionValueType_Auto: aValues[i] = vsde->strVboxCurrent; break; 1392 case VirtualSystemDescriptionValueType_ExtraConfig: aValues[i] = vsde->strExtraConfigCurrent; break; 1474 1393 } 1475 1476 bstr.cloneTo(&sfaValues[i]); 1477 } 1478 1479 sfaValues.detachTo(ComSafeArrayOutArg(aValues)); 1394 } 1480 1395 1481 1396 return S_OK; … … 1486 1401 * @return 1487 1402 */ 1488 STDMETHODIMP VirtualSystemDescription::SetFinalValues(ComSafeArrayIn(BOOL, aEnabled),1489 ComSafeArrayIn(IN_BSTR, argVboxValues),1490 ComSafeArrayIn(IN_BSTR, argExtraConfigValues))1403 HRESULT VirtualSystemDescription::setFinalValues(const std::vector<BOOL> &aEnabled, 1404 const std::vector<com::Utf8Str> &aVBoxValues, 1405 const std::vector<com::Utf8Str> &aExtraConfigValues) 1491 1406 { 1492 1407 #ifndef RT_OS_WINDOWS 1493 NOREF(aEnabledSize);1408 // NOREF(aEnabledSize); 1494 1409 #endif /* RT_OS_WINDOWS */ 1495 1496 CheckComArgSafeArrayNotNull(aEnabled);1497 CheckComArgSafeArrayNotNull(argVboxValues);1498 CheckComArgSafeArrayNotNull(argExtraConfigValues);1499 1500 AutoCaller autoCaller(this);1501 if (FAILED(autoCaller.rc())) return autoCaller.rc();1502 1503 1410 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 1504 1411 1505 com::SafeArray<BOOL> sfaEnabled(ComSafeArrayInArg(aEnabled)); 1506 com::SafeArray<IN_BSTR> sfaVboxValues(ComSafeArrayInArg(argVboxValues)); 1507 com::SafeArray<IN_BSTR> sfaExtraConfigValues(ComSafeArrayInArg(argExtraConfigValues)); 1508 1509 if ( (sfaEnabled.size() != m->llDescriptions.size()) 1510 || (sfaVboxValues.size() != m->llDescriptions.size()) 1511 || (sfaExtraConfigValues.size() != m->llDescriptions.size()) 1412 if ( (aEnabled.size() != m->maDescriptions.size()) 1413 || (aVBoxValues.size() != m->maDescriptions.size()) 1414 || (aExtraConfigValues.size() != m->maDescriptions.size()) 1512 1415 ) 1513 1416 return E_INVALIDARG; 1514 1417 1515 list<VirtualSystemDescriptionEntry>::iterator it;1516 1418 size_t i = 0; 1517 for ( it = m->llDescriptions.begin();1518 it != m-> llDescriptions.end();1419 for (vector<VirtualSystemDescriptionEntry>::iterator it = m->maDescriptions.begin(); 1420 it != m->maDescriptions.end(); 1519 1421 ++it, ++i) 1520 1422 { 1521 1423 VirtualSystemDescriptionEntry& vsde = *it; 1522 1424 1523 if ( sfaEnabled[i])1425 if (aEnabled[i]) 1524 1426 { 1525 vsde.strVboxCurrent = sfaVboxValues[i];1526 vsde.strExtraConfigCurrent = sfaExtraConfigValues[i];1427 vsde.strVboxCurrent = aVBoxValues[i]; 1428 vsde.strExtraConfigCurrent = aExtraConfigValues[i]; 1527 1429 } 1528 1430 else … … 1537 1439 * @return 1538 1440 */ 1539 STDMETHODIMP VirtualSystemDescription::AddDescription(VirtualSystemDescriptionType_T aType, 1540 IN_BSTR aVboxValue, 1541 IN_BSTR aExtraConfigValue) 1542 { 1543 AutoCaller autoCaller(this); 1544 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1545 1441 HRESULT VirtualSystemDescription::addDescription(VirtualSystemDescriptionType_T aType, 1442 const com::Utf8Str &aVBoxValue, 1443 const com::Utf8Str &aExtraConfigValue) 1444 1445 { 1546 1446 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 1547 1548 addEntry(aType, "", aVboxValue, aVboxValue, 0, aExtraConfigValue); 1549 1447 i_addEntry(aType, "", aVBoxValue, aVBoxValue, 0, aExtraConfigValue); 1550 1448 return S_OK; 1551 1449 } … … 1560 1458 * @param strExtraConfig Extra configuration; meaning dependent on type. 1561 1459 */ 1562 void VirtualSystemDescription:: addEntry(VirtualSystemDescriptionType_T aType,1563 const Utf8Str &strRef,1564 const Utf8Str &aOvfValue,1565 const Utf8Str &aVboxValue,1566 uint32_t ulSizeMB,1567 const Utf8Str &strExtraConfig /*= ""*/)1460 void VirtualSystemDescription::i_addEntry(VirtualSystemDescriptionType_T aType, 1461 const Utf8Str &strRef, 1462 const Utf8Str &aOvfValue, 1463 const Utf8Str &aVboxValue, 1464 uint32_t ulSizeMB, 1465 const Utf8Str &strExtraConfig /*= ""*/) 1568 1466 { 1569 1467 VirtualSystemDescriptionEntry vsde; 1570 vsde.ulIndex = (uint32_t)m-> llDescriptions.size(); // each entry gets an index so the client side can reference them1468 vsde.ulIndex = (uint32_t)m->maDescriptions.size(); // each entry gets an index so the client side can reference them 1571 1469 vsde.type = aType; 1572 1470 vsde.strRef = strRef; … … 1580 1478 vsde.ulSizeMB = ulSizeMB; 1581 1479 1582 m-> llDescriptions.push_back(vsde);1480 m->maDescriptions.push_back(vsde); 1583 1481 } 1584 1482 … … 1589 1487 * @return 1590 1488 */ 1591 std::list<VirtualSystemDescriptionEntry*> VirtualSystemDescription:: findByType(VirtualSystemDescriptionType_T aType)1489 std::list<VirtualSystemDescriptionEntry*> VirtualSystemDescription::i_findByType(VirtualSystemDescriptionType_T aType) 1592 1490 { 1593 1491 std::list<VirtualSystemDescriptionEntry*> vsd; 1594 1595 list<VirtualSystemDescriptionEntry>::iterator it; 1596 for (it = m->llDescriptions.begin(); 1597 it != m->llDescriptions.end(); 1492 for (vector<VirtualSystemDescriptionEntry>::iterator it = m->maDescriptions.begin(); 1493 it != m->maDescriptions.end(); 1598 1494 ++it) 1599 1495 { … … 1605 1501 } 1606 1502 1607 /** 1608 * Private method; delete all records from the list 1503 /* Private method; delete all records from the list 1609 1504 * m->llDescriptions that match the given type. 1610 1505 * @param aType 1611 1506 * @return 1612 1507 */ 1613 void VirtualSystemDescription::removeByType(VirtualSystemDescriptionType_T aType) 1614 { 1615 std::list<VirtualSystemDescriptionEntry*> vsd; 1616 1617 list<VirtualSystemDescriptionEntry>::iterator it = m->llDescriptions.begin(); 1618 while (it != m->llDescriptions.end()) 1508 void VirtualSystemDescription::i_removeByType(VirtualSystemDescriptionType_T aType) 1509 { 1510 for (std::vector<VirtualSystemDescriptionEntry>::iterator it = m->maDescriptions.begin(); it != m->maDescriptions.end(); ++it) 1619 1511 { 1620 1512 if (it->type == aType) 1621 it = m->llDescriptions.erase(it); 1622 else 1623 ++it; 1513 it = m->maDescriptions.erase(it); 1624 1514 } 1625 1515 } … … 1632 1522 * @return 1633 1523 */ 1634 const VirtualSystemDescriptionEntry* VirtualSystemDescription:: findControllerFromID(uint32_t id)1524 const VirtualSystemDescriptionEntry* VirtualSystemDescription::i_findControllerFromID(uint32_t id) 1635 1525 { 1636 1526 Utf8Str strRef = Utf8StrFmt("%RI32", id); 1637 list<VirtualSystemDescriptionEntry>::const_iterator it;1638 for (it = m-> llDescriptions.begin();1639 it != m-> llDescriptions.end();1527 vector<VirtualSystemDescriptionEntry>::const_iterator it; 1528 for (it = m->maDescriptions.begin(); 1529 it != m->maDescriptions.end(); 1640 1530 ++it) 1641 1531 { … … 1669 1559 * DOM tree. 1670 1560 */ 1671 void VirtualSystemDescription::i mportVboxMachineXML(const xml::ElementNode &elmMachine)1561 void VirtualSystemDescription::i_importVboxMachineXML(const xml::ElementNode &elmMachine) 1672 1562 { 1673 1563 settings::MachineConfigFile *pConfig = NULL; … … 1694 1584 * @return 1695 1585 */ 1696 const settings::MachineConfigFile* VirtualSystemDescription:: getMachineConfig() const1586 const settings::MachineConfigFile* VirtualSystemDescription::i_getMachineConfig() const 1697 1587 { 1698 1588 return m->pConfig; -
trunk/src/VBox/Main/src-server/ApplianceImplExport.cpp
r49586 r49742 77 77 78 78 LocationInfo locInfo; 79 parseURI(location, locInfo);79 i_parseURI(location, locInfo); 80 80 // create a new virtual system to store in the appliance 81 81 rc = pNewDesc.createObject(); … … 143 143 /* Guest OS type */ 144 144 ovf::CIMOSType_T cim = convertVBoxOSType2CIMOSType(strOsTypeVBox.c_str(), fLongMode); 145 pNewDesc-> addEntry(VirtualSystemDescriptionType_OS,146 "",147 Utf8StrFmt("%RI32", cim),148 strOsTypeVBox);145 pNewDesc->i_addEntry(VirtualSystemDescriptionType_OS, 146 "", 147 Utf8StrFmt("%RI32", cim), 148 strOsTypeVBox); 149 149 150 150 /* VM name */ 151 pNewDesc-> addEntry(VirtualSystemDescriptionType_Name,152 "",153 strVMName,154 strVMName);151 pNewDesc->i_addEntry(VirtualSystemDescriptionType_Name, 152 "", 153 strVMName, 154 strVMName); 155 155 156 156 // description 157 pNewDesc-> addEntry(VirtualSystemDescriptionType_Description,158 "",159 strDescription,160 strDescription);157 pNewDesc->i_addEntry(VirtualSystemDescriptionType_Description, 158 "", 159 strDescription, 160 strDescription); 161 161 162 162 /* CPU count*/ 163 163 Utf8Str strCpuCount = Utf8StrFmt("%RI32", cCPUs); 164 pNewDesc-> addEntry(VirtualSystemDescriptionType_CPU,165 "",166 strCpuCount,167 strCpuCount);164 pNewDesc->i_addEntry(VirtualSystemDescriptionType_CPU, 165 "", 166 strCpuCount, 167 strCpuCount); 168 168 169 169 /* Memory */ 170 170 Utf8Str strMemory = Utf8StrFmt("%RI64", (uint64_t)ulMemSizeMB * _1M); 171 pNewDesc-> addEntry(VirtualSystemDescriptionType_Memory,172 "",173 strMemory,174 strMemory);171 pNewDesc->i_addEntry(VirtualSystemDescriptionType_Memory, 172 "", 173 strMemory, 174 strMemory); 175 175 176 176 // the one VirtualBox IDE controller has two channels with two ports each, which is … … 225 225 if (strVbox.length()) 226 226 { 227 lIDEControllerPrimaryIndex = (int32_t)pNewDesc->m-> llDescriptions.size();228 pNewDesc-> addEntry(VirtualSystemDescriptionType_HardDiskControllerIDE,229 Utf8StrFmt("%d", lIDEControllerPrimaryIndex), // strRef230 strVbox, // aOvfValue231 strVbox); // aVboxValue227 lIDEControllerPrimaryIndex = (int32_t)pNewDesc->m->maDescriptions.size(); 228 pNewDesc->i_addEntry(VirtualSystemDescriptionType_HardDiskControllerIDE, 229 Utf8StrFmt("%d", lIDEControllerPrimaryIndex), // strRef 230 strVbox, // aOvfValue 231 strVbox); // aVboxValue 232 232 lIDEControllerSecondaryIndex = lIDEControllerPrimaryIndex + 1; 233 pNewDesc-> addEntry(VirtualSystemDescriptionType_HardDiskControllerIDE,234 Utf8StrFmt("%d", lIDEControllerSecondaryIndex),235 strVbox,236 strVbox);233 pNewDesc->i_addEntry(VirtualSystemDescriptionType_HardDiskControllerIDE, 234 Utf8StrFmt("%d", lIDEControllerSecondaryIndex), 235 strVbox, 236 strVbox); 237 237 } 238 238 } … … 242 242 { 243 243 Utf8Str strVbox = "AHCI"; 244 lSATAControllerIndex = (int32_t)pNewDesc->m-> llDescriptions.size();245 pNewDesc-> addEntry(VirtualSystemDescriptionType_HardDiskControllerSATA,246 Utf8StrFmt("%d", lSATAControllerIndex),247 strVbox,248 strVbox);244 lSATAControllerIndex = (int32_t)pNewDesc->m->maDescriptions.size(); 245 pNewDesc->i_addEntry(VirtualSystemDescriptionType_HardDiskControllerSATA, 246 Utf8StrFmt("%d", lSATAControllerIndex), 247 strVbox, 248 strVbox); 249 249 } 250 250 … … 262 262 case StorageControllerType_BusLogic: strVbox = "BusLogic"; break; 263 263 } 264 lSCSIControllerIndex = (int32_t)pNewDesc->m-> llDescriptions.size();265 pNewDesc-> addEntry(VirtualSystemDescriptionType_HardDiskControllerSCSI,266 Utf8StrFmt("%d", lSCSIControllerIndex),267 strVbox,268 strVbox);264 lSCSIControllerIndex = (int32_t)pNewDesc->m->maDescriptions.size(); 265 pNewDesc->i_addEntry(VirtualSystemDescriptionType_HardDiskControllerSCSI, 266 Utf8StrFmt("%d", lSCSIControllerIndex), 267 strVbox, 268 strVbox); 269 269 } 270 270 else … … 277 277 // it should be a SCSI controller 278 278 Utf8Str strVbox = "LsiLogicSas"; 279 lSCSIControllerIndex = (int32_t)pNewDesc->m-> llDescriptions.size();280 pNewDesc-> addEntry(VirtualSystemDescriptionType_HardDiskControllerSAS,281 Utf8StrFmt("%d", lSCSIControllerIndex),282 strVbox,283 strVbox);279 lSCSIControllerIndex = (int32_t)pNewDesc->m->maDescriptions.size(); 280 pNewDesc->i_addEntry(VirtualSystemDescriptionType_HardDiskControllerSAS, 281 Utf8StrFmt("%d", lSCSIControllerIndex), 282 strVbox, 283 strVbox); 284 284 } 285 285 … … 478 478 case DeviceType_HardDisk: 479 479 Log(("Adding VirtualSystemDescriptionType_HardDiskImage, disk size: %RI64\n", llSize)); 480 pNewDesc-> addEntry(VirtualSystemDescriptionType_HardDiskImage,481 strTargetImageName, // disk ID: let's use the name482 strTargetImageName, // OVF value:483 strLocation, // vbox value: media path484 (uint32_t)(llSize / _1M),485 strExtra);480 pNewDesc->i_addEntry(VirtualSystemDescriptionType_HardDiskImage, 481 strTargetImageName, // disk ID: let's use the name 482 strTargetImageName, // OVF value: 483 strLocation, // vbox value: media path 484 (uint32_t)(llSize / _1M), 485 strExtra); 486 486 break; 487 487 488 488 case DeviceType_DVD: 489 489 Log(("Adding VirtualSystemDescriptionType_CDROM, disk size: %RI64\n", llSize)); 490 pNewDesc-> addEntry(VirtualSystemDescriptionType_CDROM,491 strTargetImageName, // disk ID492 strTargetImageName, // OVF value493 strLocation, // vbox value494 (uint32_t)(llSize / _1M),// ulSize495 strExtra);490 pNewDesc->i_addEntry(VirtualSystemDescriptionType_CDROM, 491 strTargetImageName, // disk ID 492 strTargetImageName, // OVF value 493 strLocation, // vbox value 494 (uint32_t)(llSize / _1M),// ulSize 495 strExtra); 496 496 break; 497 497 498 498 case DeviceType_Floppy: 499 pNewDesc-> addEntry(VirtualSystemDescriptionType_Floppy,500 strEmpty, // disk ID501 strEmpty, // OVF value502 strEmpty, // vbox value503 1, // ulSize504 strExtra);499 pNewDesc->i_addEntry(VirtualSystemDescriptionType_Floppy, 500 strEmpty, // disk ID 501 strEmpty, // OVF value 502 strEmpty, // vbox value 503 1, // ulSize 504 strExtra); 505 505 break; 506 506 } … … 532 532 533 533 Utf8Str strAttachmentType = convertNetworkAttachmentTypeToString(attachmentType); 534 pNewDesc-> addEntry(VirtualSystemDescriptionType_NetworkAdapter,534 pNewDesc->i_addEntry(VirtualSystemDescriptionType_NetworkAdapter, 535 535 "", // ref 536 536 strAttachmentType, // orig … … 544 544 #ifdef VBOX_WITH_USB 545 545 if (fUSBEnabled) 546 pNewDesc-> addEntry(VirtualSystemDescriptionType_USBController, "", "", "");546 pNewDesc->i_addEntry(VirtualSystemDescriptionType_USBController, "", "", ""); 547 547 #endif /* VBOX_WITH_USB */ 548 548 549 549 // <const name="SoundCard" /> 550 550 if (fAudioEnabled) 551 pNewDesc-> addEntry(VirtualSystemDescriptionType_SoundCard,552 "",553 "ensoniq1371", // this is what OVFTool writes and VMware supports554 Utf8StrFmt("%RI32", audioController));551 pNewDesc->i_addEntry(VirtualSystemDescriptionType_SoundCard, 552 "", 553 "ensoniq1371", // this is what OVFTool writes and VMware supports 554 Utf8StrFmt("%RI32", audioController)); 555 555 556 556 /* We return the new description to the caller */ … … 584 584 * @return 585 585 */ 586 STDMETHODIMP Appliance::Write(IN_BSTR format, ComSafeArrayIn(ImportOptions_T, options), IN_BSTR path, IProgress **aProgress) 586 HRESULT Appliance::write(const com::Utf8Str &aFormat, 587 const std::vector<ExportOptions_T> &aOptions, 588 const com::Utf8Str &aPath, 589 ComPtr<IProgress> &aProgress) 587 590 { 588 if (!path) return E_POINTER;589 CheckComArgOutPointerValid(aProgress);590 591 AutoCaller autoCaller(this);592 if (FAILED(autoCaller.rc())) return autoCaller.rc();593 594 591 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 595 592 596 if (options != NULL) 597 m->optListExport = com::SafeArray<ExportOptions_T>(ComSafeArrayInArg(options)).toList(); 598 599 // AssertReturn(!(m->optListExport.contains(ExportOptions_CreateManifest) && m->optListExport.contains(ExportOptions_ExportDVDImages)), E_INVALIDARG); 593 m->optListExport.clear(); 594 if (aOptions.size()) 595 { 596 for (size_t i = 0; i < aOptions.size(); ++i) 597 { 598 m->optListExport.insert(i, aOptions[i]); 599 } 600 } 601 602 // AssertReturn(!(m->optListExport.contains(ExportOptions_CreateManifest) && m->optListExport.contains(ExportOptions_ExportDVDImages)), E_INVALIDARG); 600 603 601 604 m->fExportISOImages = m->optListExport.contains(ExportOptions_ExportDVDImages); … … 609 612 { 610 613 ComObjPtr<VirtualSystemDescription> vsdescThis = (*it); 611 vsdescThis-> removeByType(VirtualSystemDescriptionType_CDROM);614 vsdescThis->i_removeByType(VirtualSystemDescriptionType_CDROM); 612 615 } 613 616 } 614 617 615 618 // do not allow entering this method if the appliance is busy reading or writing 616 if (!i sApplianceIdle())619 if (!i_isApplianceIdle()) 617 620 return E_ACCESSDENIED; 618 621 619 622 // see if we can handle this file; for now we insist it has an ".ovf" extension 620 Utf8Str strPath = path; 621 if (!( strPath.endsWith(".ovf", Utf8Str::CaseInsensitive) 622 || strPath.endsWith(".ova", Utf8Str::CaseInsensitive))) 623 if (!( aPath.endsWith(".ovf", Utf8Str::CaseInsensitive) 624 || aPath.endsWith(".ova", Utf8Str::CaseInsensitive))) 623 625 return setError(VBOX_E_FILE_ERROR, 624 626 tr("Appliance file must have .ovf or .ova extension")); 625 627 626 628 m->fManifest = m->optListExport.contains(ExportOptions_CreateManifest); 627 Utf8Str strFormat(format);628 629 629 630 ovf::OVFVersion_T ovfF; 630 if ( strFormat == "ovf-0.9")631 if (aFormat == "ovf-0.9") 631 632 { 632 633 ovfF = ovf::OVFVersion_0_9; 633 634 } 634 else if ( strFormat == "ovf-1.0")635 else if (aFormat == "ovf-1.0") 635 636 { 636 637 ovfF = ovf::OVFVersion_1_0; 637 638 } 638 else if ( strFormat == "ovf-2.0")639 else if (aFormat == "ovf-2.0") 639 640 { 640 641 ovfF = ovf::OVFVersion_2_0; … … 642 643 else 643 644 return setError(VBOX_E_FILE_ERROR, 644 tr("Invalid format \"%s\" specified"), strFormat.c_str());645 tr("Invalid format \"%s\" specified"), aFormat.c_str()); 645 646 646 647 /* as of OVF 2.0 we have to use SHA256 */ … … 652 653 { 653 654 /* Parse all necessary info out of the URI */ 654 parseURI(strPath, m->locInfo);655 rc = writeImpl(ovfF, m->locInfo, progress);655 i_parseURI(aPath, m->locInfo); 656 rc = i_writeImpl(ovfF, m->locInfo, progress); 656 657 } 657 658 catch (HRESULT aRC) … … 662 663 if (SUCCEEDED(rc)) 663 664 /* Return progress to the caller */ 664 progress.queryInterfaceTo(aProgress );665 progress.queryInterfaceTo(aProgress.asOutParam()); 665 666 666 667 return rc; … … 685 686 * 1) from the public Appliance::Write(). 686 687 * 687 * 2) in a second worker thread; in that case, Appliance::Write() called Appliance:: writeImpl(), which688 * called Appliance:: writeFSOVA(), which called Appliance::writeImpl(), which then called this again.688 * 2) in a second worker thread; in that case, Appliance::Write() called Appliance::i_writeImpl(), which 689 * called Appliance::i_writeFSOVA(), which called Appliance::i_writeImpl(), which then called this again. 689 690 * 690 * 3) from Appliance:: writeS3(), which got called from a previous instance of Appliance::taskThreadWriteOVF().691 * 3) from Appliance::i_writeS3(), which got called from a previous instance of Appliance::taskThreadWriteOVF(). 691 692 * 692 693 * @param aFormat … … 695 696 * @return 696 697 */ 697 HRESULT Appliance:: writeImpl(ovf::OVFVersion_T aFormat, const LocationInfo &aLocInfo, ComObjPtr<Progress> &aProgress)698 HRESULT Appliance::i_writeImpl(ovf::OVFVersion_T aFormat, const LocationInfo &aLocInfo, ComObjPtr<Progress> &aProgress) 698 699 { 699 700 HRESULT rc = S_OK; 700 701 try 701 702 { 702 rc = setUpProgress(aProgress,703 BstrFmt(tr("Export appliance '%s'"), aLocInfo.strPath.c_str()),704 (aLocInfo.storageType == VFSType_File) ? WriteFile : WriteS3);703 rc = i_setUpProgress(aProgress, 704 BstrFmt(tr("Export appliance '%s'"), aLocInfo.strPath.c_str()), 705 (aLocInfo.storageType == VFSType_File) ? WriteFile : WriteS3); 705 706 706 707 /* Initialize our worker task */ … … 724 725 725 726 /** 726 * Called from Appliance:: writeFS() for creating a XML document for this727 * Called from Appliance::i_writeFS() for creating a XML document for this 727 728 * Appliance. 728 729 * … … 735 736 * @param enFormat OVF format (0.9 or 1.0). 736 737 */ 737 void Appliance:: buildXML(AutoWriteLockBase& writeLock,738 xml::Document &doc,739 XMLStack &stack,740 const Utf8Str &strPath,741 ovf::OVFVersion_T enFormat)738 void Appliance::i_buildXML(AutoWriteLockBase& writeLock, 739 xml::Document &doc, 740 XMLStack &stack, 741 const Utf8Str &strPath, 742 ovf::OVFVersion_T enFormat) 742 743 { 743 744 xml::ElementNode *pelmRoot = doc.createRootElement("Envelope"); … … 851 852 { 852 853 ComObjPtr<VirtualSystemDescription> vsdescThis = *it; 853 buildXMLForOneVirtualSystem(writeLock,854 *pelmToAddVirtualSystemsTo,855 &llElementsWithUuidAttributes,856 vsdescThis,857 enFormat,858 stack); // disks and networks stack854 i_buildXMLForOneVirtualSystem(writeLock, 855 *pelmToAddVirtualSystemsTo, 856 &llElementsWithUuidAttributes, 857 vsdescThis, 858 enFormat, 859 stack); // disks and networks stack 859 860 } 860 861 … … 1010 1011 1011 1012 /** 1012 * Called from Appliance:: buildXML() for each virtual system (machine) that1013 * Called from Appliance::i_buildXML() for each virtual system (machine) that 1013 1014 * needs XML written out. 1014 1015 * … … 1024 1025 * data shared with caller. 1025 1026 */ 1026 void Appliance:: buildXMLForOneVirtualSystem(AutoWriteLockBase& writeLock,1027 xml::ElementNode &elmToAddVirtualSystemsTo,1028 std::list<xml::ElementNode*> *pllElementsWithUuidAttributes,1029 ComObjPtr<VirtualSystemDescription> &vsdescThis,1030 ovf::OVFVersion_T enFormat,1031 XMLStack &stack)1027 void Appliance::i_buildXMLForOneVirtualSystem(AutoWriteLockBase& writeLock, 1028 xml::ElementNode &elmToAddVirtualSystemsTo, 1029 std::list<xml::ElementNode*> *pllElementsWithUuidAttributes, 1030 ComObjPtr<VirtualSystemDescription> &vsdescThis, 1031 ovf::OVFVersion_T enFormat, 1032 XMLStack &stack) 1032 1033 { 1033 1034 LogFlowFunc(("ENTER appliance %p\n", this)); … … 1045 1046 /*xml::ElementNode *pelmVirtualSystemInfo =*/ pelmVirtualSystem->createChild("Info")->addContent("A virtual machine"); 1046 1047 1047 std::list<VirtualSystemDescriptionEntry*> llName = vsdescThis-> findByType(VirtualSystemDescriptionType_Name);1048 std::list<VirtualSystemDescriptionEntry*> llName = vsdescThis->i_findByType(VirtualSystemDescriptionType_Name); 1048 1049 if (!llName.size()) 1049 1050 throw setError(VBOX_E_NOT_SUPPORTED, tr("Missing VM name")); … … 1052 1053 1053 1054 // product info 1054 std::list<VirtualSystemDescriptionEntry*> llProduct = vsdescThis-> findByType(VirtualSystemDescriptionType_Product);1055 std::list<VirtualSystemDescriptionEntry*> llProductUrl = vsdescThis-> findByType(VirtualSystemDescriptionType_ProductUrl);1056 std::list<VirtualSystemDescriptionEntry*> llVendor = vsdescThis-> findByType(VirtualSystemDescriptionType_Vendor);1057 std::list<VirtualSystemDescriptionEntry*> llVendorUrl = vsdescThis-> findByType(VirtualSystemDescriptionType_VendorUrl);1058 std::list<VirtualSystemDescriptionEntry*> llVersion = vsdescThis-> findByType(VirtualSystemDescriptionType_Version);1055 std::list<VirtualSystemDescriptionEntry*> llProduct = vsdescThis->i_findByType(VirtualSystemDescriptionType_Product); 1056 std::list<VirtualSystemDescriptionEntry*> llProductUrl = vsdescThis->i_findByType(VirtualSystemDescriptionType_ProductUrl); 1057 std::list<VirtualSystemDescriptionEntry*> llVendor = vsdescThis->i_findByType(VirtualSystemDescriptionType_Vendor); 1058 std::list<VirtualSystemDescriptionEntry*> llVendorUrl = vsdescThis->i_findByType(VirtualSystemDescriptionType_VendorUrl); 1059 std::list<VirtualSystemDescriptionEntry*> llVersion = vsdescThis->i_findByType(VirtualSystemDescriptionType_Version); 1059 1060 bool fProduct = llProduct.size() && !llProduct.back()->strVboxCurrent.isEmpty(); 1060 1061 bool fProductUrl = llProductUrl.size() && !llProductUrl.back()->strVboxCurrent.isEmpty(); … … 1100 1101 1101 1102 // description 1102 std::list<VirtualSystemDescriptionEntry*> llDescription = vsdescThis-> findByType(VirtualSystemDescriptionType_Description);1103 std::list<VirtualSystemDescriptionEntry*> llDescription = vsdescThis->i_findByType(VirtualSystemDescriptionType_Description); 1103 1104 if (llDescription.size() && 1104 1105 !llDescription.back()->strVboxCurrent.isEmpty()) … … 1123 1124 1124 1125 // license 1125 std::list<VirtualSystemDescriptionEntry*> llLicense = vsdescThis-> findByType(VirtualSystemDescriptionType_License);1126 std::list<VirtualSystemDescriptionEntry*> llLicense = vsdescThis->i_findByType(VirtualSystemDescriptionType_License); 1126 1127 if (llLicense.size() && 1127 1128 !llLicense.back()->strVboxCurrent.isEmpty()) … … 1145 1146 1146 1147 // operating system 1147 std::list<VirtualSystemDescriptionEntry*> llOS = vsdescThis-> findByType(VirtualSystemDescriptionType_OS);1148 std::list<VirtualSystemDescriptionEntry*> llOS = vsdescThis->i_findByType(VirtualSystemDescriptionType_OS); 1148 1149 if (!llOS.size()) 1149 1150 throw setError(VBOX_E_NOT_SUPPORTED, tr("Missing OS type")); … … 1233 1234 { 1234 1235 int32_t lIndexThis = 0; 1235 list<VirtualSystemDescriptionEntry>::const_iterator itD;1236 for (itD = vsdescThis->m-> llDescriptions.begin();1237 itD != vsdescThis->m-> llDescriptions.end();1236 vector<VirtualSystemDescriptionEntry>::const_iterator itD; 1237 for (itD = vsdescThis->m->maDescriptions.begin(); 1238 itD != vsdescThis->m->maDescriptions.end(); 1238 1239 ++itD, ++lIndexThis) 1239 1240 { … … 1850 1851 * and therefore runs on the OVF/OVA write worker thread. This runs in two contexts: 1851 1852 * 1852 * 1) in a first worker thread; in that case, Appliance::Write() called Appliance:: writeImpl();1853 * 1) in a first worker thread; in that case, Appliance::Write() called Appliance::i_writeImpl(); 1853 1854 * 1854 * 2) in a second worker thread; in that case, Appliance::Write() called Appliance:: writeImpl(), which1855 * called Appliance:: writeS3(), which called Appliance::writeImpl(), which then called this. In other1855 * 2) in a second worker thread; in that case, Appliance::Write() called Appliance::i_writeImpl(), which 1856 * called Appliance::i_writeS3(), which called Appliance::i_writeImpl(), which then called this. In other 1856 1857 * words, to write to the cloud, the first worker thread first starts a second worker thread to create 1857 1858 * temporary files and then uploads them to the S3 cloud server. … … 1860 1861 * @return 1861 1862 */ 1862 HRESULT Appliance:: writeFS(TaskOVF *pTask)1863 HRESULT Appliance::i_writeFS(TaskOVF *pTask) 1863 1864 { 1864 1865 LogFlowFuncEnter(); … … 1879 1880 1880 1881 if (pTask->locInfo.strPath.endsWith(".ovf", Utf8Str::CaseInsensitive)) 1881 rc = writeFSOVF(pTask, multiLock);1882 rc = i_writeFSOVF(pTask, multiLock); 1882 1883 else 1883 rc = writeFSOVA(pTask, multiLock);1884 rc = i_writeFSOVA(pTask, multiLock); 1884 1885 1885 1886 // reset the state so others can call methods again … … 1891 1892 } 1892 1893 1893 HRESULT Appliance:: writeFSOVF(TaskOVF *pTask, AutoWriteLockBase& writeLock)1894 HRESULT Appliance::i_writeFSOVF(TaskOVF *pTask, AutoWriteLockBase& writeLock) 1894 1895 { 1895 1896 LogFlowFuncEnter(); … … 1920 1921 1921 1922 1922 Utf8Str name = applianceIOName(applianceIOFile);1923 Utf8Str name = i_applianceIOName(applianceIOFile); 1923 1924 1924 1925 int vrc = VDInterfaceAdd(&pFileIo->Core, name.c_str(), … … 1930 1931 break; 1931 1932 } 1932 rc = writeFSImpl(pTask, writeLock, pShaIo, &storage);1933 rc = i_writeFSImpl(pTask, writeLock, pShaIo, &storage); 1933 1934 } while (0); 1934 1935 … … 1943 1944 } 1944 1945 1945 HRESULT Appliance:: writeFSOVA(TaskOVF *pTask, AutoWriteLockBase& writeLock)1946 HRESULT Appliance::i_writeFSOVA(TaskOVF *pTask, AutoWriteLockBase& writeLock) 1946 1947 { 1947 1948 LogFlowFuncEnter(); … … 1977 1978 storage.fSha256 = m->fSha256; 1978 1979 1979 Utf8Str name = applianceIOName(applianceIOTar);1980 Utf8Str name = i_applianceIOName(applianceIOTar); 1980 1981 1981 1982 vrc = VDInterfaceAdd(&pTarIo->Core, name.c_str(), … … 1988 1989 break; 1989 1990 } 1990 rc = writeFSImpl(pTask, writeLock, pShaIo, &storage);1991 rc = i_writeFSImpl(pTask, writeLock, pShaIo, &storage); 1991 1992 } while (0); 1992 1993 … … 2007 2008 } 2008 2009 2009 HRESULT Appliance:: writeFSImpl(TaskOVF *pTask, AutoWriteLockBase& writeLock, PVDINTERFACEIO pIfIo, PSHASTORAGE pStorage)2010 HRESULT Appliance::i_writeFSImpl(TaskOVF *pTask, AutoWriteLockBase& writeLock, PVDINTERFACEIO pIfIo, PSHASTORAGE pStorage) 2010 2011 { 2011 2012 LogFlowFuncEnter(); … … 2026 2027 xml::Document doc; 2027 2028 // Now fully build a valid ovf document in memory 2028 buildXML(writeLock, doc, stack, pTask->locInfo.strPath, pTask->enFormat);2029 i_buildXML(writeLock, doc, stack, pTask->locInfo.strPath, pTask->enFormat); 2029 2030 /* Extract the OVA file name */ 2030 2031 Utf8Str strOvaFile = pTask->locInfo.strPath; … … 2144 2145 ComPtr<IProgress> pProgress3(pProgress2); 2145 2146 // now wait for the background disk operation to complete; this throws HRESULTs on error 2146 waitForAsyncProgress(pTask->pProgress, pProgress3);2147 i_waitForAsyncProgress(pTask->pProgress, pProgress3); 2147 2148 } 2148 2149 else//pDiskEntry->type == VirtualSystemDescriptionType_CDROM … … 2314 2315 * Worker code for writing out OVF to the cloud. This is called from Appliance::taskThreadWriteOVF() 2315 2316 * in S3 mode and therefore runs on the OVF write worker thread. This then starts a second worker 2316 * thread to create temporary files (see Appliance:: writeFS()).2317 * thread to create temporary files (see Appliance::i_writeFS()). 2317 2318 * 2318 2319 * @param pTask 2319 2320 * @return 2320 2321 */ 2321 HRESULT Appliance:: writeS3(TaskOVF *pTask)2322 HRESULT Appliance::i_writeS3(TaskOVF *pTask) 2322 2323 { 2323 2324 LogFlowFuncEnter(); … … 2347 2348 Utf8Str tmpPath = pTask->locInfo.strPath; 2348 2349 Utf8Str bucket; 2349 parseBucket(tmpPath, bucket);2350 i_parseBucket(tmpPath, bucket); 2350 2351 2351 2352 /* We need a temporary directory which we can put the OVF file & all … … 2364 2365 LocationInfo li; 2365 2366 li.strPath = strTmpOvf; 2366 rc = writeImpl(pTask->enFormat, li, progress);2367 rc = i_writeImpl(pTask->enFormat, li, progress); 2367 2368 if (FAILED(rc)) throw rc; 2368 2369 … … 2372 2373 caller */ 2373 2374 ComPtr<IProgress> progressInt(progress); 2374 waitForAsyncProgress(pTask->pProgress, progressInt); /* Any errors will be thrown */2375 i_waitForAsyncProgress(pTask->pProgress, progressInt); /* Any errors will be thrown */ 2375 2376 2376 2377 /* Again lock the appliance for the next steps */ … … 2397 2398 { 2398 2399 ComObjPtr<VirtualSystemDescription> vsdescThis = (*it); 2399 std::list<VirtualSystemDescriptionEntry*> avsdeHDs = vsdescThis-> findByType(VirtualSystemDescriptionType_HardDiskImage);2400 std::list<VirtualSystemDescriptionEntry*> avsdeHDs = vsdescThis->i_findByType(VirtualSystemDescriptionType_HardDiskImage); 2400 2401 std::list<VirtualSystemDescriptionEntry*>::const_iterator itH; 2401 2402 for (itH = avsdeHDs.begin(); … … 2417 2418 } 2418 2419 /* Next we have to upload the OVF & all disk images */ 2419 vrc = RTS3Create(&hS3, pTask->locInfo.strUsername.c_str(), pTask->locInfo.strPassword.c_str(), pTask->locInfo.strHostname.c_str(), "virtualbox-agent/" 2420 vrc = RTS3Create(&hS3, pTask->locInfo.strUsername.c_str(), pTask->locInfo.strPassword.c_str(), pTask->locInfo.strHostname.c_str(), "virtualbox-agent/"VBOX_VERSION_STRING); 2420 2421 if (RT_FAILURE(vrc)) 2421 2422 throw setError(VBOX_E_IPRT_ERROR, -
trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp
r49716 r49742 62 62 * Thread implementation is in Appliance::readImpl(). 63 63 * 64 * @param path64 * @param aFile 65 65 * @return 66 66 */ 67 STDMETHODIMP Appliance::Read(IN_BSTR path, IProgress **aProgress) 67 HRESULT Appliance::read(const com::Utf8Str &aFile, 68 ComPtr<IProgress> &aProgress) 68 69 { 69 if (!path) return E_POINTER;70 CheckComArgOutPointerValid(aProgress);71 72 AutoCaller autoCaller(this);73 if (FAILED(autoCaller.rc())) return autoCaller.rc();74 75 70 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 76 71 77 if (!i sApplianceIdle())72 if (!i_isApplianceIdle()) 78 73 return E_ACCESSDENIED; 79 74 … … 85 80 86 81 // see if we can handle this file; for now we insist it has an ovf/ova extension 87 Utf8Str strPath (path); 88 if (!( strPath.endsWith(".ovf", Utf8Str::CaseInsensitive) 89 || strPath.endsWith(".ova", Utf8Str::CaseInsensitive))) 82 if (!( aFile.endsWith(".ovf", Utf8Str::CaseInsensitive) 83 || aFile.endsWith(".ova", Utf8Str::CaseInsensitive))) 90 84 return setError(VBOX_E_FILE_ERROR, 91 85 tr("Appliance file must have .ovf extension")); … … 96 90 { 97 91 /* Parse all necessary info out of the URI */ 98 parseURI(strPath, m->locInfo);99 rc = readImpl(m->locInfo, progress);92 i_parseURI(aFile, m->locInfo); 93 rc = i_readImpl(m->locInfo, progress); 100 94 } 101 95 catch (HRESULT aRC) … … 106 100 if (SUCCEEDED(rc)) 107 101 /* Return progress to the caller */ 108 progress.queryInterfaceTo(aProgress );102 progress.queryInterfaceTo(aProgress.asOutParam()); 109 103 110 104 return S_OK; … … 116 110 * @return 117 111 */ 118 STDMETHODIMP Appliance::Interpret()112 HRESULT Appliance::interpret() 119 113 { 120 114 // @todo: … … 122 116 // locking of that objects itself (s. HardDisk)) 123 117 // - Appropriate handle errors like not supported file formats 124 AutoCaller autoCaller(this);125 if (FAILED(autoCaller.rc())) return autoCaller.rc();126 127 118 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 128 119 129 if (!i sApplianceIdle())120 if (!i_isApplianceIdle()) 130 121 return E_ACCESSDENIED; 131 122 … … 165 156 // VirtualBox settings code parse that XML now 166 157 if (vsysThis.pelmVboxMachine) 167 pNewDesc->i mportVboxMachineXML(*vsysThis.pelmVboxMachine);158 pNewDesc->i_importVboxMachineXML(*vsysThis.pelmVboxMachine); 168 159 169 160 // Guest OS type … … 182 173 else 183 174 convertCIMOSType2VBoxOSType(strOsTypeVBox, vsysThis.cimos, vsysThis.strCimosDesc); 184 pNewDesc-> addEntry(VirtualSystemDescriptionType_OS,185 "",186 strCIMOSType,187 strOsTypeVBox);175 pNewDesc->i_addEntry(VirtualSystemDescriptionType_OS, 176 "", 177 strCIMOSType, 178 strOsTypeVBox); 188 179 189 180 /* VM name */ … … 199 190 if (nameVBox.isEmpty()) 200 191 nameVBox = strOsTypeVBox; 201 searchUniqueVMName(nameVBox);202 pNewDesc-> addEntry(VirtualSystemDescriptionType_Name,203 "",204 vsysThis.strName,205 nameVBox);192 i_searchUniqueVMName(nameVBox); 193 pNewDesc->i_addEntry(VirtualSystemDescriptionType_Name, 194 "", 195 vsysThis.strName, 196 nameVBox); 206 197 207 198 /* Based on the VM name, create a target machine path. */ … … 218 209 /* VM Product */ 219 210 if (!vsysThis.strProduct.isEmpty()) 220 pNewDesc-> addEntry(VirtualSystemDescriptionType_Product,221 "",222 vsysThis.strProduct,223 vsysThis.strProduct);211 pNewDesc->i_addEntry(VirtualSystemDescriptionType_Product, 212 "", 213 vsysThis.strProduct, 214 vsysThis.strProduct); 224 215 225 216 /* VM Vendor */ 226 217 if (!vsysThis.strVendor.isEmpty()) 227 pNewDesc-> addEntry(VirtualSystemDescriptionType_Vendor,228 "",229 vsysThis.strVendor,230 vsysThis.strVendor);218 pNewDesc->i_addEntry(VirtualSystemDescriptionType_Vendor, 219 "", 220 vsysThis.strVendor, 221 vsysThis.strVendor); 231 222 232 223 /* VM Version */ 233 224 if (!vsysThis.strVersion.isEmpty()) 234 pNewDesc-> addEntry(VirtualSystemDescriptionType_Version,235 "",236 vsysThis.strVersion,237 vsysThis.strVersion);225 pNewDesc->i_addEntry(VirtualSystemDescriptionType_Version, 226 "", 227 vsysThis.strVersion, 228 vsysThis.strVersion); 238 229 239 230 /* VM ProductUrl */ 240 231 if (!vsysThis.strProductUrl.isEmpty()) 241 pNewDesc-> addEntry(VirtualSystemDescriptionType_ProductUrl,242 "",243 vsysThis.strProductUrl,244 vsysThis.strProductUrl);232 pNewDesc->i_addEntry(VirtualSystemDescriptionType_ProductUrl, 233 "", 234 vsysThis.strProductUrl, 235 vsysThis.strProductUrl); 245 236 246 237 /* VM VendorUrl */ 247 238 if (!vsysThis.strVendorUrl.isEmpty()) 248 pNewDesc-> addEntry(VirtualSystemDescriptionType_VendorUrl,249 "",250 vsysThis.strVendorUrl,251 vsysThis.strVendorUrl);239 pNewDesc->i_addEntry(VirtualSystemDescriptionType_VendorUrl, 240 "", 241 vsysThis.strVendorUrl, 242 vsysThis.strVendorUrl); 252 243 253 244 /* VM description */ 254 245 if (!vsysThis.strDescription.isEmpty()) 255 pNewDesc-> addEntry(VirtualSystemDescriptionType_Description,256 "",257 vsysThis.strDescription,258 vsysThis.strDescription);246 pNewDesc->i_addEntry(VirtualSystemDescriptionType_Description, 247 "", 248 vsysThis.strDescription, 249 vsysThis.strDescription); 259 250 260 251 /* VM license */ 261 252 if (!vsysThis.strLicenseText.isEmpty()) 262 pNewDesc-> addEntry(VirtualSystemDescriptionType_License,263 "",264 vsysThis.strLicenseText,265 vsysThis.strLicenseText);253 pNewDesc->i_addEntry(VirtualSystemDescriptionType_License, 254 "", 255 vsysThis.strLicenseText, 256 vsysThis.strLicenseText); 266 257 267 258 /* Now that we know the OS type, get our internal defaults based on that. */ … … 281 272 if (cpuCountVBox > SchemaDefs::MaxCPUCount) 282 273 { 283 addWarning(tr("The virtual system \"%s\" claims support for %u CPU's, but VirtualBox has support for "284 "max %u CPU's only."),285 vsysThis.strName.c_str(), cpuCountVBox, SchemaDefs::MaxCPUCount);274 i_addWarning(tr("The virtual system \"%s\" claims support for %u CPU's, but VirtualBox has support for " 275 "max %u CPU's only."), 276 vsysThis.strName.c_str(), cpuCountVBox, SchemaDefs::MaxCPUCount); 286 277 cpuCountVBox = SchemaDefs::MaxCPUCount; 287 278 } 288 279 if (vsysThis.cCPUs == 0) 289 280 cpuCountVBox = 1; 290 pNewDesc-> addEntry(VirtualSystemDescriptionType_CPU,291 "",292 Utf8StrFmt("%RU32", (uint32_t)vsysThis.cCPUs),293 Utf8StrFmt("%RU32", (uint32_t)cpuCountVBox));281 pNewDesc->i_addEntry(VirtualSystemDescriptionType_CPU, 282 "", 283 Utf8StrFmt("%RU32", (uint32_t)vsysThis.cCPUs), 284 Utf8StrFmt("%RU32", (uint32_t)cpuCountVBox)); 294 285 295 286 /* RAM */ … … 308 299 ) 309 300 { 310 addWarning(tr("The virtual system \"%s\" claims support for %llu MB RAM size, but VirtualBox has "311 "support for min %u & max %u MB RAM size only."),312 vsysThis.strName.c_str(), ullMemSizeVBox, MM_RAM_MIN_IN_MB, MM_RAM_MAX_IN_MB);301 i_addWarning(tr("The virtual system \"%s\" claims support for %llu MB RAM size, but VirtualBox has " 302 "support for min %u & max %u MB RAM size only."), 303 vsysThis.strName.c_str(), ullMemSizeVBox, MM_RAM_MIN_IN_MB, MM_RAM_MAX_IN_MB); 313 304 ullMemSizeVBox = RT_MIN(RT_MAX(ullMemSizeVBox, MM_RAM_MIN_IN_MB), MM_RAM_MAX_IN_MB); 314 305 } … … 322 313 ullMemSizeVBox = (uint64_t)memSizeVBox2; 323 314 } 324 pNewDesc-> addEntry(VirtualSystemDescriptionType_Memory,325 "",326 Utf8StrFmt("%RU64", (uint64_t)vsysThis.ullMemorySize),327 Utf8StrFmt("%RU64", (uint64_t)ullMemSizeVBox));315 pNewDesc->i_addEntry(VirtualSystemDescriptionType_Memory, 316 "", 317 Utf8StrFmt("%RU64", (uint64_t)vsysThis.ullMemorySize), 318 Utf8StrFmt("%RU64", (uint64_t)ullMemSizeVBox)); 328 319 329 320 /* Audio */ … … 345 336 } 346 337 if (strSoundCard.isNotEmpty()) 347 pNewDesc-> addEntry(VirtualSystemDescriptionType_SoundCard,348 "",349 strSoundCardOrig,350 strSoundCard);338 pNewDesc->i_addEntry(VirtualSystemDescriptionType_SoundCard, 339 "", 340 strSoundCardOrig, 341 strSoundCard); 351 342 352 343 #ifdef VBOX_WITH_USB … … 356 347 && pNewDesc->m->pConfig->hardwareMachine.usbSettings.llUSBControllers.size() > 0) 357 348 || vsysThis.fHasUsbController) 358 pNewDesc-> addEntry(VirtualSystemDescriptionType_USBController, "", "", "");349 pNewDesc->i_addEntry(VirtualSystemDescriptionType_USBController, "", "", ""); 359 350 #endif /* VBOX_WITH_USB */ 360 351 … … 368 359 /* Check for the constrains */ 369 360 if (llNetworkAdapters.size() > maxNetworkAdapters) 370 addWarning(tr("The virtual system \"%s\" claims support for %zu network adapters, but VirtualBox "371 "has support for max %u network adapter only."),372 vsysThis.strName.c_str(), llNetworkAdapters.size(), maxNetworkAdapters);361 i_addWarning(tr("The virtual system \"%s\" claims support for %zu network adapters, but VirtualBox " 362 "has support for max %u network adapter only."), 363 vsysThis.strName.c_str(), llNetworkAdapters.size(), maxNetworkAdapters); 373 364 /* Iterate through all network adapters. */ 374 365 settings::NetworkAdaptersList::const_iterator it1; … … 381 372 { 382 373 Utf8Str strMode = convertNetworkAttachmentTypeToString(it1->mode); 383 pNewDesc-> addEntry(VirtualSystemDescriptionType_NetworkAdapter,384 "", // ref385 strMode, // orig386 Utf8StrFmt("%RU32", (uint32_t)it1->type), // conf387 0,388 Utf8StrFmt("slot=%RU32;type=%s", it1->ulSlot, strMode.c_str())); // extra conf374 pNewDesc->i_addEntry(VirtualSystemDescriptionType_NetworkAdapter, 375 "", // ref 376 strMode, // orig 377 Utf8StrFmt("%RU32", (uint32_t)it1->type), // conf 378 0, 379 Utf8StrFmt("slot=%RU32;type=%s", it1->ulSlot, strMode.c_str())); // extra conf 389 380 } 390 381 } … … 397 388 /* Check for the constrains */ 398 389 if (cEthernetAdapters > maxNetworkAdapters) 399 addWarning(tr("The virtual system \"%s\" claims support for %zu network adapters, but VirtualBox "400 "has support for max %u network adapter only."),401 vsysThis.strName.c_str(), cEthernetAdapters, maxNetworkAdapters);390 i_addWarning(tr("The virtual system \"%s\" claims support for %zu network adapters, but VirtualBox " 391 "has support for max %u network adapter only."), 392 vsysThis.strName.c_str(), cEthernetAdapters, maxNetworkAdapters); 402 393 403 394 /* Get the default network adapter type for the selected guest OS */ … … 461 452 #endif /* VBOX_WITH_E1000 */ 462 453 463 pNewDesc-> addEntry(VirtualSystemDescriptionType_NetworkAdapter,464 "", // ref465 ea.strNetworkName, // orig466 Utf8StrFmt("%RU32", (uint32_t)nwAdapterVBox), // conf467 0,468 Utf8StrFmt("type=%s", strNetwork.c_str())); // extra conf454 pNewDesc->i_addEntry(VirtualSystemDescriptionType_NetworkAdapter, 455 "", // ref 456 ea.strNetworkName, // orig 457 Utf8StrFmt("%RU32", (uint32_t)nwAdapterVBox), // conf 458 0, 459 Utf8StrFmt("type=%s", strNetwork.c_str())); // extra conf 469 460 } 470 461 } … … 503 494 /* Floppy Drive */ 504 495 if (fFloppy) 505 pNewDesc-> addEntry(VirtualSystemDescriptionType_Floppy, "", "", "");496 pNewDesc->i_addEntry(VirtualSystemDescriptionType_Floppy, "", "", ""); 506 497 /* CD Drive */ 507 498 if (fDVD) 508 pNewDesc-> addEntry(VirtualSystemDescriptionType_CDROM, "", "", "");499 pNewDesc->i_addEntry(VirtualSystemDescriptionType_CDROM, "", "", ""); 509 500 510 501 /* Hard disk Controller */ … … 534 525 else if (!hdc.strControllerType.compare("ICH6", Utf8Str::CaseInsensitive)) 535 526 strType = "ICH6"; 536 pNewDesc-> addEntry(VirtualSystemDescriptionType_HardDiskControllerIDE,537 strControllerID, // strRef538 hdc.strControllerType, // aOvfValue539 strType); // aVboxValue527 pNewDesc->i_addEntry(VirtualSystemDescriptionType_HardDiskControllerIDE, 528 strControllerID, // strRef 529 hdc.strControllerType, // aOvfValue 530 strType); // aVboxValue 540 531 } 541 532 else 542 533 /* Warn only once */ 543 534 if (cIDEused == 2) 544 addWarning(tr("The virtual \"%s\" system requests support for more than two "535 i_addWarning(tr("The virtual \"%s\" system requests support for more than two " 545 536 "IDE controller channels, but VirtualBox supports only two."), 546 vsysThis.strName.c_str());537 vsysThis.strName.c_str()); 547 538 548 539 ++cIDEused; … … 555 546 // @todo: figure out the SATA types 556 547 /* We only support a plain AHCI controller, so use them always */ 557 pNewDesc-> addEntry(VirtualSystemDescriptionType_HardDiskControllerSATA,558 strControllerID,559 hdc.strControllerType,560 "AHCI");548 pNewDesc->i_addEntry(VirtualSystemDescriptionType_HardDiskControllerSATA, 549 strControllerID, 550 hdc.strControllerType, 551 "AHCI"); 561 552 } 562 553 else … … 564 555 /* Warn only once */ 565 556 if (cSATAused == 1) 566 addWarning(tr("The virtual system \"%s\" requests support for more than one "567 "SATA controller, but VirtualBox has support for only one"),568 vsysThis.strName.c_str());557 i_addWarning(tr("The virtual system \"%s\" requests support for more than one " 558 "SATA controller, but VirtualBox has support for only one"), 559 vsysThis.strName.c_str()); 569 560 570 561 } … … 586 577 else if (!hdc.strControllerType.compare("BusLogic", Utf8Str::CaseInsensitive)) 587 578 hdcController = "BusLogic"; 588 589 pNewDesc->addEntry(vsdet, 590 strControllerID, 591 hdc.strControllerType, 592 hdcController); 579 pNewDesc->i_addEntry(vsdet, 580 strControllerID, 581 hdc.strControllerType, 582 hdcController); 593 583 } 594 584 else 595 addWarning(tr("The virtual system \"%s\" requests support for an additional "596 "SCSI controller of type \"%s\" with ID %s, but VirtualBox presently "597 "supports only one SCSI controller."),598 vsysThis.strName.c_str(),599 hdc.strControllerType.c_str(),600 strControllerID.c_str());585 i_addWarning(tr("The virtual system \"%s\" requests support for an additional " 586 "SCSI controller of type \"%s\" with ID %s, but VirtualBox presently " 587 "supports only one SCSI controller."), 588 vsysThis.strName.c_str(), 589 hdc.strControllerType.c_str(), 590 strControllerID.c_str()); 601 591 ++cSCSIused; 602 592 break; … … 634 624 635 625 ComObjPtr<MediumFormat> mediumFormat; 636 rc = findMediumFormatFromDiskImage(di, mediumFormat);626 rc = i_findMediumFormatFromDiskImage(di, mediumFormat); 637 627 if (FAILED(rc)) 638 628 throw rc; … … 642 632 if (FAILED(rc)) 643 633 throw rc; 644 645 634 Utf8Str vdf = Utf8Str(bstrFormatName); 646 635 … … 659 648 Utf8Str strTargetPath = Utf8Str(strMachineFolder); 660 649 strTargetPath.append(RTPATH_DELIMITER).append(di.strHref); 661 searchUniqueDiskImageFilePath(strTargetPath);650 i_searchUniqueDiskImageFilePath(strTargetPath); 662 651 663 652 /* find the description for the hard disk controller 664 653 * that has the same ID as hd.idController */ 665 654 const VirtualSystemDescriptionEntry *pController; 666 if (!(pController = pNewDesc-> findControllerFromID(hd.idController)))655 if (!(pController = pNewDesc->i_findControllerFromID(hd.idController))) 667 656 throw setError(E_FAIL, 668 657 tr("Cannot find hard disk controller with OVF instance ID %RI32 " … … 675 664 pController->ulIndex, 676 665 hd.ulAddressOnParent); 677 pNewDesc-> addEntry(VirtualSystemDescriptionType_HardDiskImage,678 hd.strDiskId,679 di.strHref,680 strTargetPath,681 di.ulSuggestedSizeMB,682 strExtraConfig);666 pNewDesc->i_addEntry(VirtualSystemDescriptionType_HardDiskImage, 667 hd.strDiskId, 668 di.strHref, 669 strTargetPath, 670 di.ulSuggestedSizeMB, 671 strExtraConfig); 683 672 } 684 673 else if (vdf.compare("RAW", Utf8Str::CaseInsensitive) == 0) … … 692 681 .append(RTPATH_DELIMITER) 693 682 .append(di.strHref); 694 searchUniqueDiskImageFilePath(strTargetPath);683 i_searchUniqueDiskImageFilePath(strTargetPath); 695 684 696 685 /* find the description for the hard disk controller 697 686 * that has the same ID as hd.idController */ 698 687 const VirtualSystemDescriptionEntry *pController; 699 if (!(pController = pNewDesc-> findControllerFromID(hd.idController)))688 if (!(pController = pNewDesc->i_findControllerFromID(hd.idController))) 700 689 throw setError(E_FAIL, 701 690 tr("Cannot find disk controller with OVF instance ID %RI32 " … … 708 697 pController->ulIndex, 709 698 hd.ulAddressOnParent); 710 pNewDesc-> addEntry(VirtualSystemDescriptionType_HardDiskImage,711 hd.strDiskId,712 di.strHref,713 strTargetPath,714 di.ulSuggestedSizeMB,715 strExtraConfig);699 pNewDesc->i_addEntry(VirtualSystemDescriptionType_HardDiskImage, 700 hd.strDiskId, 701 di.strHref, 702 strTargetPath, 703 di.ulSuggestedSizeMB, 704 strExtraConfig); 716 705 } 717 706 else … … 743 732 * Public method implementation. This creates one or more new machines according to the 744 733 * VirtualSystemScription instances created by Appliance::Interpret(). 745 * Thread implementation is in Appliance::i mportImpl().734 * Thread implementation is in Appliance::i_importImpl(). 746 735 * @param aProgress 747 736 * @return 748 737 */ 749 STDMETHODIMP Appliance::ImportMachines(ComSafeArrayIn(ImportOptions_T, options), IProgress **aProgress) 738 HRESULT Appliance::importMachines(const std::vector<ImportOptions_T> &aOptions, 739 ComPtr<IProgress> &aProgress) 750 740 { 751 CheckComArgOutPointerValid(aProgress);752 753 AutoCaller autoCaller(this);754 if (FAILED(autoCaller.rc())) return autoCaller.rc();755 756 741 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 757 742 758 if (options != NULL) 759 m->optListImport = com::SafeArray<ImportOptions_T>(ComSafeArrayInArg(options)).toList(); 743 if (aOptions.size()) 744 { 745 m->optListImport.setCapacity(aOptions.size()); 746 for (size_t i = 0; i < aOptions.size(); ++i) 747 { 748 m->optListImport.insert(i, aOptions[i]); 749 } 750 } 760 751 761 752 AssertReturn(!(m->optListImport.contains(ImportOptions_KeepAllMACs) && m->optListImport.contains(ImportOptions_KeepNATMACs)), E_INVALIDARG); 762 753 763 754 // do not allow entering this method if the appliance is busy reading or writing 764 if (!i sApplianceIdle())755 if (!i_isApplianceIdle()) 765 756 return E_ACCESSDENIED; 766 757 767 758 if (!m->pReader) 768 759 return setError(E_FAIL, 769 tr("Cannot import machines without reading it first (call read() before i mportMachines())"));760 tr("Cannot import machines without reading it first (call read() before i_importMachines())")); 770 761 771 762 ComObjPtr<Progress> progress; … … 773 764 try 774 765 { 775 rc = i mportImpl(m->locInfo, progress);766 rc = i_importImpl(m->locInfo, progress); 776 767 } 777 768 catch (HRESULT aRC) … … 782 773 if (SUCCEEDED(rc)) 783 774 /* Return progress to the caller */ 784 progress.queryInterfaceTo(aProgress );775 progress.queryInterfaceTo(aProgress.asOutParam()); 785 776 786 777 return rc; … … 793 784 //////////////////////////////////////////////////////////////////////////////// 794 785 795 HRESULT Appliance:: preCheckImageAvailability(PSHASTORAGE pSHAStorage,786 HRESULT Appliance::i_preCheckImageAvailability(PSHASTORAGE pSHAStorage, 796 787 RTCString &availableImage) 797 788 { … … 836 827 * 1) from the public Appliance::Read(). 837 828 * 838 * 2) in a second worker thread; in that case, Appliance::ImportMachines() called Appliance::i mportImpl(), which839 * called Appliance::readFSOVA(), which called Appliance::i mportImpl(), which then called this again.829 * 2) in a second worker thread; in that case, Appliance::ImportMachines() called Appliance::i_importImpl(), which 830 * called Appliance::readFSOVA(), which called Appliance::i_importImpl(), which then called this again. 840 831 * 841 832 * 3) from Appliance::readS3(), which got called from a previous instance of Appliance::taskThreadImportOrExport(). … … 845 836 * @return 846 837 */ 847 HRESULT Appliance:: readImpl(const LocationInfo &aLocInfo, ComObjPtr<Progress> &aProgress)838 HRESULT Appliance::i_readImpl(const LocationInfo &aLocInfo, ComObjPtr<Progress> &aProgress) 848 839 { 849 840 BstrFmt bstrDesc = BstrFmt(tr("Reading appliance '%s'"), … … 895 886 * @return 896 887 */ 897 HRESULT Appliance:: readFS(TaskOVF *pTask)888 HRESULT Appliance::i_readFS(TaskOVF *pTask) 898 889 { 899 890 LogFlowFuncEnter(); … … 908 899 909 900 if (pTask->locInfo.strPath.endsWith(".ovf", Utf8Str::CaseInsensitive)) 910 rc = readFSOVF(pTask);901 rc = i_readFSOVF(pTask); 911 902 else 912 rc = readFSOVA(pTask);903 rc = i_readFSOVA(pTask); 913 904 914 905 LogFlowFunc(("rc=%Rhrc\n", rc)); … … 918 909 } 919 910 920 HRESULT Appliance:: readFSOVF(TaskOVF *pTask)911 HRESULT Appliance::i_readFSOVF(TaskOVF *pTask) 921 912 { 922 913 LogFlowFuncEnter(); … … 1009 1000 } 1010 1001 1011 Utf8Str name = applianceIOName(applianceIOFile);1002 Utf8Str name = i_applianceIOName(applianceIOFile); 1012 1003 1013 1004 vrc = VDInterfaceAdd(&pFileIo->Core, name.c_str(), … … 1017 1008 throw setError(VBOX_E_IPRT_ERROR, "Creation of the VD interface failed (%Rrc)", vrc); 1018 1009 1019 rc = readFSImpl(pTask, pTask->locInfo.strPath, pShaIo, &storage);1010 rc = i_readFSImpl(pTask, pTask->locInfo.strPath, pShaIo, &storage); 1020 1011 if (FAILED(rc)) 1021 1012 break; … … 1031 1022 { 1032 1023 storage.fCreateDigest = false; 1033 rc = readFSImpl(pTask, pTask->locInfo.strPath, pFileIo, &storage);1024 rc = i_readFSImpl(pTask, pTask->locInfo.strPath, pFileIo, &storage); 1034 1025 if (FAILED(rc)) 1035 1026 break; … … 1055 1046 } 1056 1047 1057 HRESULT Appliance:: readFSOVA(TaskOVF *pTask)1048 HRESULT Appliance::i_readFSOVA(TaskOVF *pTask) 1058 1049 { 1059 1050 LogFlowFuncEnter(); … … 1112 1103 } 1113 1104 1114 Utf8Str name = applianceIOName(applianceIOTar);1105 Utf8Str name = i_applianceIOName(applianceIOTar); 1115 1106 1116 1107 vrc = VDInterfaceAdd(&pTarIo->Core, name.c_str(), … … 1123 1114 } 1124 1115 1125 rc = readFSImpl(pTask, pszFilename, pShaIo, &storage);1116 rc = i_readFSImpl(pTask, pszFilename, pShaIo, &storage); 1126 1117 if (FAILED(rc)) 1127 1118 break; … … 1148 1139 } 1149 1140 1150 HRESULT Appliance:: readFSImpl(TaskOVF *pTask, const RTCString &strFilename, PVDINTERFACEIO pIfIo, PSHASTORAGE pStorage)1141 HRESULT Appliance::i_readFSImpl(TaskOVF *pTask, const RTCString &strFilename, PVDINTERFACEIO pIfIo, PSHASTORAGE pStorage) 1151 1142 { 1152 1143 LogFlowFuncEnter(); … … 1235 1226 * @return 1236 1227 */ 1237 HRESULT Appliance:: readS3(TaskOVF *pTask)1228 HRESULT Appliance::i_readS3(TaskOVF *pTask) 1238 1229 { 1239 1230 LogFlowFuncEnter(); … … 1260 1251 Utf8Str tmpPath = pTask->locInfo.strPath; 1261 1252 Utf8Str bucket; 1262 parseBucket(tmpPath, bucket);1253 i_parseBucket(tmpPath, bucket); 1263 1254 1264 1255 /* We need a temporary directory which we can put the OVF file & all … … 1315 1306 li.strPath = strTmpOvf; 1316 1307 /* Start the reading from the fs */ 1317 rc = readImpl(li, progress);1308 rc = i_readImpl(li, progress); 1318 1309 if (FAILED(rc)) throw rc; 1319 1310 … … 1323 1314 caller */ 1324 1315 ComPtr<IProgress> progressInt(progress); 1325 waitForAsyncProgress(pTask->pProgress, progressInt); /* Any errors will be thrown */1316 i_waitForAsyncProgress(pTask->pProgress, progressInt); /* Any errors will be thrown */ 1326 1317 1327 1318 /* Again lock the appliance for the next steps */ … … 1374 1365 * 1375 1366 * 1) from the public Appliance::ImportMachines(). 1376 * 2) from Appliance::i mportS3(), which got called from a previous instance of Appliance::taskThreadImportOrExport().1367 * 2) from Appliance::i_importS3(), which got called from a previous instance of Appliance::taskThreadImportOrExport(). 1377 1368 * 1378 1369 * @param aLocInfo … … 1380 1371 * @return 1381 1372 */ 1382 HRESULT Appliance::i mportImpl(const LocationInfo &locInfo,1383 ComObjPtr<Progress> &progress)1373 HRESULT Appliance::i_importImpl(const LocationInfo &locInfo, 1374 ComObjPtr<Progress> &progress) 1384 1375 { 1385 1376 HRESULT rc = S_OK; … … 1391 1382 mode = ImportS3; 1392 1383 1393 rc = setUpProgress(progress,1394 BstrFmt(tr("Importing appliance '%s'"), locInfo.strPath.c_str()),1395 mode);1384 rc = i_setUpProgress(progress, 1385 BstrFmt(tr("Importing appliance '%s'"), locInfo.strPath.c_str()), 1386 mode); 1396 1387 if (FAILED(rc)) throw rc; 1397 1388 … … 1415 1406 * This runs in three contexts: 1416 1407 * 1417 * 1) in a first worker thread; in that case, Appliance::ImportMachines() called Appliance::i mportImpl();1408 * 1) in a first worker thread; in that case, Appliance::ImportMachines() called Appliance::i_importImpl(); 1418 1409 * 1419 * 2) in a second worker thread; in that case, Appliance::ImportMachines() called Appliance::i mportImpl(), which1420 * called Appliance::i mportFSOVA(), which called Appliance::importImpl(), which then called this again.1410 * 2) in a second worker thread; in that case, Appliance::ImportMachines() called Appliance::i_importImpl(), which 1411 * called Appliance::i_i_importFSOVA(), which called Appliance::i_importImpl(), which then called this again. 1421 1412 * 1422 * 3) in a second worker thread; in that case, Appliance::ImportMachines() called Appliance::i mportImpl(), which1423 * called Appliance::i mportS3(), which called Appliance::importImpl(), which then called this again.1413 * 3) in a second worker thread; in that case, Appliance::ImportMachines() called Appliance::i_importImpl(), which 1414 * called Appliance::i_importS3(), which called Appliance::i_importImpl(), which then called this again. 1424 1415 * 1425 1416 * @param pTask 1426 1417 * @return 1427 1418 */ 1428 HRESULT Appliance::i mportFS(TaskOVF *pTask)1419 HRESULT Appliance::i_importFS(TaskOVF *pTask) 1429 1420 { 1430 1421 1431 1422 LogFlowFuncEnter(); 1432 1423 LogFlowFunc(("Appliance %p\n", this)); 1433 1434 AutoCaller autoCaller(this);1435 if (FAILED(autoCaller.rc())) return autoCaller.rc();1436 1424 1437 1425 /* Change the appliance state so we can safely leave the lock while doing … … 1440 1428 AutoWriteLock writeLock(this COMMA_LOCKVAL_SRC_POS); 1441 1429 /* Check if the appliance is currently busy. */ 1442 if (!i sApplianceIdle())1430 if (!i_isApplianceIdle()) 1443 1431 return E_ACCESSDENIED; 1444 1432 /* Set the internal state to importing. */ … … 1451 1439 1452 1440 if (pTask->locInfo.strPath.endsWith(".ovf", Utf8Str::CaseInsensitive)) 1453 rc = i mportFSOVF(pTask, writeLock);1441 rc = i_importFSOVF(pTask, writeLock); 1454 1442 else 1455 rc = i mportFSOVA(pTask, writeLock);1443 rc = i_importFSOVA(pTask, writeLock); 1456 1444 1457 1445 if (FAILED(rc)) … … 1489 1477 } 1490 1478 1491 HRESULT Appliance::i mportFSOVF(TaskOVF *pTask, AutoWriteLockBase& writeLock)1479 HRESULT Appliance::i_importFSOVF(TaskOVF *pTask, AutoWriteLockBase& writeLock) 1492 1480 { 1493 1481 LogFlowFuncEnter(); … … 1512 1500 RT_ZERO(storage); 1513 1501 1514 Utf8Str name = applianceIOName(applianceIOFile);1502 Utf8Str name = i_applianceIOName(applianceIOFile); 1515 1503 1516 1504 int vrc = VDInterfaceAdd(&pFileIo->Core, name.c_str(), … … 1529 1517 throw setError(E_OUTOFMEMORY); 1530 1518 1531 Utf8Str nameSha = applianceIOName(applianceIOSha);1519 Utf8Str nameSha = i_applianceIOName(applianceIOSha); 1532 1520 /* Fill out interface descriptor. */ 1533 1521 pShaIo->Core.u32Magic = VDINTERFACE_MAGIC; … … 1543 1531 1544 1532 /* Now import the appliance. */ 1545 i mportMachines(stack, pShaIo, &storage);1533 i_importMachines(stack, pShaIo, &storage); 1546 1534 /* Read & verify the manifest file. */ 1547 1535 /* Add the ovf file to the digest list. */ 1548 1536 stack.llSrcDisksDigest.push_front(STRPAIR(pTask->locInfo.strPath, m->strOVFSHADigest)); 1549 rc = readFileToBuf(strMfFile, &pvMfBuf, &cbMfSize, true, pShaIo, &storage);1537 rc = i_readFileToBuf(strMfFile, &pvMfBuf, &cbMfSize, true, pShaIo, &storage); 1550 1538 if (FAILED(rc)) throw rc; 1551 rc = verifyManifestFile(strMfFile, stack, pvMfBuf, cbMfSize);1539 rc = i_verifyManifestFile(strMfFile, stack, pvMfBuf, cbMfSize); 1552 1540 if (FAILED(rc)) throw rc; 1553 1541 … … 1560 1548 if (RTFileExists(strCertFile.c_str())) 1561 1549 { 1562 rc = readFileToBuf(strCertFile, &pvCertBuf, &cbCertSize, false, pShaIo, &storage);1550 rc = i_readFileToBuf(strCertFile, &pvCertBuf, &cbCertSize, false, pShaIo, &storage); 1563 1551 if (FAILED(rc)) throw rc; 1564 1552 … … 1569 1557 { 1570 1558 storage.fCreateDigest = false; 1571 i mportMachines(stack, pFileIo, &storage);1559 i_importMachines(stack, pFileIo, &storage); 1572 1560 } 1573 1561 } … … 1594 1582 } 1595 1583 1596 HRESULT Appliance::i mportFSOVA(TaskOVF *pTask, AutoWriteLockBase& writeLock)1584 HRESULT Appliance::i_importFSOVA(TaskOVF *pTask, AutoWriteLockBase& writeLock) 1597 1585 { 1598 1586 LogFlowFuncEnter(); … … 1630 1618 RT_ZERO(storage); 1631 1619 1632 Utf8Str nameTar = applianceIOName(applianceIOTar);1620 Utf8Str nameTar = i_applianceIOName(applianceIOTar); 1633 1621 1634 1622 vrc = VDInterfaceAdd(&pTarIo->Core, nameTar.c_str(), … … 1639 1627 tr("Creation of the VD interface failed (%Rrc)"), vrc); 1640 1628 1641 Utf8Str nameSha = applianceIOName(applianceIOSha);1629 Utf8Str nameSha = i_applianceIOName(applianceIOSha); 1642 1630 /* Fill out interface descriptor. */ 1643 1631 pShaIo->Core.u32Magic = VDINTERFACE_MAGIC; … … 1711 1699 * If it fails here, we will try it again after all disks where read. 1712 1700 */ 1713 rc = readTarFileToBuf(tar, strMfFile, &pvMfBuf, &cbMfSize, true, pCallbacks, pStorage);1701 rc = i_readTarFileToBuf(tar, strMfFile, &pvMfBuf, &cbMfSize, true, pCallbacks, pStorage); 1714 1702 if (FAILED(rc)) throw rc; 1715 1703 … … 1726 1714 if (strCertFile.compare(pszFilename) == 0) 1727 1715 { 1728 rc = readTarFileToBuf(tar, strCertFile, &pvCertBuf, &cbCertSize, false, pCallbacks, pStorage);1716 rc = i_readTarFileToBuf(tar, strCertFile, &pvCertBuf, &cbCertSize, false, pCallbacks, pStorage); 1729 1717 if (FAILED(rc)) throw rc; 1730 1718 … … 1738 1726 1739 1727 /* Now import the appliance. */ 1740 i mportMachines(stack, pCallbacks, pStorage);1728 i_importMachines(stack, pCallbacks, pStorage); 1741 1729 /* Try to read the manifest file. Second try. */ 1742 1730 if (!pvMfBuf) 1743 1731 { 1744 rc = readTarFileToBuf(tar, strMfFile, &pvMfBuf, &cbMfSize, true, pCallbacks, pStorage);1732 rc = i_readTarFileToBuf(tar, strMfFile, &pvMfBuf, &cbMfSize, true, pCallbacks, pStorage); 1745 1733 if (FAILED(rc)) throw rc; 1746 1734 … … 1750 1738 /* Add the ovf file to the digest list. */ 1751 1739 stack.llSrcDisksDigest.push_front(STRPAIR(OVFfilename, m->strOVFSHADigest)); 1752 rc = verifyManifestFile(strMfFile, stack, pvMfBuf, cbMfSize);1740 rc = i_verifyManifestFile(strMfFile, stack, pvMfBuf, cbMfSize); 1753 1741 if (FAILED(rc)) throw rc; 1754 1742 … … 1763 1751 if (strCertFile.compare(pszFilename) == 0) 1764 1752 { 1765 rc = readTarFileToBuf(tar, strCertFile, &pvCertBuf, &cbCertSize, false, pCallbacks, pStorage);1753 rc = i_readTarFileToBuf(tar, strCertFile, &pvCertBuf, &cbCertSize, false, pCallbacks, pStorage); 1766 1754 if (FAILED(rc)) throw rc; 1767 1755 … … 1805 1793 * Worker code for importing OVF from the cloud. This is called from Appliance::taskThreadImportOrExport() 1806 1794 * in S3 mode and therefore runs on the OVF import worker thread. This then starts a second worker 1807 * thread to import from temporary files (see Appliance::i mportFS()).1795 * thread to import from temporary files (see Appliance::i_importFS()). 1808 1796 * @param pTask 1809 1797 * @return 1810 1798 */ 1811 HRESULT Appliance::i mportS3(TaskOVF *pTask)1799 HRESULT Appliance::i_importS3(TaskOVF *pTask) 1812 1800 { 1813 1801 LogFlowFuncEnter(); 1814 1802 LogFlowFunc(("Appliance %p\n", this)); 1815 1816 AutoCaller autoCaller(this);1817 if (FAILED(autoCaller.rc())) return autoCaller.rc();1818 1803 1819 1804 AutoWriteLock appLock(this COMMA_LOCKVAL_SRC_POS); … … 1833 1818 Utf8Str tmpPath = pTask->locInfo.strPath; 1834 1819 Utf8Str bucket; 1835 parseBucket(tmpPath, bucket);1820 i_parseBucket(tmpPath, bucket); 1836 1821 1837 1822 /* We need a temporary directory which we can put the all disk images … … 1849 1834 { 1850 1835 ComObjPtr<VirtualSystemDescription> vsdescThis = (*it); 1851 std::list<VirtualSystemDescriptionEntry*> avsdeHDs = vsdescThis-> findByType(VirtualSystemDescriptionType_HardDiskImage);1836 std::list<VirtualSystemDescriptionEntry*> avsdeHDs = vsdescThis->i_findByType(VirtualSystemDescriptionType_HardDiskImage); 1852 1837 std::list<VirtualSystemDescriptionEntry*>::const_iterator itH; 1853 1838 for (itH = avsdeHDs.begin(); … … 1951 1936 LocationInfo li; 1952 1937 li.strPath = strTmpOvf; 1953 rc = i mportImpl(li, progress);1938 rc = i_importImpl(li, progress); 1954 1939 if (FAILED(rc)) throw rc; 1955 1940 … … 1959 1944 caller */ 1960 1945 ComPtr<IProgress> progressInt(progress); 1961 waitForAsyncProgress(pTask->pProgress, progressInt); /* Any errors will be thrown */1946 i_waitForAsyncProgress(pTask->pProgress, progressInt); /* Any errors will be thrown */ 1962 1947 1963 1948 /* Again lock the appliance for the next steps */ … … 2000 1985 #endif /* VBOX_WITH_S3 */ 2001 1986 2002 HRESULT Appliance:: readFileToBuf(const Utf8Str &strFile,2003 void **ppvBuf,2004 size_t *pcbSize,2005 bool fCreateDigest,2006 PVDINTERFACEIO pCallbacks,2007 PSHASTORAGE pStorage)1987 HRESULT Appliance::i_readFileToBuf(const Utf8Str &strFile, 1988 void **ppvBuf, 1989 size_t *pcbSize, 1990 bool fCreateDigest, 1991 PVDINTERFACEIO pCallbacks, 1992 PSHASTORAGE pStorage) 2008 1993 { 2009 1994 HRESULT rc = S_OK; … … 2022 2007 } 2023 2008 2024 HRESULT Appliance:: readTarFileToBuf(RTTAR tar,2025 const Utf8Str &strFile,2026 void **ppvBuf,2027 size_t *pcbSize,2028 bool fCreateDigest,2029 PVDINTERFACEIO pCallbacks,2030 PSHASTORAGE pStorage)2009 HRESULT Appliance::i_readTarFileToBuf(RTTAR tar, 2010 const Utf8Str &strFile, 2011 void **ppvBuf, 2012 size_t *pcbSize, 2013 bool fCreateDigest, 2014 PVDINTERFACEIO pCallbacks, 2015 PSHASTORAGE pStorage) 2031 2016 { 2032 2017 HRESULT rc = S_OK; … … 2046 2031 { 2047 2032 if (!strcmp(pszCurFile, RTPathFilename(strFile.c_str()))) 2048 rc = readFileToBuf(strFile, ppvBuf, pcbSize, fCreateDigest, pCallbacks, pStorage);2033 rc = i_readFileToBuf(strFile, ppvBuf, pcbSize, fCreateDigest, pCallbacks, pStorage); 2049 2034 RTStrFree(pszCurFile); 2050 2035 } … … 2056 2041 } 2057 2042 2058 HRESULT Appliance:: verifyManifestFile(const Utf8Str &strFile, ImportStack &stack, void *pvBuf, size_t cbSize)2043 HRESULT Appliance::i_verifyManifestFile(const Utf8Str &strFile, ImportStack &stack, void *pvBuf, size_t cbSize) 2059 2044 { 2060 2045 HRESULT rc = S_OK; … … 2099 2084 * @param lDevice out: the device number to attach to. 2100 2085 */ 2101 void Appliance:: convertDiskAttachmentValues(const ovf::HardDiskController &hdc,2086 void Appliance::i_convertDiskAttachmentValues(const ovf::HardDiskController &hdc, 2102 2087 uint32_t ulAddressOnParent, 2103 2088 Bstr &controllerType, … … 2105 2090 int32_t &lDevice) 2106 2091 { 2107 Log(("Appliance:: convertDiskAttachmentValues: hdc.system=%d, hdc.fPrimary=%d, ulAddressOnParent=%d\n",2092 Log(("Appliance::i_convertDiskAttachmentValues: hdc.system=%d, hdc.fPrimary=%d, ulAddressOnParent=%d\n", 2108 2093 hdc.system, 2109 2094 hdc.fPrimary, … … 2181 2166 else 2182 2167 controllerType = Bstr("SCSI Controller"); 2183 2184 2168 lControllerPort = (long)ulAddressOnParent; 2185 2169 lDevice = (long)0; … … 2195 2179 /** 2196 2180 * Imports one disk image. This is common code shared between 2197 * -- i mportMachineGeneric() for the OVF case; in that case the information comes from2181 * -- i_importMachineGeneric() for the OVF case; in that case the information comes from 2198 2182 * the OVF virtual systems; 2199 * -- i mportVBoxMachine(); in that case, the information comes from the <vbox:Machine>2183 * -- i_importVBoxMachine(); in that case, the information comes from the <vbox:Machine> 2200 2184 * tag. 2201 2185 * … … 2214 2198 * @param stack 2215 2199 */ 2216 void Appliance::i mportOneDiskImage(const ovf::DiskImage &di,2217 Utf8Str *strTargetPath,2218 ComObjPtr<Medium> &pTargetHD,2219 ImportStack &stack,2220 PVDINTERFACEIO pCallbacks,2221 PSHASTORAGE pStorage)2200 void Appliance::i_importOneDiskImage(const ovf::DiskImage &di, 2201 Utf8Str *strTargetPath, 2202 ComObjPtr<Medium> &pTargetHD, 2203 ImportStack &stack, 2204 PVDINTERFACEIO pCallbacks, 2205 PSHASTORAGE pStorage) 2222 2206 { 2223 2207 SHASTORAGE finalStorage; … … 2246 2230 2247 2231 /* Construct source file path */ 2248 Utf8Str name = applianceIOName(applianceIOTar);2232 Utf8Str name = i_applianceIOName(applianceIOTar); 2249 2233 2250 2234 if (RTStrNICmp(pStorage->pVDImageIfaces->pszInterfaceName, name.c_str(), name.length()) == 0) … … 2304 2288 throw setError(E_OUTOFMEMORY); 2305 2289 2306 name = applianceIOName(applianceIOFile);2290 name = i_applianceIOName(applianceIOFile); 2307 2291 2308 2292 vrc = VDInterfaceAdd(&pFileIo->Core, name.c_str(), … … 2449 2433 /* We need a proper source format description */ 2450 2434 /* Which format to use? */ 2451 ComObjPtr<MediumFormat> srcFormat; 2452 rc = findMediumFormatFromDiskImage(di, srcFormat);2435 ComObjPtr<MediumFormat> srcFormat; 2436 rc = i_findMediumFormatFromDiskImage(di, srcFormat); 2453 2437 if (FAILED(rc)) 2454 2438 throw setError(VBOX_E_NOT_SUPPORTED, … … 2468 2452 if (FAILED(rc)) throw rc; 2469 2453 2454 2455 2470 2456 /* Advance to the next operation. */ 2471 2457 /* operation's weight, as set up with the IProgress originally */ … … 2478 2464 * HRESULTs on error. */ 2479 2465 ComPtr<IProgress> pp(pProgress); 2480 waitForAsyncProgress(stack.pProgress, pp);2466 i_waitForAsyncProgress(stack.pProgress, pp); 2481 2467 2482 2468 if (fGzipUsed == true) … … 2523 2509 * @param stack Cleanup stack for when this throws. 2524 2510 */ 2525 void Appliance::i mportMachineGeneric(const ovf::VirtualSystem &vsysThis,2526 ComObjPtr<VirtualSystemDescription> &vsdescThis,2527 ComPtr<IMachine> &pNewMachine,2528 ImportStack &stack,2529 PVDINTERFACEIO pCallbacks,2530 PSHASTORAGE pStorage)2511 void Appliance::i_importMachineGeneric(const ovf::VirtualSystem &vsysThis, 2512 ComObjPtr<VirtualSystemDescription> &vsdescThis, 2513 ComPtr<IMachine> &pNewMachine, 2514 ImportStack &stack, 2515 PVDINTERFACEIO pCallbacks, 2516 PSHASTORAGE pStorage) 2531 2517 { 2532 2518 HRESULT rc; … … 2628 2614 uint32_t maxNetworkAdapters = Global::getMaxNetworkAdapters(ChipsetType_PIIX3); 2629 2615 2630 std::list<VirtualSystemDescriptionEntry*> vsdeNW = vsdescThis-> findByType(VirtualSystemDescriptionType_NetworkAdapter);2616 std::list<VirtualSystemDescriptionEntry*> vsdeNW = vsdescThis->i_findByType(VirtualSystemDescriptionType_NetworkAdapter); 2631 2617 if (vsdeNW.size() == 0) 2632 2618 { … … 2744 2730 if (FAILED(rc)) throw rc; 2745 2731 } 2732 2746 2733 /* Next test for NAT network interfaces */ 2747 2734 else if (pvsys->strExtraConfigCurrent.endsWith("type=NATNetwork", Utf8Str::CaseInsensitive)) … … 2769 2756 2770 2757 // IDE Hard disk controller 2771 std::list<VirtualSystemDescriptionEntry*> vsdeHDCIDE = vsdescThis-> findByType(VirtualSystemDescriptionType_HardDiskControllerIDE);2758 std::list<VirtualSystemDescriptionEntry*> vsdeHDCIDE = vsdescThis->i_findByType(VirtualSystemDescriptionType_HardDiskControllerIDE); 2772 2759 /* 2773 2760 * In OVF (at least VMware's version of it), an IDE controller has two ports, … … 2801 2788 2802 2789 /* Hard disk controller SATA */ 2803 std::list<VirtualSystemDescriptionEntry*> vsdeHDCSATA = vsdescThis-> findByType(VirtualSystemDescriptionType_HardDiskControllerSATA);2790 std::list<VirtualSystemDescriptionEntry*> vsdeHDCSATA = vsdescThis->i_findByType(VirtualSystemDescriptionType_HardDiskControllerSATA); 2804 2791 if (vsdeHDCSATA.size() > 1) 2805 2792 throw setError(VBOX_E_FILE_ERROR, … … 2823 2810 2824 2811 /* Hard disk controller SCSI */ 2825 std::list<VirtualSystemDescriptionEntry*> vsdeHDCSCSI = vsdescThis-> findByType(VirtualSystemDescriptionType_HardDiskControllerSCSI);2812 std::list<VirtualSystemDescriptionEntry*> vsdeHDCSCSI = vsdescThis->i_findByType(VirtualSystemDescriptionType_HardDiskControllerSCSI); 2826 2813 if (vsdeHDCSCSI.size() > 1) 2827 2814 throw setError(VBOX_E_FILE_ERROR, … … 2857 2844 2858 2845 /* Hard disk controller SAS */ 2859 std::list<VirtualSystemDescriptionEntry*> vsdeHDCSAS = vsdescThis-> findByType(VirtualSystemDescriptionType_HardDiskControllerSAS);2846 std::list<VirtualSystemDescriptionEntry*> vsdeHDCSAS = vsdescThis->i_findByType(VirtualSystemDescriptionType_HardDiskControllerSAS); 2860 2847 if (vsdeHDCSAS.size() > 1) 2861 2848 throw setError(VBOX_E_FILE_ERROR, … … 2884 2871 2885 2872 // Add floppies and CD-ROMs to the appropriate controllers. 2886 std::list<VirtualSystemDescriptionEntry*> vsdeFloppy = vsdescThis-> findByType(VirtualSystemDescriptionType_Floppy);2873 std::list<VirtualSystemDescriptionEntry*> vsdeFloppy = vsdescThis->i_findByType(VirtualSystemDescriptionType_Floppy); 2887 2874 if (vsdeFloppy.size() > 1) 2888 2875 throw setError(VBOX_E_FILE_ERROR, 2889 2876 tr("Too many floppy controllers in OVF; import facility only supports one")); 2890 std::list<VirtualSystemDescriptionEntry*> vsdeCDROM = vsdescThis-> findByType(VirtualSystemDescriptionType_CDROM);2877 std::list<VirtualSystemDescriptionEntry*> vsdeCDROM = vsdescThis->i_findByType(VirtualSystemDescriptionType_CDROM); 2891 2878 if ( (vsdeFloppy.size() > 0) 2892 2879 || (vsdeCDROM.size() > 0) … … 2962 2949 2963 2950 // create the hard disks & connect them to the appropriate controllers 2964 std::list<VirtualSystemDescriptionEntry*> avsdeHDs = vsdescThis-> findByType(VirtualSystemDescriptionType_HardDiskImage);2951 std::list<VirtualSystemDescriptionEntry*> avsdeHDs = vsdescThis->i_findByType(VirtualSystemDescriptionType_HardDiskImage); 2965 2952 if (avsdeHDs.size() > 0) 2966 2953 { … … 2975 2962 2976 2963 /* get VM name from virtual system description. Only one record is possible (size of list is equal 1). */ 2977 std::list<VirtualSystemDescriptionEntry*> vmName = vsdescThis-> findByType(VirtualSystemDescriptionType_Name);2964 std::list<VirtualSystemDescriptionEntry*> vmName = vsdescThis->i_findByType(VirtualSystemDescriptionType_Name); 2978 2965 std::list<VirtualSystemDescriptionEntry*>::iterator vmNameIt = vmName.begin(); 2979 2966 VirtualSystemDescriptionEntry* vmNameEntry = *vmNameIt; 2967 2980 2968 2981 2969 ovf::DiskImagesMap::const_iterator oit = stack.mapDisks.begin(); … … 3035 3023 */ 3036 3024 3037 Utf8Str name = applianceIOName(applianceIOTar);3025 Utf8Str name = i_applianceIOName(applianceIOTar); 3038 3026 3039 3027 if (strncmp(pStorage->pVDImageIfaces->pszInterfaceName, name.c_str(), name.length()) == 0) … … 3050 3038 RTCString availableImage(diCurrent.strHref); 3051 3039 3052 rc = preCheckImageAvailability(pStorage, 3053 availableImage 3054 ); 3040 rc = i_preCheckImageAvailability(pStorage, availableImage); 3055 3041 3056 3042 if (SUCCEEDED(rc)) … … 3073 3059 } 3074 3060 if (itDiskImage == stack.mapDisks.end()) 3061 { 3075 3062 throw setError(E_FAIL, 3076 3063 tr("Internal inconsistency looking up disk image '%s'. " 3077 3064 "Check compliance OVA package structure and file names " 3078 "references in the section <References> in the OVF file "),3065 "references in the section <References> in the OVF file."), 3079 3066 availableImage.c_str()); 3067 } 3080 3068 3081 3069 /* replace with a new found disk image */ … … 3101 3089 } 3102 3090 if (!vsdeTargetHD) 3091 { 3103 3092 /* 3104 3093 - * in this case it's an error because something wrong with OVF description file. 3105 3094 * May be VB imports OVA package with wrong file sequence inside the archive. 3106 3095 */ … … 3108 3097 tr("Internal inconsistency looking up disk image '%s'"), 3109 3098 diCurrent.strHref.c_str()); 3099 } 3110 3100 3111 3101 itVDisk = vsysThis.mapVirtualDisks.find(diCurrent.strDiskId); … … 3142 3132 Utf8Str savedVboxCurrent = vsdeTargetHD->strVboxCurrent; 3143 3133 3144 i mportOneDiskImage(diCurrent,3145 &vsdeTargetHD->strVboxCurrent,3146 pTargetHD,3147 stack,3148 pCallbacks,3149 pStorage);3134 i_importOneDiskImage(diCurrent, 3135 &vsdeTargetHD->strVboxCurrent, 3136 pTargetHD, 3137 stack, 3138 pCallbacks, 3139 pStorage); 3150 3140 3151 3141 // now use the new uuid to attach the disk image to our new machine … … 3162 3152 mhda.pMachine = pNewMachine; 3163 3153 3164 convertDiskAttachmentValues(hdc,3165 ovfVdisk.ulAddressOnParent,3166 mhda.controllerType, // Bstr3167 mhda.lControllerPort,3168 mhda.lDevice);3154 i_convertDiskAttachmentValues(hdc, 3155 ovfVdisk.ulAddressOnParent, 3156 mhda.controllerType, // Bstr 3157 mhda.lControllerPort, 3158 mhda.lDevice); 3169 3159 3170 3160 Log(("Attaching disk %s to port %d on device %d\n", … … 3172 3162 3173 3163 ComObjPtr<MediumFormat> mediumFormat; 3174 rc = findMediumFormatFromDiskImage(diCurrent, mediumFormat);3164 rc = i_findMediumFormatFromDiskImage(diCurrent, mediumFormat); 3175 3165 if (FAILED(rc)) 3176 3166 throw rc; … … 3240 3230 // only now that we're done with all disks, close the session 3241 3231 rc = stack.pSession->UnlockMachine(); 3242 3243 3232 if (FAILED(rc)) 3244 3233 throw rc; 3245 3246 3234 stack.fSessionOpen = false; 3247 3235 } 3248 catch(HRESULT 3236 catch(HRESULT aRC) 3249 3237 { 3250 3238 com::ErrorInfo info; 3251 3252 3239 if (stack.fSessionOpen) 3253 3240 stack.pSession->UnlockMachine(); … … 3290 3277 * @param stack 3291 3278 */ 3292 void Appliance::i mportVBoxMachine(ComObjPtr<VirtualSystemDescription> &vsdescThis,3293 ComPtr<IMachine> &pReturnNewMachine,3294 ImportStack &stack,3295 PVDINTERFACEIO pCallbacks,3296 PSHASTORAGE pStorage)3279 void Appliance::i_importVBoxMachine(ComObjPtr<VirtualSystemDescription> &vsdescThis, 3280 ComPtr<IMachine> &pReturnNewMachine, 3281 ImportStack &stack, 3282 PVDINTERFACEIO pCallbacks, 3283 PSHASTORAGE pStorage) 3297 3284 { 3298 3285 Assert(vsdescThis->m->pConfig); … … 3378 3365 || (fKeepNATMACs && it1->mode == NetworkAttachmentType_NAT) 3379 3366 || (fKeepNATMACs && it1->mode == NetworkAttachmentType_NATNetwork))) 3380 Host:: generateMACAddress(it1->strMACAddress);3367 Host::i_generateMACAddress(it1->strMACAddress); 3381 3368 } 3382 3369 /* Now iterate over all network entries. */ 3383 std::list<VirtualSystemDescriptionEntry*> avsdeNWs = vsdescThis-> findByType(VirtualSystemDescriptionType_NetworkAdapter);3370 std::list<VirtualSystemDescriptionEntry*> avsdeNWs = vsdescThis->i_findByType(VirtualSystemDescriptionType_NetworkAdapter); 3384 3371 if (avsdeNWs.size() > 0) 3385 3372 { … … 3415 3402 3416 3403 /* Floppy controller */ 3417 bool fFloppy = vsdescThis-> findByType(VirtualSystemDescriptionType_Floppy).size() > 0;3404 bool fFloppy = vsdescThis->i_findByType(VirtualSystemDescriptionType_Floppy).size() > 0; 3418 3405 /* DVD controller */ 3419 bool fDVD = vsdescThis-> findByType(VirtualSystemDescriptionType_CDROM).size() > 0;3406 bool fDVD = vsdescThis->i_findByType(VirtualSystemDescriptionType_CDROM).size() > 0; 3420 3407 /* Iterate over all storage controller check the attachments and remove 3421 3408 * them when necessary. Also detect broken configs with more than one … … 3475 3462 * step 2: scan the machine config for media attachments 3476 3463 */ 3477 3478 3464 /* get VM name from virtual system description. Only one record is possible (size of list is equal 1). */ 3479 std::list<VirtualSystemDescriptionEntry*> vmName = vsdescThis-> findByType(VirtualSystemDescriptionType_Name);3465 std::list<VirtualSystemDescriptionEntry*> vmName = vsdescThis->i_findByType(VirtualSystemDescriptionType_Name); 3480 3466 std::list<VirtualSystemDescriptionEntry*>::iterator vmNameIt = vmName.begin(); 3481 3467 VirtualSystemDescriptionEntry* vmNameEntry = *vmNameIt; 3482 3468 3483 3469 /* Get all hard disk descriptions. */ 3484 std::list<VirtualSystemDescriptionEntry*> avsdeHDs = vsdescThis-> findByType(VirtualSystemDescriptionType_HardDiskImage);3470 std::list<VirtualSystemDescriptionEntry*> avsdeHDs = vsdescThis->i_findByType(VirtualSystemDescriptionType_HardDiskImage); 3485 3471 std::list<VirtualSystemDescriptionEntry*>::iterator avsdeHDsIt = avsdeHDs.begin(); 3486 3472 /* paranoia - if there is no 1:1 match do not try to repair. */ … … 3517 3503 } 3518 3504 } 3519 3520 3505 if (!vsdeTargetHD) 3521 3506 { … … 3534 3519 */ 3535 3520 3536 Utf8Str name = applianceIOName(applianceIOTar);3521 Utf8Str name = i_applianceIOName(applianceIOTar); 3537 3522 3538 3523 if (strncmp(pStorage->pVDImageIfaces->pszInterfaceName, name.c_str(), name.length()) == 0) … … 3549 3534 RTCString availableImage(diCurrent.strHref); 3550 3535 3551 rc = preCheckImageAvailability(pStorage, 3552 availableImage 3553 ); 3536 rc = i_preCheckImageAvailability(pStorage, availableImage); 3554 3537 3555 3538 if (SUCCEEDED(rc)) … … 3687 3670 Utf8Str savedVboxCurrent = vsdeTargetHD->strVboxCurrent; 3688 3671 ComObjPtr<Medium> pTargetHD; 3689 i mportOneDiskImage(diCurrent,3690 &vsdeTargetHD->strVboxCurrent,3691 pTargetHD,3692 stack,3693 pCallbacks,3694 pStorage);3672 i_importOneDiskImage(diCurrent, 3673 &vsdeTargetHD->strVboxCurrent, 3674 pTargetHD, 3675 stack, 3676 pCallbacks, 3677 pStorage); 3695 3678 3696 3679 Bstr hdId; 3697 3680 3698 3681 ComObjPtr<MediumFormat> mediumFormat; 3699 rc = findMediumFormatFromDiskImage(diCurrent, mediumFormat);3682 rc = i_findMediumFormatFromDiskImage(diCurrent, mediumFormat); 3700 3683 if (FAILED(rc)) 3701 3684 throw rc; … … 3753 3736 }// while(oit != stack.mapDisks.end()) 3754 3737 3738 3755 3739 /* 3756 3740 * quantity of the imported disks isn't equal to the size of the avsdeHDs list. … … 3790 3774 } 3791 3775 3792 void Appliance::i mportMachines(ImportStack &stack,3793 PVDINTERFACEIO pCallbacks,3794 PSHASTORAGE pStorage)3776 void Appliance::i_importMachines(ImportStack &stack, 3777 PVDINTERFACEIO pCallbacks, 3778 PSHASTORAGE pStorage) 3795 3779 { 3796 3780 HRESULT rc = S_OK; … … 3835 3819 3836 3820 // VM name 3837 std::list<VirtualSystemDescriptionEntry*> vsdeName = vsdescThis-> findByType(VirtualSystemDescriptionType_Name);3821 std::list<VirtualSystemDescriptionEntry*> vsdeName = vsdescThis->i_findByType(VirtualSystemDescriptionType_Name); 3838 3822 if (vsdeName.size() < 1) 3839 3823 throw setError(VBOX_E_FILE_ERROR, … … 3856 3840 // guest OS type 3857 3841 std::list<VirtualSystemDescriptionEntry*> vsdeOS; 3858 vsdeOS = vsdescThis-> findByType(VirtualSystemDescriptionType_OS);3842 vsdeOS = vsdescThis->i_findByType(VirtualSystemDescriptionType_OS); 3859 3843 if (vsdeOS.size() < 1) 3860 3844 throw setError(VBOX_E_FILE_ERROR, … … 3863 3847 3864 3848 // CPU count 3865 std::list<VirtualSystemDescriptionEntry*> vsdeCPU = vsdescThis-> findByType(VirtualSystemDescriptionType_CPU);3849 std::list<VirtualSystemDescriptionEntry*> vsdeCPU = vsdescThis->i_findByType(VirtualSystemDescriptionType_CPU); 3866 3850 if (vsdeCPU.size() != 1) 3867 3851 throw setError(VBOX_E_FILE_ERROR, tr("CPU count missing")); … … 3876 3860 3877 3861 // RAM 3878 std::list<VirtualSystemDescriptionEntry*> vsdeRAM = vsdescThis-> findByType(VirtualSystemDescriptionType_Memory);3862 std::list<VirtualSystemDescriptionEntry*> vsdeRAM = vsdescThis->i_findByType(VirtualSystemDescriptionType_Memory); 3879 3863 if (vsdeRAM.size() != 1) 3880 3864 throw setError(VBOX_E_FILE_ERROR, tr("RAM size missing")); … … 3883 3867 #ifdef VBOX_WITH_USB 3884 3868 // USB controller 3885 std::list<VirtualSystemDescriptionEntry*> vsdeUSBController = vsdescThis-> findByType(VirtualSystemDescriptionType_USBController);3869 std::list<VirtualSystemDescriptionEntry*> vsdeUSBController = vsdescThis->i_findByType(VirtualSystemDescriptionType_USBController); 3886 3870 // USB support is enabled if there's at least one such entry; to disable USB support, 3887 3871 // the type of the USB item would have been changed to "ignore" … … 3889 3873 #endif 3890 3874 // audio adapter 3891 std::list<VirtualSystemDescriptionEntry*> vsdeAudioAdapter = vsdescThis-> findByType(VirtualSystemDescriptionType_SoundCard);3875 std::list<VirtualSystemDescriptionEntry*> vsdeAudioAdapter = vsdescThis->i_findByType(VirtualSystemDescriptionType_SoundCard); 3892 3876 /* @todo: we support one audio adapter only */ 3893 3877 if (vsdeAudioAdapter.size() > 0) … … 3895 3879 3896 3880 // for the description of the new machine, always use the OVF entry, the user may have changed it in the import config 3897 std::list<VirtualSystemDescriptionEntry*> vsdeDescription = vsdescThis-> findByType(VirtualSystemDescriptionType_Description);3881 std::list<VirtualSystemDescriptionEntry*> vsdeDescription = vsdescThis->i_findByType(VirtualSystemDescriptionType_Description); 3898 3882 if (vsdeDescription.size()) 3899 3883 stack.strDescription = vsdeDescription.front()->strVboxCurrent; … … 3902 3886 if (vsdescThis->m->pConfig) 3903 3887 // vbox:Machine config 3904 i mportVBoxMachine(vsdescThis, pNewMachine, stack, pCallbacks, pStorage);3888 i_importVBoxMachine(vsdescThis, pNewMachine, stack, pCallbacks, pStorage); 3905 3889 else 3906 3890 // generic OVF config 3907 i mportMachineGeneric(vsysThis, vsdescThis, pNewMachine, stack, pCallbacks, pStorage);3891 i_importMachineGeneric(vsysThis, vsdescThis, pNewMachine, stack, pCallbacks, pStorage); 3908 3892 3909 3893 } // for (it = pAppliance->m->llVirtualSystems.begin() ... -
trunk/src/VBox/Main/src-server/DHCPServerImpl.cpp
r49673 r49742 267 267 268 268 m->GlobalDhcpOptions.insert(DhcpOptValuePair(aOption, aValue)); 269 269 270 270 /* Indirect way to understand that we're on NAT network */ 271 271 if (aOption == DhcpOpt_Router) 272 272 m->dhcp.setOption(NetworkServiceRunner::kNsrKeyNeedMain, "on"); 273 273 274 274 alock.release(); 275 275 -
trunk/src/VBox/Main/src-server/HostImpl.cpp
r49409 r49742 108 108 typedef SOLARISDVD *PSOLARISDVD; 109 109 110 111 110 112 #endif /* RT_OS_SOLARIS */ 111 113 … … 213 215 VBoxMainDriveInfo hostDrives; 214 216 #endif 217 215 218 /** @name Features that can be queried with GetProcessorFeature. 216 219 * @{ */ … … 231 234 }; 232 235 236 233 237 //////////////////////////////////////////////////////////////////////////////// 234 238 // … … 236 240 // 237 241 //////////////////////////////////////////////////////////////////////////////// 242 DEFINE_EMPTY_CTOR_DTOR(Host) 238 243 239 244 HRESULT Host::FinalConstruct() … … 290 295 291 296 #ifdef VBOX_WITH_RESOURCE_USAGE_API 292 registerMetrics(aParent->performanceCollector());297 i_registerMetrics(aParent->performanceCollector()); 293 298 #endif /* VBOX_WITH_RESOURCE_USAGE_API */ 294 299 /* Create the list of network interfaces so their metrics get registered. */ 295 updateNetIfList();300 i_updateNetIfList(); 296 301 297 302 m->hostDnsMonitorProxy.init(HostDnsMonitor::getHostDnsMonitor(), m->pParent); … … 466 471 #ifdef VBOX_WITH_RESOURCE_USAGE_API 467 472 PerformanceCollector *aCollector = m->pParent->performanceCollector(); 468 unregisterMetrics (aCollector);473 i_unregisterMetrics (aCollector); 469 474 #endif /* VBOX_WITH_RESOURCE_USAGE_API */ 470 475 /* … … 514 519 * @param drives address of result pointer 515 520 */ 516 STDMETHODIMP Host::COMGETTER(DVDDrives)(ComSafeArrayOut(IMedium *, aDrives)) 517 { 518 CheckComArgOutSafeArrayPointerValid(aDrives); 519 520 AutoCaller autoCaller(this); 521 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 522 521 522 HRESULT Host::getDVDDrives(std::vector<ComPtr<IMedium> > &aDVDDrives) 523 { 523 524 AutoWriteLock alock(m->pParent->getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS); 524 525 525 MediaList *pList; 526 HRESULT rc = getDrives(DeviceType_DVD, true /* fRefresh */, pList);526 HRESULT rc = i_getDrives(DeviceType_DVD, true /* fRefresh */, pList); 527 527 if (SUCCEEDED(rc)) 528 528 { 529 SafeIfaceArray<IMedium> array(*pList); 530 array.detachTo(ComSafeArrayOutArg(aDrives)); 529 aDVDDrives.resize(pList->size()); 530 size_t i = 0; 531 for (MediaList::const_iterator it= pList->begin(); it!= pList->end(); ++it, ++i) 532 { 533 (*it).queryInterfaceTo(aDVDDrives[i].asOutParam()); 534 } 531 535 } 532 536 … … 540 544 * @param drives address of result pointer 541 545 */ 542 STDMETHODIMP Host::COMGETTER(FloppyDrives)(ComSafeArrayOut(IMedium *, aDrives)) 543 { 544 CheckComArgOutPointerValid(aDrives); 545 546 AutoCaller autoCaller(this); 547 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 548 546 HRESULT Host::getFloppyDrives(std::vector<ComPtr<IMedium> > &aFloppyDrives) 547 { 549 548 AutoWriteLock alock(m->pParent->getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS); 550 549 551 550 MediaList *pList; 552 HRESULT rc = getDrives(DeviceType_Floppy, true /* fRefresh */, pList);551 HRESULT rc = i_getDrives(DeviceType_Floppy, true /* fRefresh */, pList); 553 552 if (SUCCEEDED(rc)) 554 553 { 555 SafeIfaceArray<IMedium> collection(*pList); 556 collection.detachTo(ComSafeArrayOutArg(aDrives)); 554 aFloppyDrives.resize(pList->size()); 555 size_t i = 0; 556 for (MediaList::const_iterator it = pList->begin(); it != pList->end(); ++it, ++i) 557 { 558 (*it).queryInterfaceTo(aFloppyDrives[i].asOutParam()); 559 } 557 560 } 558 561 … … 610 613 * @param drives address of result pointer 611 614 */ 612 STDMETHODIMP Host::COMGETTER(NetworkInterfaces)(ComSafeArrayOut(IHostNetworkInterface*, aNetworkInterfaces))615 HRESULT Host::getNetworkInterfaces(std::vector<ComPtr<IHostNetworkInterface> > &aNetworkInterfaces) 613 616 { 614 617 #if defined(RT_OS_WINDOWS) || defined(VBOX_WITH_NETFLT) /*|| defined(RT_OS_OS2)*/ 615 if (ComSafeArrayOutIsNull(aNetworkInterfaces))616 return E_POINTER;617 618 AutoCaller autoCaller(this);619 if (FAILED(autoCaller.rc())) return autoCaller.rc();620 621 618 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 622 619 # ifdef VBOX_WITH_HOSTNETIF_API 623 int rc = updateNetIfList();620 int rc = i_updateNetIfList(); 624 621 if (rc) 625 622 { 626 623 Log(("Failed to get host network interface list with rc=%Rrc\n", rc)); 627 624 } 628 629 SafeIfaceArray<IHostNetworkInterface> networkInterfaces (m->llNetIfs); 630 networkInterfaces.detachTo(ComSafeArrayOutArg(aNetworkInterfaces)); 625 aNetworkInterfaces.resize(m->llNetIfs.size()); 626 size_t i = 0; 627 for (HostNetworkInterfaceList::iterator it = m->llNetIfs.begin(); it != m->llNetIfs.end(); ++it, ++i) 628 { 629 (*it).queryInterfaceTo(aNetworkInterfaces[i].asOutParam()); 630 } 631 631 632 632 return S_OK; … … 793 793 } 794 794 795 STDMETHODIMP Host::COMGETTER(USBDevices)(ComSafeArrayOut(IHostUSBDevice*, aUSBDevices))795 HRESULT Host::getUSBDevices(std::vector<ComPtr<IHostUSBDevice> > &aUSBDevices) 796 796 { 797 797 #ifdef VBOX_WITH_USB 798 CheckComArgOutSafeArrayPointerValid(aUSBDevices);799 800 AutoCaller autoCaller(this);801 if (FAILED(autoCaller.rc())) return autoCaller.rc();802 803 798 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 804 805 HRESULT rc = checkUSBProxyService();799 aUSBDevices.resize(0); 800 HRESULT rc = i_checkUSBProxyService(); 806 801 if (FAILED(rc)) return rc; 807 808 return m->pUSBProxyService->getDeviceCollection(ComSafeArrayOutArg(aUSBDevices)); 802 SafeIfaceArray<IHostUSBDevice> resultArr; 803 rc = m->pUSBProxyService->getDeviceCollection(ComSafeArrayAsOutParam(resultArr)); 804 if (FAILED(rc)) return rc; 805 aUSBDevices.resize(resultArr.size()); 806 for (size_t i = 0; i < resultArr.size(); ++i) 807 { 808 ComObjPtr<IHostUSBDevice> iHu = static_cast<IHostUSBDevice *>(resultArr[i]); 809 iHu.queryInterfaceTo(aUSBDevices[i].asOutParam()); 810 } 811 812 return rc; 809 813 810 814 #else … … 812 816 * extended error info to indicate that USB is simply not available 813 817 * (w/o treating it as a failure), for example, as in OSE. */ 814 NOREF(aUSBDevice s);818 NOREF(aUSBDeviceFilters); 815 819 # ifndef RT_OS_WINDOWS 816 NOREF(aUSBDevice sSize);820 NOREF(aUSBDeviceFiltersSize); 817 821 # endif 818 822 ReturnComNotImplemented(); 819 823 #endif 820 } 821 824 return S_OK; 825 } 822 826 823 827 /** 824 828 * This method return the list of registered name servers 825 829 */ 826 STDMETHODIMP Host::COMGETTER(NameServers)(ComSafeArrayOut(BSTR, aNameServers)) 827 { 828 CheckComArgOutSafeArrayPointerValid(aNameServers); 829 830 AutoCaller autoCaller(this); 831 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 832 830 HRESULT Host::getNameServers(std::vector<com::Utf8Str> &aNameServers) 831 { 833 832 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 834 833 835 return m->hostDnsMonitorProxy.GetNameServers(ComSafeArrayOutArg(aNameServers)); 834 aNameServers.resize(0); 835 com::SafeArray<BSTR> resultArr; 836 resultArr.setNull(); 837 HRESULT rc = m->hostDnsMonitorProxy.COMGETTER(NameServers)(ComSafeArrayAsOutParam(resultArr)); 838 if (FAILED(rc)) return rc; 839 aNameServers.resize(resultArr.size()); 840 for (size_t i = 0; i < resultArr.size(); ++i) 841 { 842 aNameServers[i] = com::Utf8Str(resultArr[i]); 843 } 844 return rc; 836 845 } 837 846 … … 840 849 * This method returns the domain name of the host 841 850 */ 842 STDMETHODIMP Host::COMGETTER(DomainName)(BSTR *aDomainName) 843 { 851 HRESULT Host::getDomainName(com::Utf8Str &aDomainName) 852 { 853 BSTR bstr; 854 HRESULT rc = m->hostDnsMonitorProxy.COMGETTER(DomainName)(&bstr); 855 if SUCCEEDED(rc) 856 aDomainName = com::Utf8Str(bstr); 857 return rc; 844 858 /* XXX: note here should be synchronization with thread polling state 845 859 * changes in name resoving system on host */ 846 847 AutoCaller autoCaller(this);848 if (FAILED(autoCaller.rc())) return autoCaller.rc();849 850 return m->hostDnsMonitorProxy.GetDomainName(aDomainName);851 860 } 852 861 … … 855 864 * This method returns the search string. 856 865 */ 857 STDMETHODIMP Host::COMGETTER(SearchStrings)(ComSafeArrayOut(BSTR, aSearchStrings)) 858 { 859 CheckComArgOutSafeArrayPointerValid(aSearchStrings); 860 861 AutoCaller autoCaller(this); 862 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 863 866 HRESULT Host::getSearchStrings(std::vector<com::Utf8Str> &aSearchStrings) 867 { 864 868 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 865 866 return m->hostDnsMonitorProxy.GetSearchStrings(ComSafeArrayOutArg(aSearchStrings)); 867 } 868 869 870 STDMETHODIMP Host::COMGETTER(USBDeviceFilters)(ComSafeArrayOut(IHostUSBDeviceFilter*, aUSBDeviceFilters)) 869 com::SafeArray<BSTR> resultArr; 870 resultArr.setNull(); 871 HRESULT rc = m->hostDnsMonitorProxy.COMGETTER(SearchStrings)(ComSafeArrayAsOutParam(resultArr)); 872 if (FAILED(rc)) return rc; 873 aSearchStrings.resize(resultArr.size()); 874 for (size_t i = 0; i < resultArr.size(); ++i) 875 { 876 aSearchStrings[i] = com::Utf8Str(resultArr[i]); 877 } 878 return rc; 879 } 880 881 HRESULT Host::getUSBDeviceFilters(std::vector<ComPtr<IHostUSBDeviceFilter> > &aUSBDeviceFilters) 871 882 { 872 883 #ifdef VBOX_WITH_USB 873 CheckComArgOutSafeArrayPointerValid(aUSBDeviceFilters);874 875 AutoCaller autoCaller(this);876 if (FAILED(autoCaller.rc())) return autoCaller.rc();877 878 884 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 879 880 HRESULT rc = checkUSBProxyService();885 aUSBDeviceFilters.resize(0); 886 HRESULT rc = i_checkUSBProxyService(); 881 887 if (FAILED(rc)) return rc; 882 883 SafeIfaceArray<IHostUSBDeviceFilter> collection(m->llUSBDeviceFilters); 884 collection.detachTo(ComSafeArrayOutArg(aUSBDeviceFilters)); 888 aUSBDeviceFilters.resize(m->llUSBDeviceFilters.size()); 889 size_t i = 0; 890 for (USBDeviceFilterList::iterator it = m->llUSBDeviceFilters.begin(); it != m->llUSBDeviceFilters.end(); ++it, ++i) 891 { 892 (*it).queryInterfaceTo(aUSBDeviceFilters[i].asOutParam()); 893 } 885 894 886 895 return rc; … … 900 909 * Returns the number of installed logical processors 901 910 * 902 * @returns COMstatus code911 * @returns VBOX status code 903 912 * @param count address of result variable 904 913 */ 905 STDMETHODIMP Host::COMGETTER(ProcessorCount)(ULONG *aCount) 906 { 907 CheckComArgOutPointerValid(aCount); 914 915 HRESULT Host::getProcessorCount(ULONG *aCount) 916 { 908 917 // no locking required 909 918 … … 918 927 * @param count address of result variable 919 928 */ 920 STDMETHODIMP Host::COMGETTER(ProcessorOnlineCount)(ULONG *aCount) 921 { 922 CheckComArgOutPointerValid(aCount); 929 HRESULT Host::getProcessorOnlineCount(ULONG *aCount) 930 { 923 931 // no locking required 924 932 … … 933 941 * @param count address of result variable 934 942 */ 935 STDMETHODIMP Host::COMGETTER(ProcessorCoreCount)(ULONG *aCount) 936 { 937 CheckComArgOutPointerValid(aCount); 943 HRESULT Host::getProcessorCoreCount(ULONG *aCount) 944 { 938 945 // no locking required 939 946 … … 948 955 * @param count address of result variable 949 956 */ 950 STDMETHODIMP Host::COMGETTER(ProcessorOnlineCoreCount)(ULONG *aCount) 951 { 952 CheckComArgOutPointerValid(aCount); 957 HRESULT Host::getProcessorOnlineCoreCount(ULONG *aCount) 958 { 953 959 // no locking required 954 960 … … 964 970 * @param speed address of result variable, speed is 0 if unknown or aCpuId is invalid. 965 971 */ 966 STDMETHODIMP Host::GetProcessorSpeed(ULONG aCpuId, ULONG *aSpeed) 967 { 968 CheckComArgOutPointerValid(aSpeed); 972 HRESULT Host::getProcessorSpeed(ULONG aCpuId, 973 ULONG *aSpeed) 974 { 969 975 // no locking required 970 976 … … 980 986 * @param description address of result variable, empty string if not known or aCpuId is invalid. 981 987 */ 982 STDMETHODIMP Host::GetProcessorDescription(ULONG aCpuId, BSTR *aDescription) 983 { 984 CheckComArgOutPointerValid(aDescription); 988 HRESULT Host::getProcessorDescription(ULONG aCpuId, com::Utf8Str &aDescription) 989 { 985 990 // no locking required 986 991 987 992 char szCPUModel[80]; 993 szCPUModel[0] = *"\0"; 988 994 int vrc = RTMpGetDescription(aCpuId, szCPUModel, sizeof(szCPUModel)); 989 995 if (RT_FAILURE(vrc)) 990 996 return E_FAIL; /** @todo error reporting? */ 991 Bstr (szCPUModel).cloneTo(aDescription);997 aDescription = Utf8Str(szCPUModel); 992 998 return S_OK; 993 999 } … … 1000 1006 * @param address of supported bool result variable 1001 1007 */ 1002 STDMETHODIMP Host::GetProcessorFeature(ProcessorFeature_T aFeature, BOOL *aSupported)1008 HRESULT Host::getProcessorFeature(ProcessorFeature_T aFeature, BOOL *aSupported) 1003 1009 { 1004 1010 /* Validate input. */ 1005 CheckComArgOutPointerValid(aSupported);1006 1011 switch (aFeature) 1007 1012 { … … 1092 1097 * @param aValEDX Where to return EDX. 1093 1098 */ 1094 STDMETHODIMP Host::GetProcessorCPUIDLeaf(ULONG aCpuId, ULONG aLeaf, ULONG aSubLeaf, 1095 ULONG *aValEAX, ULONG *aValEBX, ULONG *aValECX, ULONG *aValEDX) 1096 { 1097 CheckComArgOutPointerValid(aValEAX); 1098 CheckComArgOutPointerValid(aValEBX); 1099 CheckComArgOutPointerValid(aValECX); 1100 CheckComArgOutPointerValid(aValEDX); 1099 HRESULT Host::getProcessorCPUIDLeaf(ULONG aCpuId, ULONG aLeaf, ULONG aSubLeaf, 1100 ULONG *aValEAX, ULONG *aValEBX, ULONG *aValECX, ULONG *aValEDX) 1101 { 1101 1102 // no locking required 1102 1103 … … 1124 1125 * @param size address of result variable 1125 1126 */ 1126 STDMETHODIMP Host::COMGETTER(MemorySize)(ULONG *aSize) 1127 { 1128 CheckComArgOutPointerValid(aSize); 1127 HRESULT Host::getMemorySize(ULONG *aSize) 1128 { 1129 1129 // no locking required 1130 1130 … … 1143 1143 * @param available address of result variable 1144 1144 */ 1145 STDMETHODIMP Host::COMGETTER(MemoryAvailable)(ULONG *aAvailable) 1146 { 1147 CheckComArgOutPointerValid(aAvailable); 1145 HRESULT Host::getMemoryAvailable(ULONG *aAvailable) 1146 { 1148 1147 // no locking required 1149 1148 … … 1162 1161 * @param os address of result variable 1163 1162 */ 1164 STDMETHODIMP Host::COMGETTER(OperatingSystem)(BSTR *aOs) 1165 { 1166 CheckComArgOutPointerValid(aOs); 1163 HRESULT Host::getOperatingSystem(com::Utf8Str &aOperatingSystem) 1164 { 1167 1165 // no locking required 1168 1166 … … 1171 1169 if (RT_FAILURE(vrc)) 1172 1170 return E_FAIL; /** @todo error reporting? */ 1173 Bstr (szOSName).cloneTo(aOs);1171 aOperatingSystem = Utf8Str(szOSName); 1174 1172 return S_OK; 1175 1173 } … … 1181 1179 * @param os address of result variable 1182 1180 */ 1183 STDMETHODIMP Host::COMGETTER(OSVersion)(BSTR *aVersion) 1184 { 1185 CheckComArgOutPointerValid(aVersion); 1181 HRESULT Host::getOSVersion(com::Utf8Str &aVersion) 1182 { 1186 1183 // no locking required 1187 1184 … … 1207 1204 } 1208 1205 1209 Bstr(szOSRelease).cloneTo(aVersion);1206 aVersion = szOSRelease; 1210 1207 return S_OK; 1211 1208 } … … 1217 1214 * @param time address of result variable 1218 1215 */ 1219 STDMETHODIMP Host::COMGETTER(UTCTime)(LONG64 *aUTCTime) 1220 { 1221 CheckComArgOutPointerValid(aUTCTime); 1216 HRESULT Host::getUTCTime(LONG64 *aUTCTime) 1217 { 1222 1218 // no locking required 1223 1219 … … 1228 1224 } 1229 1225 1230 STDMETHODIMP Host::COMGETTER(Acceleration3DAvailable)(BOOL *aSupported) 1231 { 1232 CheckComArgOutPointerValid(aSupported); 1233 AutoCaller autoCaller(this); 1234 HRESULT hrc = autoCaller.rc(); 1235 if (SUCCEEDED(hrc)) 1236 { 1237 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 1238 if (m->f3DAccelerationSupported != -1) 1239 *aSupported = m->f3DAccelerationSupported; 1240 else 1241 { 1242 alock.release(); 1226 1227 HRESULT Host::getAcceleration3DAvailable(BOOL *aSupported) 1228 { 1229 HRESULT hrc = S_OK; 1230 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 1231 if (m->f3DAccelerationSupported != -1) 1232 *aSupported = m->f3DAccelerationSupported; 1233 else 1234 { 1235 alock.release(); 1236 1243 1237 #ifdef VBOX_WITH_CROGL 1244 1238 bool fSupported = VBoxOglIs3DAccelerationSupported(); 1245 1239 #else 1246 bool fSupported = false; /* shoudn't get here, but just in case. */ 1247 #endif 1248 AutoWriteLock alock2(this COMMA_LOCKVAL_SRC_POS); 1249 m->f3DAccelerationSupported = fSupported; 1250 alock2.release(); 1251 1252 *aSupported = fSupported; 1253 } 1240 bool fSupported = false; /* shoudn't get here, but just in case. */ 1241 #endif 1242 AutoWriteLock alock2(this COMMA_LOCKVAL_SRC_POS); 1243 1244 m->f3DAccelerationSupported = fSupported; 1245 alock2.release(); 1246 *aSupported = fSupported; 1254 1247 } 1255 1248 … … 1261 1254 } 1262 1255 1263 STDMETHODIMP Host::CreateHostOnlyNetworkInterface(IHostNetworkInterface **aHostNetworkInterface, 1264 IProgress **aProgress) 1265 { 1266 CheckComArgOutPointerValid(aHostNetworkInterface); 1267 CheckComArgOutPointerValid(aProgress); 1268 1269 AutoCaller autoCaller(this); 1270 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1271 1256 HRESULT Host::createHostOnlyNetworkInterface(ComPtr<IHostNetworkInterface> &aHostInterface, 1257 ComPtr<IProgress> &aProgress) 1258 1259 { 1272 1260 #ifdef VBOX_WITH_HOSTNETIF_API 1273 1261 /* No need to lock anything. If there ever will - watch out, the function 1274 1262 * called below grabs the VirtualBox lock. */ 1275 1276 int r = NetIfCreateHostOnlyNetworkInterface(m->pParent, aHostNetworkInterface, aProgress); 1263 IHostNetworkInterface *iHn = static_cast<IHostNetworkInterface *>(aHostInterface); 1264 IProgress *iHn2 = static_cast<IProgress *>(aProgress); 1265 1266 int r = NetIfCreateHostOnlyNetworkInterface(m->pParent, &iHn, &iHn2); 1277 1267 if (RT_SUCCESS(r)) 1278 1268 { 1279 if (! *aHostNetworkInterface)1269 if (!iHn) 1280 1270 return setError(E_FAIL, 1281 1271 tr("Unable to create a host network interface")); … … 1284 1274 Bstr tmpAddr, tmpMask, tmpName; 1285 1275 HRESULT hrc; 1286 hrc = (*aHostNetworkInterface)->COMGETTER(Name)(tmpName.asOutParam());1276 hrc = aHostInterface->COMGETTER(Name)(tmpName.asOutParam()); 1287 1277 ComAssertComRCRet(hrc, hrc); 1288 hrc = (*aHostNetworkInterface)->COMGETTER(IPAddress)(tmpAddr.asOutParam());1278 hrc = aHostInterface->COMGETTER(IPAddress)(tmpAddr.asOutParam()); 1289 1279 ComAssertComRCRet(hrc, hrc); 1290 hrc = (*aHostNetworkInterface)->COMGETTER(NetworkMask)(tmpMask.asOutParam());1280 hrc = aHostInterface->COMGETTER(NetworkMask)(tmpMask.asOutParam()); 1291 1281 ComAssertComRCRet(hrc, hrc); 1292 1282 /* … … 1299 1289 hrc = m->pParent->SetExtraData(BstrFmt("HostOnly/%ls/IPAddress", 1300 1290 tmpName.raw()).raw(), 1301 tmpAddr.raw());1291 tmpAddr.raw()); 1302 1292 ComAssertComRCRet(hrc, hrc); 1303 1293 1304 1294 hrc = m->pParent->SetExtraData(BstrFmt("HostOnly/%ls/IPNetMask", 1305 1295 tmpName.raw()).raw(), 1306 tmpMask.raw());1296 tmpMask.raw()); 1307 1297 ComAssertComRCRet(hrc, hrc); 1308 1298 #endif … … 1315 1305 } 1316 1306 1317 STDMETHODIMP Host::RemoveHostOnlyNetworkInterface(IN_BSTR aId, 1318 IProgress **aProgress) 1319 { 1320 CheckComArgOutPointerValid(aProgress); 1321 1322 AutoCaller autoCaller(this); 1323 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1324 1307 HRESULT Host::removeHostOnlyNetworkInterface(const com::Guid &aId, 1308 ComPtr<IProgress> &aProgress) 1309 1310 { 1325 1311 #ifdef VBOX_WITH_HOSTNETIF_API 1326 1312 /* No need to lock anything, the code below does not touch the state … … 1334 1320 { 1335 1321 ComPtr<IHostNetworkInterface> iface; 1336 if (FAILED(FindHostNetworkInterfaceById(aId,1337 iface.asOutParam())))1322 rc = findHostNetworkInterfaceById(aId, iface); 1323 if (FAILED(rc)) 1338 1324 return setError(VBOX_E_OBJECT_NOT_FOUND, 1339 1325 tr("Host network interface with UUID {%RTuuid} does not exist"), … … 1343 1329 } 1344 1330 1345 int r = NetIfRemoveHostOnlyNetworkInterface(m->pParent, Guid(aId).ref(), aProgress); 1331 IProgress *iPr = static_cast<IProgress *>(aProgress); 1332 1333 int r = NetIfRemoveHostOnlyNetworkInterface(m->pParent, Guid(aId).ref(), &iPr); 1346 1334 if (RT_SUCCESS(r)) 1347 1335 { … … 1361 1349 } 1362 1350 1363 STDMETHODIMP Host::CreateUSBDeviceFilter(IN_BSTRaName,1364 IHostUSBDeviceFilter **aFilter)1351 HRESULT Host::createUSBDeviceFilter(const com::Utf8Str &aName, 1352 ComPtr<IHostUSBDeviceFilter> &aFilter) 1365 1353 { 1366 1354 #ifdef VBOX_WITH_USB 1367 CheckComArgStrNotEmptyOrNull(aName);1368 CheckComArgOutPointerValid(aFilter);1369 1370 AutoCaller autoCaller(this);1371 if (FAILED(autoCaller.rc())) return autoCaller.rc();1372 1355 1373 1356 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); … … 1375 1358 ComObjPtr<HostUSBDeviceFilter> filter; 1376 1359 filter.createObject(); 1377 HRESULT rc = filter->init(this, aName);1360 HRESULT rc = filter->init(this, Bstr(aName).raw()); 1378 1361 ComAssertComRCRet(rc, rc); 1379 rc = filter.queryInterfaceTo(aFilter );1362 rc = filter.queryInterfaceTo(aFilter.asOutParam()); 1380 1363 AssertComRCReturn(rc, rc); 1381 1364 return S_OK; … … 1390 1373 } 1391 1374 1392 STDMETHODIMP Host::InsertUSBDeviceFilter(ULONG aPosition,1393 IHostUSBDeviceFilter *aFilter)1375 HRESULT Host::insertUSBDeviceFilter(ULONG aPosition, 1376 const ComPtr<IHostUSBDeviceFilter> &aFilter) 1394 1377 { 1395 1378 #ifdef VBOX_WITH_USB 1396 CheckComArgNotNull(aFilter);1397 1398 1379 /* Note: HostUSBDeviceFilter and USBProxyService also uses this lock. */ 1399 AutoCaller autoCaller(this);1400 if (FAILED(autoCaller.rc())) return autoCaller.rc();1401 1380 1402 1381 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 1403 1382 1404 1383 clearError(); 1405 MultiResult rc = checkUSBProxyService();1384 MultiResult rc = i_checkUSBProxyService(); 1406 1385 if (FAILED(rc)) return rc; 1407 1386 … … 1445 1424 return rc = m->pParent->saveSettings(); 1446 1425 #else 1426 1447 1427 /* Note: The GUI depends on this method returning E_NOTIMPL with no 1448 1428 * extended error info to indicate that USB is simply not available … … 1454 1434 } 1455 1435 1456 STDMETHODIMP Host::RemoveUSBDeviceFilter(ULONG aPosition)1436 HRESULT Host::removeUSBDeviceFilter(ULONG aPosition) 1457 1437 { 1458 1438 #ifdef VBOX_WITH_USB 1459 1439 1460 1440 /* Note: HostUSBDeviceFilter and USBProxyService also uses this lock. */ 1461 AutoCaller autoCaller(this);1462 if (FAILED(autoCaller.rc())) return autoCaller.rc();1463 1464 1441 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 1465 1442 1466 1443 clearError(); 1467 MultiResult rc = checkUSBProxyService();1444 MultiResult rc = i_checkUSBProxyService(); 1468 1445 if (FAILED(rc)) return rc; 1469 1446 … … 1510 1487 } 1511 1488 1512 STDMETHODIMP Host::FindHostDVDDrive(IN_BSTR aName, IMedium **aDrive) 1513 { 1514 CheckComArgStrNotEmptyOrNull(aName); 1515 CheckComArgOutPointerValid(aDrive); 1489 HRESULT Host::findHostDVDDrive(const com::Utf8Str &aName, 1490 ComPtr<IMedium> &aDrive) 1491 { 1492 ComObjPtr<Medium> medium; 1493 HRESULT rc = i_findHostDriveByNameOrId(DeviceType_DVD, aName, medium); 1494 if (SUCCEEDED(rc)) 1495 rc = medium.queryInterfaceTo(aDrive.asOutParam()); 1496 else 1497 rc = setError(rc, Medium::tr("The host DVD drive named '%ls' could not be found"), Bstr(aName).raw()); 1498 return rc; 1499 } 1500 1501 HRESULT Host::findHostFloppyDrive(const com::Utf8Str &aName, ComPtr<IMedium> &aDrive) 1502 { 1503 aDrive = NULL; 1516 1504 1517 1505 ComObjPtr<Medium>medium; 1518 HRESULT rc = findHostDriveByNameOrId(DeviceType_DVD, Utf8Str(aName), medium); 1506 1507 HRESULT rc = i_findHostDriveByNameOrId(DeviceType_Floppy, aName, medium); 1519 1508 if (SUCCEEDED(rc)) 1520 return medium.queryInterfaceTo(aDrive );1509 return medium.queryInterfaceTo(aDrive.asOutParam()); 1521 1510 else 1522 return setError(rc, Medium::tr("The host DVD drive named '%ls' could not be found"), aName); 1523 } 1524 1525 STDMETHODIMP Host::FindHostFloppyDrive(IN_BSTR aName, IMedium **aDrive) 1526 { 1527 CheckComArgStrNotEmptyOrNull(aName); 1528 CheckComArgOutPointerValid(aDrive); 1529 1530 *aDrive = NULL; 1531 1532 ComObjPtr<Medium>medium; 1533 HRESULT rc = findHostDriveByNameOrId(DeviceType_Floppy, Utf8Str(aName), medium); 1534 if (SUCCEEDED(rc)) 1535 return medium.queryInterfaceTo(aDrive); 1536 else 1537 return setError(rc, Medium::tr("The host floppy drive named '%ls' could not be found"), aName); 1538 } 1539 1540 STDMETHODIMP Host::FindHostNetworkInterfaceByName(IN_BSTR name, IHostNetworkInterface **networkInterface) 1511 return setError(rc, Medium::tr("The host floppy drive named '%ls' could not be found"), Bstr(aName).raw()); 1512 } 1513 1514 HRESULT Host::findHostNetworkInterfaceByName(const com::Utf8Str &aName, 1515 ComPtr<IHostNetworkInterface> &aNetworkInterface) 1541 1516 { 1542 1517 #ifndef VBOX_WITH_HOSTNETIF_API 1543 1518 return E_NOTIMPL; 1544 1519 #else 1545 if (! name)1520 if (!aName.length()) 1546 1521 return E_INVALIDARG; 1547 if (! networkInterface)1522 if (!aNetworkInterface) 1548 1523 return E_POINTER; 1549 1524 1550 1525 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 1551 1526 1552 *networkInterface = NULL; 1527 aNetworkInterface = NULL; 1528 1553 1529 ComObjPtr<HostNetworkInterface> found; 1554 int rc = updateNetIfList();1530 int rc = i_updateNetIfList(); 1555 1531 if (RT_FAILURE(rc)) 1556 1532 { … … 1558 1534 return E_FAIL; 1559 1535 } 1560 HostNetworkInterfaceList::iterator it; 1561 for (it = m->llNetIfs.begin(); it != m->llNetIfs.end(); ++it) 1536 for (HostNetworkInterfaceList::iterator it = m->llNetIfs.begin(); it != m->llNetIfs.end(); ++it) 1562 1537 { 1563 1538 Bstr n; 1564 1539 (*it)->COMGETTER(Name) (n.asOutParam()); 1565 if (n == name)1540 if (n == aName) 1566 1541 found = *it; 1567 1542 } … … 1571 1546 HostNetworkInterface::tr("The host network interface with the given name could not be found")); 1572 1547 1573 return found.queryInterfaceTo(networkInterface); 1574 #endif 1575 } 1576 1577 STDMETHODIMP Host::FindHostNetworkInterfaceById(IN_BSTR id, IHostNetworkInterface **networkInterface) 1548 return found.queryInterfaceTo(aNetworkInterface.asOutParam()); 1549 #endif 1550 } 1551 1552 HRESULT Host::findHostNetworkInterfaceById(const com::Guid &aId, 1553 ComPtr<IHostNetworkInterface> &aNetworkInterface) 1578 1554 { 1579 1555 #ifndef VBOX_WITH_HOSTNETIF_API 1580 1556 return E_NOTIMPL; 1581 1557 #else 1582 if (! Guid(id).isValid())1558 if (!aId.isValid()) 1583 1559 return E_INVALIDARG; 1584 if (! networkInterface)1560 if (!aNetworkInterface) 1585 1561 return E_POINTER; 1586 1562 1587 1563 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 1588 1564 1589 *networkInterface = NULL; 1565 aNetworkInterface = NULL; 1566 1590 1567 ComObjPtr<HostNetworkInterface> found; 1591 int rc = updateNetIfList();1568 int rc = i_updateNetIfList(); 1592 1569 if (RT_FAILURE(rc)) 1593 1570 { … … 1600 1577 Bstr g; 1601 1578 (*it)->COMGETTER(Id) (g.asOutParam()); 1602 if ( g == id)1579 if (Guid(g) == aId) 1603 1580 found = *it; 1604 1581 } … … 1607 1584 return setError(E_INVALIDARG, 1608 1585 HostNetworkInterface::tr("The host network interface with the given GUID could not be found")); 1609 1610 return found.queryInterfaceTo(networkInterface); 1611 #endif 1612 } 1613 1614 STDMETHODIMP Host::FindHostNetworkInterfacesOfType(HostNetworkInterfaceType_T type,1615 ComSafeArrayOut(IHostNetworkInterface *, aNetworkInterfaces))1586 return found.queryInterfaceTo(aNetworkInterface.asOutParam()); 1587 1588 #endif 1589 } 1590 1591 HRESULT Host::findHostNetworkInterfacesOfType(HostNetworkInterfaceType_T aType, 1592 std::vector<ComPtr<IHostNetworkInterface> > &aNetworkInterfaces) 1616 1593 { 1617 1594 #ifdef VBOX_WITH_HOSTNETIF_API 1618 1595 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 1619 1596 1620 int rc = updateNetIfList();1597 int rc = i_updateNetIfList(); 1621 1598 if (RT_FAILURE(rc)) 1622 1599 return E_FAIL; … … 1624 1601 HostNetworkInterfaceList resultList; 1625 1602 1626 HostNetworkInterfaceList::iterator it; 1627 for (it = m->llNetIfs.begin(); it != m->llNetIfs.end(); ++it) 1603 for (HostNetworkInterfaceList::iterator it = m->llNetIfs.begin(); it != m->llNetIfs.end(); ++it) 1628 1604 { 1629 1605 HostNetworkInterfaceType_T t; … … 1632 1608 return hr; 1633 1609 1634 if (t == type) 1635 resultList.push_back (*it); 1636 } 1637 1638 SafeIfaceArray<IHostNetworkInterface> filteredNetworkInterfaces (resultList); 1639 filteredNetworkInterfaces.detachTo(ComSafeArrayOutArg(aNetworkInterfaces)); 1610 if (t == aType) 1611 resultList.push_back(*it); 1612 } 1613 aNetworkInterfaces.resize(resultList.size()); 1614 size_t i = 0; 1615 for (HostNetworkInterfaceList::iterator it = resultList.begin(); it != resultList.end(); ++it, ++i) 1616 { 1617 (*it).queryInterfaceTo(aNetworkInterfaces[i].asOutParam()); 1618 } 1640 1619 1641 1620 return S_OK; … … 1645 1624 } 1646 1625 1647 STDMETHODIMP Host::FindUSBDeviceByAddress(IN_BSTR aAddress,1648 IHostUSBDevice **aDevice)1626 HRESULT Host::findUSBDeviceByAddress(const com::Utf8Str &aName, 1627 ComPtr<IHostUSBDevice> &aDevice) 1649 1628 { 1650 1629 #ifdef VBOX_WITH_USB 1651 CheckComArgStrNotEmptyOrNull(aAddress); 1652 CheckComArgOutPointerValid(aDevice); 1653 1654 *aDevice = NULL; 1655 1630 1631 aDevice = NULL; 1656 1632 SafeIfaceArray<IHostUSBDevice> devsvec; 1657 1633 HRESULT rc = COMGETTER(USBDevices) (ComSafeArrayAsOutParam(devsvec)); … … 1663 1639 rc = devsvec[i]->COMGETTER(Address) (address.asOutParam()); 1664 1640 if (FAILED(rc)) return rc; 1665 if (address == aAddress) 1666 { 1667 return ComObjPtr<IHostUSBDevice> (devsvec[i]).queryInterfaceTo(aDevice); 1641 if (address == aName) 1642 { 1643 ComObjPtr<IHostUSBDevice> (devsvec[i]).queryInterfaceTo(aDevice.asOutParam()); 1644 return S_OK; 1668 1645 } 1669 1646 } … … 1671 1648 return setErrorNoLog(VBOX_E_OBJECT_NOT_FOUND, 1672 1649 tr("Could not find a USB device with address '%ls'"), 1673 aAddress);1650 Bstr(aName).raw()); 1674 1651 1675 1652 #else /* !VBOX_WITH_USB */ … … 1679 1656 #endif /* !VBOX_WITH_USB */ 1680 1657 } 1681 1682 STDMETHODIMP Host::FindUSBDeviceById(IN_BSTR aId, 1683 IHostUSBDevice **aDevice) 1658 HRESULT Host::findUSBDeviceById(const com::Guid &aId, 1659 ComPtr<IHostUSBDevice> &aDevice) 1684 1660 { 1685 1661 #ifdef VBOX_WITH_USB 1686 CheckComArgExpr(aId, Guid (aId).isValid());1687 CheckComArgOutPointerValid(aDevice);1688 1689 *aDevice = NULL;1662 if (!aId.isValid()) 1663 return E_INVALIDARG; 1664 1665 aDevice = NULL; 1690 1666 1691 1667 SafeIfaceArray<IHostUSBDevice> devsvec; … … 1698 1674 rc = devsvec[i]->COMGETTER(Id) (id.asOutParam()); 1699 1675 if (FAILED(rc)) return rc; 1700 if ( id== aId)1701 { 1702 return ComObjPtr<IHostUSBDevice> (devsvec[i]).queryInterfaceTo(aDevice);1703 }1704 }1705 1676 if (Guid(id) == aId) 1677 { 1678 ComObjPtr<IHostUSBDevice> (devsvec[i]).queryInterfaceTo(aDevice.asOutParam()); 1679 return rc; 1680 } 1681 } 1706 1682 return setErrorNoLog (VBOX_E_OBJECT_NOT_FOUND, tr ( 1707 1683 "Could not find a USB device with uuid {%RTuuid}"), 1708 Guid (aId).raw());1684 aId.raw()); 1709 1685 1710 1686 #else /* !VBOX_WITH_USB */ … … 1715 1691 } 1716 1692 1717 STDMETHODIMP Host::GenerateMACAddress(BSTR *aAddress) 1718 { 1719 CheckComArgOutPointerValid(aAddress); 1693 HRESULT Host::generateMACAddress(com::Utf8Str &aAddress) 1694 { 1720 1695 // no locking required 1721 Utf8Str mac; 1722 generateMACAddress(mac); 1723 Bstr(mac).cloneTo(aAddress); 1696 i_generateMACAddress(aAddress); 1724 1697 return S_OK; 1725 1698 } … … 1731 1704 * @param aVideoInputDevices Array of interface pointers to be filled. 1732 1705 */ 1733 STDMETHODIMP Host::COMGETTER(VideoInputDevices)(ComSafeArrayOut(IHostVideoInputDevice*, aVideoInputDevices)) 1734 { 1735 if (ComSafeArrayOutIsNull(aVideoInputDevices)) 1736 return E_POINTER; 1737 1738 AutoCaller autoCaller(this); 1739 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1740 1706 HRESULT Host::getVideoInputDevices(std::vector<ComPtr<IHostVideoInputDevice> > &aVideoInputDevices) 1707 { 1741 1708 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 1742 1709 HostVideoInputDeviceList list; … … 1746 1713 if (SUCCEEDED(hr)) 1747 1714 { 1748 SafeIfaceArray<IHostVideoInputDevice> devices(list); 1749 devices.detachTo(ComSafeArrayOutArg(aVideoInputDevices)); 1715 size_t i = 0; 1716 for (HostVideoInputDeviceList::const_iterator it = list.begin(); it != list.end(); ++it, ++i) 1717 { 1718 (*it).queryInterfaceTo(aVideoInputDevices[i].asOutParam()); 1719 } 1750 1720 } 1751 1721 … … 1756 1726 //////////////////////////////////////////////////////////////////////////////// 1757 1727 1758 HRESULT Host:: loadSettings(const settings::Host &data)1728 HRESULT Host::i_loadSettings(const settings::Host &data) 1759 1729 { 1760 1730 HRESULT rc = S_OK; … … 1791 1761 } 1792 1762 1793 HRESULT Host:: saveSettings(settings::Host &data)1763 HRESULT Host::i_saveSettings(settings::Host &data) 1794 1764 { 1795 1765 #ifdef VBOX_WITH_USB … … 1834 1804 * @return 1835 1805 */ 1836 HRESULT Host:: getDrives(DeviceType_T mediumType,1837 bool fRefresh,1838 MediaList *&pll)1806 HRESULT Host::i_getDrives(DeviceType_T mediumType, 1807 bool fRefresh, 1808 MediaList *&pll) 1839 1809 { 1840 1810 HRESULT rc = S_OK; … … 1850 1820 if (!m->fDVDDrivesListBuilt || fRefresh) 1851 1821 { 1852 rc = buildDVDDrivesList(llNew);1822 rc = i_buildDVDDrivesList(llNew); 1853 1823 if (FAILED(rc)) 1854 1824 return rc; … … 1861 1831 if (!m->fFloppyDrivesListBuilt || fRefresh) 1862 1832 { 1863 rc = buildFloppyDrivesList(llNew);1833 rc = i_buildFloppyDrivesList(llNew); 1864 1834 if (FAILED(rc)) 1865 1835 return rc; … … 1957 1927 * @return VBOX_E_OBJECT_NOT_FOUND if not found, or S_OK if found, or errors from getDrives(). 1958 1928 */ 1959 HRESULT Host:: findHostDriveById(DeviceType_T mediumType,1960 const Guid &uuid,1961 bool fRefresh,1962 ComObjPtr<Medium> &pMedium)1929 HRESULT Host::i_findHostDriveById(DeviceType_T mediumType, 1930 const Guid &uuid, 1931 bool fRefresh, 1932 ComObjPtr<Medium> &pMedium) 1963 1933 { 1964 1934 MediaList *pllMedia; 1965 1935 1966 1936 AutoWriteLock wlock(m->pParent->getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS); 1967 HRESULT rc = getDrives(mediumType, fRefresh, pllMedia);1937 HRESULT rc = i_getDrives(mediumType, fRefresh, pllMedia); 1968 1938 if (SUCCEEDED(rc)) 1969 1939 { … … 1997 1967 * @return VBOX_E_OBJECT_NOT_FOUND if not found, or S_OK if found, or errors from getDrives(). 1998 1968 */ 1999 HRESULT Host:: findHostDriveByName(DeviceType_T mediumType,2000 const Utf8Str &strLocationFull,2001 bool fRefresh,2002 ComObjPtr<Medium> &pMedium)1969 HRESULT Host::i_findHostDriveByName(DeviceType_T mediumType, 1970 const Utf8Str &strLocationFull, 1971 bool fRefresh, 1972 ComObjPtr<Medium> &pMedium) 2003 1973 { 2004 1974 MediaList *pllMedia; 2005 1975 2006 1976 AutoWriteLock wlock(m->pParent->getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS); 2007 HRESULT rc = getDrives(mediumType, fRefresh, pllMedia);1977 HRESULT rc = i_getDrives(mediumType, fRefresh, pllMedia); 2008 1978 if (SUCCEEDED(rc)) 2009 1979 { … … 2036 2006 * @return VBOX_E_OBJECT_NOT_FOUND if not found, or S_OK if found, or errors from getDrives(). 2037 2007 */ 2038 HRESULT Host:: findHostDriveByNameOrId(DeviceType_T mediumType,2039 const Utf8Str &strNameOrId,2040 ComObjPtr<Medium> &pMedium)2008 HRESULT Host::i_findHostDriveByNameOrId(DeviceType_T mediumType, 2009 const Utf8Str &strNameOrId, 2010 ComObjPtr<Medium> &pMedium) 2041 2011 { 2042 2012 AutoWriteLock wlock(m->pParent->getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS); … … 2044 2014 Guid uuid(strNameOrId); 2045 2015 if (uuid.isValid() && !uuid.isZero()) 2046 return findHostDriveById(mediumType, uuid, true /* fRefresh */, pMedium);2016 return i_findHostDriveById(mediumType, uuid, true /* fRefresh */, pMedium); 2047 2017 2048 2018 // string is not a syntactically valid UUID: try a name then 2049 return findHostDriveByName(mediumType, strNameOrId, true /* fRefresh */, pMedium);2019 return i_findHostDriveByName(mediumType, strNameOrId, true /* fRefresh */, pMedium); 2050 2020 } 2051 2021 … … 2055 2025 * @return 2056 2026 */ 2057 HRESULT Host:: buildDVDDrivesList(MediaList &list)2027 HRESULT Host::i_buildDVDDrivesList(MediaList &list) 2058 2028 { 2059 2029 HRESULT rc = S_OK; … … 2137 2107 * @return 2138 2108 */ 2139 HRESULT Host:: buildFloppyDrivesList(MediaList &list)2109 HRESULT Host::i_buildFloppyDrivesList(MediaList &list) 2140 2110 { 2141 2111 HRESULT rc = S_OK; … … 2194 2164 2195 2165 #ifdef VBOX_WITH_USB 2196 USBProxyService* Host:: usbProxyService()2166 USBProxyService* Host::i_usbProxyService() 2197 2167 { 2198 2168 return m->pUSBProxyService; 2199 2169 } 2200 2170 2201 HRESULT Host:: addChild(HostUSBDeviceFilter *pChild)2171 HRESULT Host::i_addChild(HostUSBDeviceFilter *pChild) 2202 2172 { 2203 2173 AutoCaller autoCaller(this); … … 2211 2181 } 2212 2182 2213 HRESULT Host:: removeChild(HostUSBDeviceFilter *pChild)2183 HRESULT Host::i_removeChild(HostUSBDeviceFilter *pChild) 2214 2184 { 2215 2185 AutoCaller autoCaller(this); … … 2232 2202 } 2233 2203 2234 VirtualBox* Host:: parent()2204 VirtualBox* Host::i_parent() 2235 2205 { 2236 2206 return m->pParent; … … 2240 2210 * Called by setter methods of all USB device filters. 2241 2211 */ 2242 HRESULT Host:: onUSBDeviceFilterChange(HostUSBDeviceFilter *aFilter,2243 BOOL aActiveChanged /* = FALSE */)2212 HRESULT Host::i_onUSBDeviceFilterChange(HostUSBDeviceFilter *aFilter, 2213 BOOL aActiveChanged /* = FALSE */) 2244 2214 { 2245 2215 AutoCaller autoCaller(this); … … 2294 2264 * @param aMachines Where to put the machine vector. 2295 2265 */ 2296 void Host:: getUSBFilters(Host::USBDeviceFilterList *aGlobalFilters)2266 void Host::i_getUSBFilters(Host::USBDeviceFilterList *aGlobalFilters) 2297 2267 { 2298 2268 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); … … 2954 2924 * @note Locks this object for reading. 2955 2925 */ 2956 HRESULT Host:: checkUSBProxyService()2926 HRESULT Host::i_checkUSBProxyService() 2957 2927 { 2958 2928 AutoCaller autoCaller(this); … … 2992 2962 #endif /* VBOX_WITH_USB */ 2993 2963 2994 HRESULT Host:: updateNetIfList()2964 HRESULT Host::i_updateNetIfList() 2995 2965 { 2996 2966 #ifdef VBOX_WITH_HOSTNETIF_API … … 3068 3038 #ifdef VBOX_WITH_RESOURCE_USAGE_API 3069 3039 3070 void Host:: registerDiskMetrics(PerformanceCollector *aCollector)3040 void Host::i_registerDiskMetrics(PerformanceCollector *aCollector) 3071 3041 { 3072 3042 pm::CollectorHAL *hal = aCollector->getHAL(); … … 3154 3124 } 3155 3125 3156 void Host:: registerMetrics(PerformanceCollector *aCollector)3126 void Host::i_registerMetrics(PerformanceCollector *aCollector) 3157 3127 { 3158 3128 pm::CollectorHAL *hal = aCollector->getHAL(); … … 3287 3257 aCollector->registerMetric(new pm::Metric(ramVmm, ramVMMShared, 3288 3258 new pm::AggregateMax())); 3289 registerDiskMetrics(aCollector);3290 } 3291 3292 void Host:: unregisterMetrics (PerformanceCollector *aCollector)3259 i_registerDiskMetrics(aCollector); 3260 } 3261 3262 void Host::i_unregisterMetrics (PerformanceCollector *aCollector) 3293 3263 { 3294 3264 aCollector->unregisterMetricsFor(this); … … 3300 3270 3301 3271 /* static */ 3302 void Host:: generateMACAddress(Utf8Str &mac)3272 void Host::i_generateMACAddress(Utf8Str &mac) 3303 3273 { 3304 3274 /* -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r49644 r49742 2706 2706 2707 2707 # ifdef VBOX_WITH_USB 2708 rc = mParent->host()-> checkUSBProxyService();2708 rc = mParent->host()->i_checkUSBProxyService(); 2709 2709 if (FAILED(rc)) return rc; 2710 2710 # endif … … 2736 2736 2737 2737 # ifdef VBOX_WITH_USB 2738 rc = mParent->host()-> checkUSBProxyService();2738 rc = mParent->host()->i_checkUSBProxyService(); 2739 2739 if (FAILED(rc)) return rc; 2740 2740 # endif … … 5724 5724 pMedium->Close(); 5725 5725 } 5726 5726 5727 } 5727 5728 setMachineState(oldState); … … 9667 9668 case DeviceType_DVD: 9668 9669 if (dev.strHostDriveSrc.isNotEmpty()) 9669 rc = mParent->host()-> findHostDriveByName(dev.deviceType, dev.strHostDriveSrc, false /* fRefresh */, medium);9670 rc = mParent->host()->i_findHostDriveByName(dev.deviceType, dev.strHostDriveSrc, false /* fRefresh */, medium); 9670 9671 else 9671 9672 rc = mParent->findRemoveableMedium(dev.deviceType, … … 12978 12979 NOREF(rc); 12979 12980 12980 USBProxyService *service = mParent->host()-> usbProxyService();12981 USBProxyService *service = mParent->host()->i_usbProxyService(); 12981 12982 if (service) 12982 12983 service->detachAllDevicesFromVM(this, true /* aDone */, true /* aAbnormal */); … … 13445 13446 /* if captureDeviceForVM() fails, it must have set extended error info */ 13446 13447 clearError(); 13447 MultiResult rc = mParent->host()-> checkUSBProxyService();13448 MultiResult rc = mParent->host()->i_checkUSBProxyService(); 13448 13449 if (FAILED(rc)) return rc; 13449 13450 13450 USBProxyService *service = mParent->host()-> usbProxyService();13451 USBProxyService *service = mParent->host()->i_usbProxyService(); 13451 13452 AssertReturn(service, E_FAIL); 13452 13453 return service->captureDeviceForVM(this, Guid(aId).ref()); … … 13468 13469 13469 13470 #ifdef VBOX_WITH_USB 13470 USBProxyService *service = mParent->host()-> usbProxyService();13471 USBProxyService *service = mParent->host()->i_usbProxyService(); 13471 13472 AssertReturn(service, E_FAIL); 13472 13473 return service->detachDeviceFromVM(this, Guid(aId).ref(), !!aDone); … … 13498 13499 NOREF(rc); 13499 13500 13500 USBProxyService *service = mParent->host()-> usbProxyService();13501 USBProxyService *service = mParent->host()->i_usbProxyService(); 13501 13502 AssertReturn(service, E_FAIL); 13502 13503 return service->autoCaptureDevicesForVM(this); … … 13528 13529 NOREF(rc); 13529 13530 13530 USBProxyService *service = mParent->host()-> usbProxyService();13531 USBProxyService *service = mParent->host()->i_usbProxyService(); 13531 13532 AssertReturn(service, E_FAIL); 13532 13533 return service->detachAllDevicesFromVM(this, !!aDone, false /* aAbnormal */); -
trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp
r49039 r49742 582 582 && it->mode == NetworkAttachmentType_NAT) 583 583 continue; 584 Host:: generateMACAddress(it->strMACAddress);584 Host::i_generateMACAddress(it->strMACAddress); 585 585 } 586 586 } -
trunk/src/VBox/Main/src-server/NATNetworkImpl.cpp
r49614 r49742 32 32 33 33 #include "EventImpl.h" 34 #include "VBoxEvents.h"35 34 36 35 #include "VirtualBoxImpl.h" … … 47 46 // constructor / destructor 48 47 ///////////////////////////////////////////////////////////////////////////// 49 50 48 struct NATNetwork::Data 51 49 { … … 73 71 ComObjPtr<IDHCPServer> dhcpServer; 74 72 #endif 75 Bstr IPv4Gateway;76 Bstr IPv4NetworkCidr;77 Bstr IPv4NetworkMask;78 Bstr IPv4DhcpServer;79 Bstr IPv4DhcpServerLowerIp;80 Bstr IPv4DhcpServerUpperIp;73 com::Utf8Str IPv4Gateway; 74 com::Utf8Str IPv4NetworkCidr; 75 com::Utf8Str IPv4NetworkMask; 76 com::Utf8Str IPv4DhcpServer; 77 com::Utf8Str IPv4DhcpServerLowerIp; 78 com::Utf8Str IPv4DhcpServerUpperIp; 81 79 BOOL fEnabled; 82 80 BOOL fIPv6Enabled; 83 Bstr IPv6Prefix;81 com::Utf8Str IPv6Prefix; 84 82 BOOL fAdvertiseDefaultIPv6Route; 85 83 BOOL fNeedDhcpServer; 86 84 NATRuleMap mapName2PortForwardRule4; 87 85 NATRuleMap mapName2PortForwardRule6; 88 settings::NATLoopbackOffsetList llNATLoopbackOffsetList;86 settings::NATLoopbackOffsetList maNATLoopbackOffsetList; 89 87 uint32_t u32LoopbackIp6; 90 88 uint32_t offGateway; … … 129 127 } 130 128 131 132 HRESULT NATNetwork::init(VirtualBox *aVirtualBox, IN_BSTR aName) 133 { 134 AssertReturn(aName != NULL, E_INVALIDARG); 129 HRESULT NATNetwork::init(VirtualBox *aVirtualBox, com::Utf8Str aName) 130 { 131 AssertReturn(!aName.isEmpty(), E_INVALIDARG); 135 132 136 133 AutoInitSpan autoInitSpan(this); … … 148 145 off.strLoopbackHostAddress = "127.0.0.1"; 149 146 off.u32Offset = (uint32_t)2; 150 m-> llNATLoopbackOffsetList.push_back(off);151 152 recalculateIpv4AddressAssignments();147 m->maNATLoopbackOffsetList.push_back(off); 148 149 i_recalculateIpv4AddressAssignments(); 153 150 154 151 HRESULT hrc = unconst(m->pEventSource).createObject(); … … 185 182 m->u32LoopbackIp6 = data.u32HostLoopback6Offset; 186 183 187 m-> llNATLoopbackOffsetList.clear();188 m-> llNATLoopbackOffsetList.assign(data.llHostLoopbackOffsetList.begin(),184 m->maNATLoopbackOffsetList.clear(); 185 m->maNATLoopbackOffsetList.assign(data.llHostLoopbackOffsetList.begin(), 189 186 data.llHostLoopbackOffsetList.end()); 190 187 191 recalculateIpv4AddressAssignments();188 i_recalculateIpv4AddressAssignments(); 192 189 193 190 /* IPv4 port-forward rules */ … … 218 215 } 219 216 220 221 HRESULT NATNetwork::saveSettings(settings::NATNetwork &data) 217 HRESULT NATNetwork::i_saveSettings(settings::NATNetwork &data) 222 218 { 223 219 AutoCaller autoCaller(this); … … 249 245 250 246 data.llHostLoopbackOffsetList.clear(); 251 data.llHostLoopbackOffsetList.assign(m-> llNATLoopbackOffsetList.begin(),252 m-> llNATLoopbackOffsetList.end());253 254 mVirtualBox->onNATNetworkSetting( mName.raw(),247 data.llHostLoopbackOffsetList.assign(m->maNATLoopbackOffsetList.begin(), 248 m->maNATLoopbackOffsetList.end()); 249 250 mVirtualBox->onNATNetworkSetting(Bstr(mName).raw(), 255 251 data.fEnabled ? TRUE : FALSE, 256 m->IPv4NetworkCidr.raw(),257 m->IPv4Gateway.raw(),252 Bstr(m->IPv4NetworkCidr).raw(), 253 Bstr(m->IPv4Gateway).raw(), 258 254 data.fAdvertiseDefaultIPv6Route ? TRUE : FALSE, 259 255 data.fNeedDhcpServer ? TRUE : FALSE); … … 261 257 /* Notify listerners listening on this network only */ 262 258 fireNATNetworkSettingEvent(m->pEventSource, 263 mName.raw(), 264 data.fEnabled ? TRUE : FALSE, 265 m->IPv4NetworkCidr.raw(), 266 m->IPv4Gateway.raw(), 267 data.fAdvertiseDefaultIPv6Route ? TRUE : FALSE, 268 data.fNeedDhcpServer ? TRUE : FALSE); 269 270 return S_OK; 271 } 272 273 274 STDMETHODIMP NATNetwork::COMGETTER(EventSource)(IEventSource ** aEventSource) 275 { 276 CheckComArgOutPointerValid(aEventSource); 277 278 AutoCaller autoCaller(this); 279 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 280 259 Bstr(mName).raw(), 260 data.fEnabled ? TRUE : FALSE, 261 Bstr(m->IPv4NetworkCidr).raw(), 262 Bstr(m->IPv4Gateway).raw(), 263 data.fAdvertiseDefaultIPv6Route ? TRUE : FALSE, 264 data.fNeedDhcpServer ? TRUE : FALSE); 265 266 return S_OK; 267 } 268 269 HRESULT NATNetwork::getEventSource(ComPtr<IEventSource> &aEventSource) 270 { 281 271 /* event source is const, no need to lock */ 282 m->pEventSource.queryInterfaceTo(aEventSource); 283 284 return S_OK; 285 } 286 287 288 STDMETHODIMP NATNetwork::COMGETTER(NetworkName)(BSTR *aName) 289 { 290 CheckComArgOutPointerValid(aName); 291 292 AutoCaller autoCaller(this); 293 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 294 295 mName.cloneTo(aName); 296 297 return S_OK; 298 } 299 300 301 STDMETHODIMP NATNetwork::COMSETTER(NetworkName)(IN_BSTR aName) 302 { 303 CheckComArgOutPointerValid(aName); 304 AutoCaller autoCaller(this); 305 306 if (FAILED(autoCaller.rc())) 307 return autoCaller.rc(); 308 272 m->pEventSource.queryInterfaceTo(aEventSource.asOutParam()); 273 return S_OK; 274 } 275 276 HRESULT NATNetwork::getNetworkName(com::Utf8Str &aNetworkName) 277 { 278 aNetworkName = mName; 279 return S_OK; 280 } 281 282 HRESULT NATNetwork::setNetworkName(const com::Utf8Str &aNetworkName) 283 { 309 284 { 310 285 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 311 312 if (aName == mName) 286 if (aNetworkName == mName) 313 287 return S_OK; 314 288 315 unconst(mName) = aName; 316 } 317 289 unconst(mName) = aNetworkName; 290 } 318 291 AutoWriteLock vboxLock(mVirtualBox COMMA_LOCKVAL_SRC_POS); 319 292 HRESULT rc = mVirtualBox->saveSettings(); … … 323 296 } 324 297 325 326 STDMETHODIMP NATNetwork::COMGETTER(Enabled)(BOOL *aEnabled) 327 { 328 CheckComArgOutPointerValid(aEnabled); 329 330 AutoCaller autoCaller(this); 331 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 332 298 HRESULT NATNetwork::getEnabled(BOOL *aEnabled) 299 { 333 300 *aEnabled = m->fEnabled; 334 recalculateIpv4AddressAssignments(); 335 336 return S_OK; 337 } 338 339 340 STDMETHODIMP NATNetwork::COMSETTER(Enabled)(BOOL aEnabled) 341 { 342 AutoCaller autoCaller(this); 343 if (FAILED(autoCaller.rc())) 344 return autoCaller.rc(); 345 301 302 i_recalculateIpv4AddressAssignments(); 303 return S_OK; 304 } 305 306 HRESULT NATNetwork::setEnabled(const BOOL aEnabled) 307 { 346 308 { 347 309 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 348 349 310 if (aEnabled == m->fEnabled) 350 311 return S_OK; 351 352 312 m->fEnabled = aEnabled; 353 313 } … … 356 316 HRESULT rc = mVirtualBox->saveSettings(); 357 317 ComAssertComRCRetRC(rc); 358 359 return S_OK; 360 } 361 362 363 STDMETHODIMP NATNetwork::COMGETTER(Gateway)(BSTR *aIPv4Gateway) 364 { 365 CheckComArgOutPointerValid(aIPv4Gateway); 366 367 AutoCaller autoCaller(this); 368 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 369 370 m->IPv4Gateway.cloneTo(aIPv4Gateway); 371 372 return S_OK; 373 } 374 375 376 STDMETHODIMP NATNetwork::COMGETTER(Network)(BSTR *aIPv4NetworkCidr) 377 { 378 CheckComArgOutPointerValid(aIPv4NetworkCidr); 379 380 AutoCaller autoCaller(this); 381 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 382 m->IPv4NetworkCidr.cloneTo(aIPv4NetworkCidr); 383 return S_OK; 384 } 385 386 387 STDMETHODIMP NATNetwork::COMSETTER(Network)(IN_BSTR aIPv4NetworkCidr) 388 { 389 CheckComArgOutPointerValid(aIPv4NetworkCidr); 390 391 AutoCaller autoCaller(this); 392 if (FAILED(autoCaller.rc())) 393 return autoCaller.rc(); 394 395 { 318 return S_OK; 319 } 320 321 HRESULT NATNetwork::getGateway(com::Utf8Str &aIPv4Gateway) 322 { 323 aIPv4Gateway = m->IPv4Gateway; 324 return S_OK; 325 } 326 327 HRESULT NATNetwork::getNetwork(com::Utf8Str &aNetwork) 328 { 329 aNetwork = m->IPv4NetworkCidr; 330 return S_OK; 331 } 332 333 334 HRESULT NATNetwork::setNetwork(const com::Utf8Str &aIPv4NetworkCidr) 335 { 336 { 337 396 338 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 397 339 … … 406 348 return S_OK; 407 349 408 unconst(m->IPv4NetworkCidr) = Bstr(aIPv4NetworkCidr); 409 recalculateIpv4AddressAssignments(); 350 351 unconst(m->IPv4NetworkCidr) = aIPv4NetworkCidr; 352 i_recalculateIpv4AddressAssignments(); 410 353 } 411 354 … … 413 356 HRESULT rc = mVirtualBox->saveSettings(); 414 357 ComAssertComRCRetRC(rc); 415 416 return S_OK; 417 } 418 419 420 STDMETHODIMP NATNetwork::COMGETTER(IPv6Enabled)(BOOL *aIPv6Enabled) 421 { 422 CheckComArgOutPointerValid(aIPv6Enabled); 423 424 AutoCaller autoCaller(this); 425 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 426 358 return S_OK; 359 } 360 361 362 HRESULT NATNetwork::getIPv6Enabled(BOOL *aIPv6Enabled) 363 { 427 364 *aIPv6Enabled = m->fIPv6Enabled; 428 365 … … 431 368 432 369 433 STDMETHODIMP NATNetwork::COMSETTER(IPv6Enabled)(BOOL aIPv6Enabled) 434 { 435 AutoCaller autoCaller(this); 436 if (FAILED(autoCaller.rc())) 437 return autoCaller.rc(); 438 370 HRESULT NATNetwork::setIPv6Enabled(const BOOL aIPv6Enabled) 371 { 439 372 { 440 373 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); … … 454 387 455 388 456 STDMETHODIMP NATNetwork::COMGETTER(IPv6Prefix) (BSTR *aIPv6Prefix) 457 { 458 CheckComArgOutPointerValid(aIPv6Prefix); 459 460 AutoCaller autoCaller(this); 461 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 389 HRESULT NATNetwork::getIPv6Prefix(com::Utf8Str &aIPv6Prefix) 390 { 462 391 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 463 392 464 m->IPv6Prefix.cloneTo(aIPv6Prefix); 465 466 return S_OK; 467 } 468 469 470 STDMETHODIMP NATNetwork::COMSETTER(IPv6Prefix) (IN_BSTR aIPv6Prefix) 471 { 472 CheckComArgOutPointerValid(aIPv6Prefix); 473 474 AutoCaller autoCaller(this); 475 if (FAILED(autoCaller.rc())) 476 return autoCaller.rc(); 477 393 aIPv6Prefix = m->IPv6Prefix; 394 return S_OK; 395 } 396 397 HRESULT NATNetwork::setIPv6Prefix(const com::Utf8Str &aIPv6Prefix) 398 { 478 399 { 479 400 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); … … 499 420 500 421 501 STDMETHODIMP NATNetwork::COMGETTER(AdvertiseDefaultIPv6RouteEnabled)(BOOL *aAdvertiseDefaultIPv6Route) 502 { 503 CheckComArgOutPointerValid(aAdvertiseDefaultIPv6Route); 504 505 AutoCaller autoCaller(this); 506 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 507 422 HRESULT NATNetwork::getAdvertiseDefaultIPv6RouteEnabled(BOOL *aAdvertiseDefaultIPv6Route) 423 { 508 424 *aAdvertiseDefaultIPv6Route = m->fAdvertiseDefaultIPv6Route; 509 425 … … 512 428 513 429 514 STDMETHODIMP NATNetwork::COMSETTER(AdvertiseDefaultIPv6RouteEnabled)(BOOL aAdvertiseDefaultIPv6Route) 515 { 516 AutoCaller autoCaller(this); 517 if (FAILED(autoCaller.rc())) 518 return autoCaller.rc(); 519 430 HRESULT NATNetwork::setAdvertiseDefaultIPv6RouteEnabled(const BOOL aAdvertiseDefaultIPv6Route) 431 { 520 432 { 521 433 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); … … 536 448 537 449 538 STDMETHODIMP NATNetwork::COMGETTER(NeedDhcpServer)(BOOL *aNeedDhcpServer) 539 { 540 CheckComArgOutPointerValid(aNeedDhcpServer); 541 542 AutoCaller autoCaller(this); 543 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 544 450 HRESULT NATNetwork::getNeedDhcpServer(BOOL *aNeedDhcpServer) 451 { 545 452 *aNeedDhcpServer = m->fNeedDhcpServer; 546 453 … … 548 455 } 549 456 550 551 STDMETHODIMP NATNetwork::COMSETTER(NeedDhcpServer)(BOOL aNeedDhcpServer) 552 { 553 AutoCaller autoCaller(this); 554 if (FAILED(autoCaller.rc())) 555 return autoCaller.rc(); 556 457 HRESULT NATNetwork::setNeedDhcpServer(const BOOL aNeedDhcpServer) 458 { 557 459 { 558 460 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); … … 563 465 m->fNeedDhcpServer = aNeedDhcpServer; 564 466 565 recalculateIpv4AddressAssignments();467 i_recalculateIpv4AddressAssignments(); 566 468 567 469 } … … 574 476 } 575 477 576 577 STDMETHODIMP NATNetwork::COMGETTER(LocalMappings)(ComSafeArrayOut(BSTR, aLocalMappings)) 578 { 579 CheckComArgOutSafeArrayPointerValid(aLocalMappings); 580 581 AutoCaller autoCaller(this); 582 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 478 HRESULT NATNetwork::getLocalMappings(std::vector<com::Utf8Str> &aLocalMappings) 479 { 583 480 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 584 481 585 com::SafeArray<BSTR> sf(m->llNATLoopbackOffsetList.size()); 586 482 aLocalMappings.resize(m->maNATLoopbackOffsetList.size()); 587 483 size_t i = 0; 588 settings::NATLoopbackOffsetList::const_iterator it; 589 590 for (it = m->llNATLoopbackOffsetList.begin(); 591 it != m->llNATLoopbackOffsetList.end(); ++it, ++i) 592 { 593 BstrFmt bstr("%s=%d", 594 (*it).strLoopbackHostAddress.c_str(), 595 (*it).u32Offset); 596 bstr.detachTo(&sf[i]); 597 } 598 sf.detachTo(ComSafeArrayOutArg(aLocalMappings)); 599 600 return S_OK; 601 } 602 603 604 STDMETHODIMP NATNetwork::AddLocalMapping(IN_BSTR aHostId, LONG aOffset) 605 { 606 AutoCaller autoCaller(this); 607 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 608 609 //AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 610 484 for (settings::NATLoopbackOffsetList::const_iterator it = m->maNATLoopbackOffsetList.begin(); 485 it != m->maNATLoopbackOffsetList.end(); ++it, ++i) 486 { 487 aLocalMappings[i] = Utf8StrFmt("%s;%d", 488 (*it).strLoopbackHostAddress.c_str(), 489 (*it).u32Offset); 490 } 491 492 return S_OK; 493 } 494 495 HRESULT NATNetwork::addLocalMapping(const com::Utf8Str &aHostId, LONG aOffset) 496 { 611 497 RTNETADDRIPV4 addr, net, mask; 612 498 … … 629 515 settings::NATLoopbackOffsetList::iterator it; 630 516 631 it = std::find(m->llNATLoopbackOffsetList.begin(), 632 m->llNATLoopbackOffsetList.end(), 633 Utf8Str(aHostId).c_str()); 634 635 if (it != m->llNATLoopbackOffsetList.end()) 517 it = std::find(m->maNATLoopbackOffsetList.begin(), 518 m->maNATLoopbackOffsetList.end(), 519 aHostId); 520 if (it != m->maNATLoopbackOffsetList.end()) 636 521 { 637 522 if (aOffset == 0) /* erase */ 638 m-> llNATLoopbackOffsetList.erase(it, it);523 m->maNATLoopbackOffsetList.erase(it, it); 639 524 else /* modify */ 640 525 { 641 526 settings::NATLoopbackOffsetList::iterator it1; 642 it1 = std::find(m-> llNATLoopbackOffsetList.begin(),643 m-> llNATLoopbackOffsetList.end(),527 it1 = std::find(m->maNATLoopbackOffsetList.begin(), 528 m->maNATLoopbackOffsetList.end(), 644 529 (uint32_t)aOffset); 645 if (it1 != m-> llNATLoopbackOffsetList.end())530 if (it1 != m->maNATLoopbackOffsetList.end()) 646 531 return E_INVALIDARG; /* this offset is already registered. */ 647 532 … … 654 539 655 540 /* injection */ 656 it = std::find(m-> llNATLoopbackOffsetList.begin(),657 m-> llNATLoopbackOffsetList.end(),541 it = std::find(m->maNATLoopbackOffsetList.begin(), 542 m->maNATLoopbackOffsetList.end(), 658 543 (uint32_t)aOffset); 659 544 660 if (it != m-> llNATLoopbackOffsetList.end())545 if (it != m->maNATLoopbackOffsetList.end()) 661 546 return E_INVALIDARG; /* offset is already registered. */ 662 547 … … 664 549 off.strLoopbackHostAddress = aHostId; 665 550 off.u32Offset = (uint32_t)aOffset; 666 m-> llNATLoopbackOffsetList.push_back(off);551 m->maNATLoopbackOffsetList.push_back(off); 667 552 668 553 AutoWriteLock vboxLock(mVirtualBox COMMA_LOCKVAL_SRC_POS); … … 671 556 672 557 673 STDMETHODIMP NATNetwork::COMGETTER(LoopbackIp6)(LONG *aLoopbackIp6) 674 { 675 AutoCaller autoCaller(this); 676 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 558 HRESULT NATNetwork::getLoopbackIp6(LONG *aLoopbackIp6) 559 { 677 560 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 678 561 … … 682 565 683 566 684 STDMETHODIMP NATNetwork::COMSETTER(LoopbackIp6)(LONG aLoopbackIp6) 685 { 686 AutoCaller autoCaller(this); 687 if (FAILED(autoCaller.rc())) 688 return autoCaller.rc(); 689 567 HRESULT NATNetwork::setLoopbackIp6(LONG aLoopbackIp6) 568 { 690 569 { 691 570 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); … … 705 584 706 585 707 STDMETHODIMP NATNetwork::COMGETTER(PortForwardRules4)(ComSafeArrayOut(BSTR, aPortForwardRules4)) 708 { 709 CheckComArgOutSafeArrayPointerValid(aPortForwardRules4); 710 711 AutoCaller autoCaller(this); 712 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 713 586 HRESULT NATNetwork::getPortForwardRules4(std::vector<com::Utf8Str> &aPortForwardRules4) 587 { 714 588 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 715 GetPortForwardRulesFromMap(ComSafeArrayInArg(aPortForwardRules4), 716 m->mapName2PortForwardRule4); 717 return S_OK; 718 } 719 720 STDMETHODIMP NATNetwork::COMGETTER(PortForwardRules6)(ComSafeArrayOut(BSTR, 721 aPortForwardRules6)) 722 { 723 CheckComArgOutSafeArrayPointerValid(aPortForwardRules6); 724 725 AutoCaller autoCaller(this); 726 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 727 589 i_getPortForwardRulesFromMap(aPortForwardRules4, 590 m->mapName2PortForwardRule4); 591 return S_OK; 592 } 593 594 HRESULT NATNetwork::getPortForwardRules6(std::vector<com::Utf8Str> &aPortForwardRules6) 595 { 728 596 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 729 GetPortForwardRulesFromMap(ComSafeArrayInArg(aPortForwardRules6), m->mapName2PortForwardRule6); 730 return S_OK; 731 } 732 733 734 STDMETHODIMP NATNetwork::AddPortForwardRule(BOOL aIsIpv6, 735 IN_BSTR aPortForwardRuleName, 736 NATProtocol_T aProto, 737 IN_BSTR aHostIp, 738 USHORT aHostPort, 739 IN_BSTR aGuestIp, 740 USHORT aGuestPort) 741 { 742 AutoCaller autoCaller(this); 743 if (FAILED(autoCaller.rc())) 744 return autoCaller.rc(); 745 597 i_getPortForwardRulesFromMap(aPortForwardRules6, 598 m->mapName2PortForwardRule6); 599 return S_OK; 600 } 601 602 HRESULT NATNetwork::addPortForwardRule(BOOL aIsIpv6, 603 const com::Utf8Str &aPortForwardRuleName, 604 NATProtocol_T aProto, 605 const com::Utf8Str &aHostIp, 606 USHORT aHostPort, 607 const com::Utf8Str &aGuestIp, 608 USHORT aGuestPort) 609 { 746 610 { 747 611 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); … … 763 627 if (name.isEmpty()) 764 628 name = Utf8StrFmt("%s_[%s]%%%d_[%s]%%%d", proto.c_str(), 765 Utf8Str(aHostIp).c_str(), aHostPort, 766 Utf8Str(aGuestIp).c_str(), aGuestPort); 767 768 NATRuleMap::iterator it; 769 770 for (it = mapRules.begin(); it != mapRules.end(); ++it) 629 aHostIp.c_str(), aHostPort, 630 aGuestIp.c_str(), aGuestPort); 631 632 for (NATRuleMap::iterator it = mapRules.begin(); it != mapRules.end(); ++it) 771 633 { 772 634 r = it->second; … … 774 636 return setError(E_INVALIDARG, 775 637 tr("A NAT rule of this name already exists")); 776 if ( r.strHostIP == Utf8Str(aHostIp)638 if ( r.strHostIP == aHostIp 777 639 && r.u16HostPort == aHostPort 778 640 && r.proto == aProto) … … 789 651 mapRules.insert(std::make_pair(name, r)); 790 652 } 791 792 653 { 793 654 AutoWriteLock vboxLock(mVirtualBox COMMA_LOCKVAL_SRC_POS); … … 796 657 } 797 658 798 mVirtualBox->onNATNetworkPortForward( mName.raw(), TRUE, aIsIpv6,799 aPortForwardRuleName, aProto,800 aHostIp, aHostPort,801 aGuestIp, aGuestPort);659 mVirtualBox->onNATNetworkPortForward(Bstr(mName).raw(), TRUE, aIsIpv6, 660 Bstr(aPortForwardRuleName).raw(), aProto, 661 Bstr(aHostIp).raw(), aHostPort, 662 Bstr(aGuestIp).raw(), aGuestPort); 802 663 803 664 /* Notify listerners listening on this network only */ 804 fireNATNetworkPortForwardEvent(m->pEventSource, mName.raw(), TRUE, 805 aIsIpv6, aPortForwardRuleName, aProto, 806 aHostIp, aHostPort, 807 aGuestIp, aGuestPort); 808 return S_OK; 809 } 810 811 812 STDMETHODIMP NATNetwork::RemovePortForwardRule(BOOL aIsIpv6, IN_BSTR aPortForwardRuleName) 813 { 814 AutoCaller autoCaller(this); 815 if (FAILED(autoCaller.rc())) 816 return autoCaller.rc(); 817 665 fireNATNetworkPortForwardEvent(m->pEventSource, Bstr(mName).raw(), TRUE, 666 aIsIpv6, Bstr(aPortForwardRuleName).raw(), aProto, 667 Bstr(aHostIp).raw(), aHostPort, 668 Bstr(aGuestIp).raw(), aGuestPort); 669 670 return S_OK; 671 } 672 673 HRESULT NATNetwork::removePortForwardRule(BOOL aIsIpv6, const com::Utf8Str &aPortForwardRuleName) 674 { 818 675 Utf8Str strHostIP; 819 676 Utf8Str strGuestIP; … … 822 679 NATProtocol_T proto; 823 680 824 825 681 { 826 682 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 827 NATRuleMap& mapRules = aIsIpv6 ? m->mapName2PortForwardRule6 828 : m->mapName2PortForwardRule4; 829 683 NATRuleMap& mapRules = aIsIpv6 ? m->mapName2PortForwardRule6 : m->mapName2PortForwardRule4; 830 684 NATRuleMap::iterator it = mapRules.find(aPortForwardRuleName); 831 685 … … 848 702 } 849 703 850 mVirtualBox->onNATNetworkPortForward( mName.raw(), FALSE, aIsIpv6,851 aPortForwardRuleName, proto,704 mVirtualBox->onNATNetworkPortForward(Bstr(mName).raw(), FALSE, aIsIpv6, 705 Bstr(aPortForwardRuleName).raw(), proto, 852 706 Bstr(strHostIP).raw(), u16HostPort, 853 707 Bstr(strGuestIP).raw(), u16GuestPort); 854 708 855 709 /* Notify listerners listening on this network only */ 856 fireNATNetworkPortForwardEvent(m->pEventSource, mName.raw(), FALSE,857 aIsIpv6, aPortForwardRuleName, proto,710 fireNATNetworkPortForwardEvent(m->pEventSource, Bstr(mName).raw(), FALSE, 711 aIsIpv6, Bstr(aPortForwardRuleName).raw(), proto, 858 712 Bstr(strHostIP).raw(), u16HostPort, 859 713 Bstr(strGuestIP).raw(), u16GuestPort); … … 862 716 863 717 864 STDMETHODIMP NATNetwork::Start(IN_BSTRaTrunkType)718 HRESULT NATNetwork::start(const com::Utf8Str &aTrunkType) 865 719 { 866 720 #ifdef VBOX_WITH_NAT_SERVICE 867 AutoCaller autoCaller(this);868 if (FAILED(autoCaller.rc())) return autoCaller.rc();869 870 721 if (!m->fEnabled) return S_OK; 871 722 … … 893 744 * 6. start dhcp server. 894 745 */ 895 HRESULT hrc = mVirtualBox->FindDHCPServerByNetworkName( mName.raw(),896 m->dhcpServer.asOutParam());746 HRESULT hrc = mVirtualBox->FindDHCPServerByNetworkName(Bstr(mName).raw(), 747 m->dhcpServer.asOutParam()); 897 748 switch (hrc) 898 749 { 899 750 case E_INVALIDARG: 900 751 /* server haven't beeen found let create it then */ 901 hrc = mVirtualBox->CreateDHCPServer( mName.raw(),752 hrc = mVirtualBox->CreateDHCPServer(Bstr(mName).raw(), 902 753 m->dhcpServer.asOutParam()); 903 754 if (FAILED(hrc)) … … 907 758 { 908 759 LogFunc(("gateway: %s, dhcpserver:%s, dhcplowerip:%s, dhcpupperip:%s\n", 909 Utf8Str(m->IPv4Gateway.raw()).c_str(),910 Utf8Str(m->IPv4DhcpServer.raw()).c_str(),911 Utf8Str(m->IPv4DhcpServerLowerIp.raw()).c_str(),912 Utf8Str(m->IPv4DhcpServerUpperIp.raw()).c_str()));760 m->IPv4Gateway.c_str(), 761 m->IPv4DhcpServer.c_str(), 762 m->IPv4DhcpServerLowerIp.c_str(), 763 m->IPv4DhcpServerUpperIp.c_str())); 913 764 914 765 hrc = m->dhcpServer->COMSETTER(Enabled)(true); … … 936 787 937 788 /* XXX: AddGlobalOption(DhcpOpt_Router,) - enables attachement of DhcpServer to Main. */ 938 m->dhcpServer->AddGlobalOption(DhcpOpt_Router, m->IPv4Gateway.raw());939 940 hrc = m->dhcpServer->Start( mName.raw(), Bstr("").raw(), aTrunkType);789 m->dhcpServer->AddGlobalOption(DhcpOpt_Router, Bstr(m->IPv4Gateway).raw()); 790 791 hrc = m->dhcpServer->Start(Bstr(mName).raw(), Bstr("").raw(), Bstr(aTrunkType).raw()); 941 792 if (FAILED(hrc)) 942 793 { … … 948 799 if (RT_SUCCESS(m->NATRunner.start())) 949 800 { 950 mVirtualBox->onNATNetworkStartStop( mName.raw(), TRUE);801 mVirtualBox->onNATNetworkStartStop(Bstr(mName).raw(), TRUE); 951 802 return S_OK; 952 803 } … … 959 810 } 960 811 961 962 STDMETHODIMP NATNetwork::Stop() 812 HRESULT NATNetwork::stop() 963 813 { 964 814 #ifdef VBOX_WITH_NAT_SERVICE … … 968 818 if (RT_SUCCESS(m->NATRunner.stop())) 969 819 { 970 mVirtualBox->onNATNetworkStartStop( mName.raw(), FALSE);820 mVirtualBox->onNATNetworkStartStop(Bstr(mName).raw(), FALSE); 971 821 return S_OK; 972 822 } … … 979 829 980 830 981 void NATNetwork:: GetPortForwardRulesFromMap(ComSafeArrayOut(BSTR, aPortForwardRules), NATRuleMap& aRules)982 { 983 com::SafeArray<BSTR> sf(aRules.size());831 void NATNetwork::i_getPortForwardRulesFromMap(std::vector<com::Utf8Str> &aPortForwardRules, NATRuleMap& aRules) 832 { 833 aPortForwardRules.resize(aRules.size()); 984 834 size_t i = 0; 985 NATRuleMap::const_iterator it; 986 for (it = aRules.begin(); 835 for (NATRuleMap::const_iterator it = aRules.begin(); 987 836 it != aRules.end(); ++it, ++i) 988 837 { 989 838 settings::NATRule r = it->second; 990 BstrFmt bstr("%s:%s:[%s]:%d:[%s]:%d", 991 r.strName.c_str(), 992 (r.proto == NATProtocol_TCP? "tcp" : "udp"), 993 r.strHostIP.c_str(), 994 r.u16HostPort, 995 r.strGuestIP.c_str(), 996 r.u16GuestPort); 997 bstr.detachTo(&sf[i]); 998 } 999 sf.detachTo(ComSafeArrayOutArg(aPortForwardRules)); 1000 } 1001 1002 1003 int NATNetwork::findFirstAvailableOffset(ADDRESSLOOKUPTYPE addrType, uint32_t *poff) 839 aPortForwardRules[i] = Utf8StrFmt("%s:%s:[%s]:%d:[%s]:%d", 840 r.strName.c_str(), 841 (r.proto == NATProtocol_TCP? "tcp" : "udp"), 842 r.strHostIP.c_str(), 843 r.u16HostPort, 844 r.strGuestIP.c_str(), 845 r.u16GuestPort); 846 } 847 } 848 849 850 int NATNetwork::i_findFirstAvailableOffset(ADDRESSLOOKUPTYPE addrType, uint32_t *poff) 1004 851 { 1005 852 RTNETADDRIPV4 network, netmask; 1006 853 1007 int rc = RTCidrStrToIPv4( Utf8Str(m->IPv4NetworkCidr.raw()).c_str(),854 int rc = RTCidrStrToIPv4(m->IPv4NetworkCidr.c_str(), 1008 855 &network, 1009 856 &netmask); … … 1011 858 1012 859 uint32_t off; 1013 settings::NATLoopbackOffsetList::iterator it;1014 860 for (off = 1; off < ~netmask.u; ++off) 1015 861 { 1016 1017 862 bool skip = false; 1018 for ( it = m->llNATLoopbackOffsetList.begin();1019 it != m-> llNATLoopbackOffsetList.end();863 for (settings::NATLoopbackOffsetList::iterator it = m->maNATLoopbackOffsetList.begin(); 864 it != m->maNATLoopbackOffsetList.end(); 1020 865 ++it) 1021 866 { … … 1057 902 } 1058 903 1059 1060 int NATNetwork::recalculateIpv4AddressAssignments() 904 int NATNetwork::i_recalculateIpv4AddressAssignments() 1061 905 { 1062 906 RTNETADDRIPV4 network, netmask; 1063 int rc = RTCidrStrToIPv4( Utf8Str(m->IPv4NetworkCidr.raw()).c_str(),907 int rc = RTCidrStrToIPv4(m->IPv4NetworkCidr.c_str(), 1064 908 &network, 1065 909 &netmask); 1066 910 AssertRCReturn(rc, rc); 1067 911 1068 findFirstAvailableOffset(ADDR_GATEWAY, &m->offGateway);912 i_findFirstAvailableOffset(ADDR_GATEWAY, &m->offGateway); 1069 913 if (m->fNeedDhcpServer) 1070 findFirstAvailableOffset(ADDR_DHCP, &m->offDhcp);914 i_findFirstAvailableOffset(ADDR_DHCP, &m->offDhcp); 1071 915 1072 916 /* I don't remember the reason CIDR calculated on the host. */ … … 1086 930 RTNETADDRIPV4 dhcplowerip = network; 1087 931 uint32_t offDhcpLowerIp; 1088 findFirstAvailableOffset(ADDR_DHCPLOWERIP, &offDhcpLowerIp);932 i_findFirstAvailableOffset(ADDR_DHCPLOWERIP, &offDhcpLowerIp); 1089 933 dhcplowerip.u = RT_H2N_U32(dhcplowerip.u + offDhcpLowerIp); 1090 934 -
trunk/src/VBox/Main/src-server/NetworkAdapterImpl.cpp
r49644 r49742 1459 1459 { 1460 1460 Utf8Str mac; 1461 Host:: generateMACAddress(mac);1461 Host::i_generateMACAddress(mac); 1462 1462 LogFlowThisFunc(("generated MAC: '%s'\n", mac.c_str())); 1463 1463 mData->mMACAddress = mac; -
trunk/src/VBox/Main/src-server/USBDeviceFilterImpl.cpp
r47376 r49742 931 931 /* register with parent early, since uninit() will unconditionally 932 932 * unregister on failure */ 933 mParent-> addChild(this);933 mParent->i_addChild(this); 934 934 935 935 mData.allocate(); … … 1000 1000 /* register with parent early, since uninit() will unconditionally 1001 1001 * unregister on failure */ 1002 mParent-> addChild(this);1002 mParent->i_addChild(this); 1003 1003 1004 1004 mData.allocate(); … … 1034 1034 mData.free(); 1035 1035 1036 mParent-> removeChild(this);1036 mParent->i_removeChild(this); 1037 1037 1038 1038 unconst(mParent) = NULL; … … 1083 1083 alock.release(); 1084 1084 1085 return mParent-> onUSBDeviceFilterChange (this);1085 return mParent->i_onUSBDeviceFilterChange (this); 1086 1086 } 1087 1087 … … 1117 1117 alock.release(); 1118 1118 1119 return mParent-> onUSBDeviceFilterChange (this, TRUE /* aActiveChanged */);1119 return mParent->i_onUSBDeviceFilterChange (this, TRUE /* aActiveChanged */); 1120 1120 } 1121 1121 … … 1286 1286 alock.release(); 1287 1287 1288 return mParent-> onUSBDeviceFilterChange (this);1288 return mParent->i_onUSBDeviceFilterChange (this); 1289 1289 } 1290 1290 … … 1373 1373 alock.release(); 1374 1374 1375 return mParent-> onUSBDeviceFilterChange(this);1375 return mParent->i_onUSBDeviceFilterChange(this); 1376 1376 } 1377 1377 -
trunk/src/VBox/Main/src-server/USBDeviceFiltersImpl.cpp
r47401 r49742 390 390 && pFilter->getData().mRemote.isMatch(false)) 391 391 { 392 USBProxyService *pProxySvc = m->pHost-> usbProxyService();392 USBProxyService *pProxySvc = m->pHost->i_usbProxyService(); 393 393 ComAssertRet(pProxySvc, E_FAIL); 394 394 … … 462 462 && pFilter->getData().mRemote.isMatch(false)) 463 463 { 464 USBProxyService *pProxySvc = m->pHost-> usbProxyService();464 USBProxyService *pProxySvc = m->pHost->i_usbProxyService(); 465 465 ComAssertRet(pProxySvc, E_FAIL); 466 466 … … 602 602 if (m->llDeviceFilters.isBackedUp()) 603 603 { 604 USBProxyService *pProxySvc = m->pHost-> usbProxyService();604 USBProxyService *pProxySvc = m->pHost->i_usbProxyService(); 605 605 Assert(pProxySvc); 606 606 … … 844 844 && m->pParent->isRegistered()) 845 845 { 846 USBProxyService *pProxySvc = m->pHost-> usbProxyService();846 USBProxyService *pProxySvc = m->pHost->i_usbProxyService(); 847 847 ComAssertRet(pProxySvc, E_FAIL); 848 848 … … 1042 1042 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 1043 1043 1044 USBProxyService *pProxySvc = m->pHost-> usbProxyService();1044 USBProxyService *pProxySvc = m->pHost->i_usbProxyService(); 1045 1045 AssertReturn(pProxySvc, E_FAIL); 1046 1046 -
trunk/src/VBox/Main/src-server/USBProxyService.cpp
r41528 r49742 218 218 // (getOpenedMachines requests locks which are incompatible with the lock of the machines list) 219 219 SessionMachinesList llOpenedMachines; 220 mHost-> parent()->getOpenedMachines(llOpenedMachines);220 mHost->i_parent()->getOpenedMachines(llOpenedMachines); 221 221 222 222 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); … … 329 329 // (getOpenedMachines requests locks which are incompatible with the host object lock) 330 330 SessionMachinesList llOpenedMachines; 331 mHost-> parent()->getOpenedMachines(llOpenedMachines);331 mHost->i_parent()->getOpenedMachines(llOpenedMachines); 332 332 333 333 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); … … 411 411 Host::USBDeviceFilterList globalFilters; 412 412 413 mHost-> getUSBFilters(&globalFilters);413 mHost->i_getUSBFilters(&globalFilters); 414 414 415 415 /* … … 862 862 // (getOpenedMachines requests higher priority locks) 863 863 SessionMachinesList llOpenedMachines; 864 mHost-> parent()->getOpenedMachines(llOpenedMachines);864 mHost->i_parent()->getOpenedMachines(llOpenedMachines); 865 865 866 866 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); -
trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp
r49644 r49742 69 69 #endif /* VBOX_WITH_RESOURCE_USAGE_API */ 70 70 #include "EventImpl.h" 71 #include "VBoxEvents.h"72 71 #ifdef VBOX_WITH_EXTPACK 73 72 # include "ExtPackManagerImpl.h" … … 428 427 ComAssertComRCThrowRC(rc); 429 428 430 rc = m->pHost-> loadSettings(m->pMainConfigFile->host);429 rc = m->pHost->i_loadSettings(m->pMainConfigFile->host); 431 430 if (FAILED(rc)) throw rc; 432 431 … … 3690 3689 3691 3690 // first search for host drive with that UUID 3692 HRESULT rc = m->pHost-> findHostDriveById(mediumType,3693 uuid,3694 fRefresh,3695 pMedium);3691 HRESULT rc = m->pHost->i_findHostDriveById(mediumType, 3692 uuid, 3693 fRefresh, 3694 pMedium); 3696 3695 if (rc == VBOX_E_OBJECT_NOT_FOUND) 3697 3696 // then search for an image with that UUID … … 4255 4254 { 4256 4255 settings::NATNetwork n; 4257 rc = (*it)-> saveSettings(n);4256 rc = (*it)->i_saveSettings(n); 4258 4257 if (FAILED(rc)) throw rc; 4259 4258 m->pMainConfigFile->llNATNetworks.push_back(n); … … 4265 4264 4266 4265 // host data (USB filters) 4267 rc = m->pHost-> saveSettings(m->pMainConfigFile->host);4266 rc = m->pHost->i_saveSettings(m->pMainConfigFile->host); 4268 4267 if (FAILED(rc)) throw rc; 4269 4268 -
trunk/src/VBox/Main/src-server/xpcom/server.cpp
r49644 r49742 104 104 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Machine, IMachine) 105 105 106 NS_DECL_CLASSINFO(Appliance)107 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Appliance, IAppliance)108 109 NS_DECL_CLASSINFO(VirtualSystemDescription)110 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(VirtualSystemDescription, IVirtualSystemDescription)111 112 106 NS_DECL_CLASSINFO(SessionMachine) 113 107 NS_IMPL_THREADSAFE_ISUPPORTS2_CI(SessionMachine, IMachine, IInternalMachineControl) … … 134 128 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(SharedFolder, ISharedFolder) 135 129 136 NS_DECL_CLASSINFO(Host)137 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Host, IHost)138 139 130 NS_DECL_CLASSINFO(HostNetworkInterface) 140 131 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(HostNetworkInterface, IHostNetworkInterface) 141 142 NS_DECL_CLASSINFO(NATNetwork)143 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(NATNetwork, INATNetwork)144 132 145 133 NS_DECL_CLASSINFO(NetworkAdapter)
Note:
See TracChangeset
for help on using the changeset viewer.