Changeset 72899 in vbox for trunk/src/VBox/Main/src-server/ApplianceImpl.cpp
- Timestamp:
- Jul 4, 2018 6:49:59 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 123446
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/ApplianceImpl.cpp
r72898 r72899 37 37 using namespace std; 38 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 81 82 //////////////////////////////////////////////////////////////////////////////// 83 // 84 // Internal helpers 85 // 86 //////////////////////////////////////////////////////////////////////////////// 87 88 static const char* const strISOURI = "http://www.ecma-international.org/publications/standards/Ecma-119.htm"; 89 static const char* const strVMDKStreamURI = "http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized"; 90 static const char* const strVMDKSparseURI = "http://www.vmware.com/specifications/vmdk.html#sparse"; 91 static const char* const strVMDKCompressedURI = "http://www.vmware.com/specifications/vmdk.html#compressed"; 92 static const char* const strVMDKCompressedURI2 = "http://www.vmware.com/interfaces/specifications/vmdk.html#compressed"; 93 static const char* const strVHDURI = "http://go.microsoft.com/fwlink/?LinkId=137171"; 39 40 /********************************************************************************************************************************* 41 * Global Variables * 42 *********************************************************************************************************************************/ 43 static const char * const g_pszISOURI = "http://www.ecma-international.org/publications/standards/Ecma-119.htm"; 44 static const char * const g_pszVMDKStreamURI = "http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized"; 45 static const char * const g_pszVMDKSparseURI = "http://www.vmware.com/specifications/vmdk.html#sparse"; 46 static const char * const g_pszVMDKCompressedURI = "http://www.vmware.com/specifications/vmdk.html#compressed"; 47 static const char * const g_pszVMDKCompressedURI2 = "http://www.vmware.com/interfaces/specifications/vmdk.html#compressed"; 48 static const char * const g_pszrVHDURI = "http://go.microsoft.com/fwlink/?LinkId=137171"; 94 49 95 50 static std::map<Utf8Str, Utf8Str> supportedStandardsURI; 96 97 static const char* const applianceIOTarName = "Appliance::IOTar";98 static const char* const applianceIOShaName = "Appliance::IOSha";99 static const char* const applianceIOFileName = "Appliance::IOFile";100 101 static std::map<APPLIANCEIONAME, Utf8Str> applianceIONameMap;102 51 103 52 static const struct … … 105 54 ovf::CIMOSType_T cim; 106 55 VBOXOSTYPE osType; 107 } 108 g_osTypes[] = 56 } g_aOsTypes[] = 109 57 { 110 58 { ovf::CIMOSType_CIMOS_Unknown, VBOXOSTYPE_Unknown }, … … 219 167 220 168 /* These are the 32-Bit ones. They are sorted by priority. */ 221 static const osTypePattern g_ osTypesPattern[] =169 static const osTypePattern g_aOsTypesPattern[] = 222 170 { 223 171 {"Windows NT", VBOXOSTYPE_WinNT4}, … … 250 198 251 199 /* These are the 64-Bit ones. They are sorted by priority. */ 252 static const osTypePattern g_ osTypesPattern64[] =200 static const osTypePattern g_aOsTypesPattern64[] = 253 201 { 254 202 {"Windows XP", VBOXOSTYPE_WinXP_x64}, … … 282 230 if (c == ovf::CIMOSType_CIMOS_Other) 283 231 { 284 for (size_t i=0; i < RT_ELEMENTS(g_ osTypesPattern); ++i)285 if (cStr.contains (g_ osTypesPattern[i].pcszPattern, Utf8Str::CaseInsensitive))232 for (size_t i=0; i < RT_ELEMENTS(g_aOsTypesPattern); ++i) 233 if (cStr.contains (g_aOsTypesPattern[i].pcszPattern, Utf8Str::CaseInsensitive)) 286 234 { 287 strType = Global::OSTypeId(g_ osTypesPattern[i].osType);235 strType = Global::OSTypeId(g_aOsTypesPattern[i].osType); 288 236 return; 289 237 } … … 291 239 else if (c == ovf::CIMOSType_CIMOS_Other_64) 292 240 { 293 for (size_t i=0; i < RT_ELEMENTS(g_ osTypesPattern64); ++i)294 if (cStr.contains (g_ osTypesPattern64[i].pcszPattern, Utf8Str::CaseInsensitive))241 for (size_t i=0; i < RT_ELEMENTS(g_aOsTypesPattern64); ++i) 242 if (cStr.contains (g_aOsTypesPattern64[i].pcszPattern, Utf8Str::CaseInsensitive)) 295 243 { 296 strType = Global::OSTypeId(g_ osTypesPattern64[i].osType);244 strType = Global::OSTypeId(g_aOsTypesPattern64[i].osType); 297 245 return; 298 246 } 299 247 } 300 248 301 for (size_t i = 0; i < RT_ELEMENTS(g_ osTypes); ++i)302 { 303 if (c == g_ osTypes[i].cim)304 { 305 strType = Global::OSTypeId(g_ osTypes[i].osType);249 for (size_t i = 0; i < RT_ELEMENTS(g_aOsTypes); ++i) 250 { 251 if (c == g_aOsTypes[i].cim) 252 { 253 strType = Global::OSTypeId(g_aOsTypes[i].osType); 306 254 return; 307 255 } … … 324 272 ovf::CIMOSType_T convertVBoxOSType2CIMOSType(const char *pcszVBox, BOOL fLongMode) 325 273 { 326 for (size_t i = 0; i < RT_ELEMENTS(g_ osTypes); ++i)327 { 328 if (!RTStrICmp(pcszVBox, Global::OSTypeId(g_ osTypes[i].osType)))329 { 330 if (fLongMode && !(g_ osTypes[i].osType & VBOXOSTYPE_x64))274 for (size_t i = 0; i < RT_ELEMENTS(g_aOsTypes); ++i) 275 { 276 if (!RTStrICmp(pcszVBox, Global::OSTypeId(g_aOsTypes[i].osType))) 277 { 278 if (fLongMode && !(g_aOsTypes[i].osType & VBOXOSTYPE_x64)) 331 279 { 332 VBOXOSTYPE enmDesiredOsType = (VBOXOSTYPE)((int)g_ osTypes[i].osType | (int)VBOXOSTYPE_x64);280 VBOXOSTYPE enmDesiredOsType = (VBOXOSTYPE)((int)g_aOsTypes[i].osType | (int)VBOXOSTYPE_x64); 333 281 size_t j = i; 334 while (++j < RT_ELEMENTS(g_ osTypes))335 if (g_ osTypes[j].osType == enmDesiredOsType)336 return g_ osTypes[j].cim;282 while (++j < RT_ELEMENTS(g_aOsTypes)) 283 if (g_aOsTypes[j].osType == enmDesiredOsType) 284 return g_aOsTypes[j].cim; 337 285 j = i; 338 286 while (--j > 0) 339 if (g_ osTypes[j].osType == enmDesiredOsType)340 return g_ osTypes[j].cim;287 if (g_aOsTypes[j].osType == enmDesiredOsType) 288 return g_aOsTypes[j].cim; 341 289 /* Not all OSes have 64-bit versions, so just return the 32-bit variant. */ 342 290 } 343 return g_ osTypes[i].cim;291 return g_aOsTypes[i].cim; 344 292 } 345 293 } … … 364 312 } 365 313 314 315 //////////////////////////////////////////////////////////////////////////////// 316 // 317 // Appliance constructor / destructor 318 // 319 // //////////////////////////////////////////////////////////////////////////////// 320 321 DEFINE_EMPTY_CTOR_DTOR(VirtualSystemDescription) 322 323 HRESULT VirtualSystemDescription::FinalConstruct() 324 { 325 return BaseFinalConstruct(); 326 } 327 328 void VirtualSystemDescription::FinalRelease() 329 { 330 uninit(); 331 332 BaseFinalRelease(); 333 } 334 335 Appliance::Appliance() 336 : mVirtualBox(NULL) 337 { 338 } 339 340 Appliance::~Appliance() 341 { 342 } 343 344 345 HRESULT Appliance::FinalConstruct() 346 { 347 return BaseFinalConstruct(); 348 } 349 350 void Appliance::FinalRelease() 351 { 352 uninit(); 353 354 BaseFinalRelease(); 355 } 356 357 358 //////////////////////////////////////////////////////////////////////////////// 359 // 360 // Internal helpers 361 // 362 //////////////////////////////////////////////////////////////////////////////// 363 364 366 365 //////////////////////////////////////////////////////////////////////////////// 367 366 // … … 411 410 m->m_pSecretKeyStore = new SecretKeyStore(false /* fRequireNonPageable*/); 412 411 AssertReturn(m->m_pSecretKeyStore, E_FAIL); 413 414 i_initApplianceIONameMap();415 412 416 413 rc = i_initSetOfSupportedStandardsURI(); … … 706 703 Utf8Str strTrgFormat = Utf8Str(bstrFormatName); 707 704 708 supportedStandardsURI.insert(std::make_pair(Utf8Str( strISOURI), strTrgFormat));705 supportedStandardsURI.insert(std::make_pair(Utf8Str(g_pszISOURI), strTrgFormat)); 709 706 } 710 707 … … 720 717 Utf8Str strTrgFormat = Utf8Str(bstrFormatName); 721 718 722 supportedStandardsURI.insert(std::make_pair(Utf8Str( strVMDKStreamURI), strTrgFormat));723 supportedStandardsURI.insert(std::make_pair(Utf8Str( strVMDKSparseURI), strTrgFormat));724 supportedStandardsURI.insert(std::make_pair(Utf8Str( strVMDKCompressedURI), strTrgFormat));725 supportedStandardsURI.insert(std::make_pair(Utf8Str( strVMDKCompressedURI2), strTrgFormat));719 supportedStandardsURI.insert(std::make_pair(Utf8Str(g_pszVMDKStreamURI), strTrgFormat)); 720 supportedStandardsURI.insert(std::make_pair(Utf8Str(g_pszVMDKSparseURI), strTrgFormat)); 721 supportedStandardsURI.insert(std::make_pair(Utf8Str(g_pszVMDKCompressedURI), strTrgFormat)); 722 supportedStandardsURI.insert(std::make_pair(Utf8Str(g_pszVMDKCompressedURI2), strTrgFormat)); 726 723 } 727 724 … … 737 734 Utf8Str strTrgFormat = Utf8Str(bstrFormatName); 738 735 739 supportedStandardsURI.insert(std::make_pair(Utf8Str( strVHDURI), strTrgFormat));736 supportedStandardsURI.insert(std::make_pair(Utf8Str(g_pszrVHDURI), strTrgFormat)); 740 737 } 741 738 … … 768 765 return uri; 769 766 } 770 771 HRESULT Appliance::i_initApplianceIONameMap()772 {773 HRESULT rc = S_OK;774 if (!applianceIONameMap.empty())775 return rc;776 777 applianceIONameMap.insert(std::make_pair(applianceIOTar, applianceIOTarName));778 applianceIONameMap.insert(std::make_pair(applianceIOFile, applianceIOFileName));779 applianceIONameMap.insert(std::make_pair(applianceIOSha, applianceIOShaName));780 781 return rc;782 }783 784 Utf8Str Appliance::i_applianceIOName(APPLIANCEIONAME type) const785 {786 Utf8Str name;787 std::map<APPLIANCEIONAME, Utf8Str>::const_iterator cit = applianceIONameMap.find(type);788 if (cit != applianceIONameMap.end())789 {790 name = cit->second;791 }792 793 return name;794 }795 796 767 797 768 /**
Note:
See TracChangeset
for help on using the changeset viewer.