Changeset 46518 in vbox for trunk/src/VBox/Main/src-server/ApplianceImpl.cpp
- Timestamp:
- Jun 13, 2013 10:07:09 AM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 86374
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/ApplianceImpl.cpp
r46341 r46518 19 19 #include <iprt/path.h> 20 20 #include <iprt/cpp/utils.h> 21 22 21 #include <VBox/com/array.h> 22 #include <map> 23 23 24 24 #include "ApplianceImpl.h" … … 29 29 #include "ProgressImpl.h" 30 30 #include "MachineImpl.h" 31 31 #include "MediumFormatImpl.h" 32 #include "SystemPropertiesImpl.h" 32 33 #include "AutoCaller.h" 33 34 #include "Logging.h" … … 42 43 // 43 44 //////////////////////////////////////////////////////////////////////////////// 45 46 static const char* const strISOURI = "http://www.ecma-international.org/publications/standards/Ecma-119.htm"; 47 static const char* const strVMDKStreamURI = "http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized"; 48 static const char* const strVMDKSparseURI = "http://www.vmware.com/specifications/vmdk.html#sparse"; 49 static const char* const strVMDKCompressedURI = "http://www.vmware.com/specifications/vmdk.html#compressed"; 50 static const char* const strVMDKCompressedURI2 = "http://www.vmware.com/interfaces/specifications/vmdk.html#compressed"; 51 static const char* const strVHDURI = "http://go.microsoft.com/fwlink/?LinkId=137171"; 52 53 static std::map<Utf8Str, Utf8Str> supportedStandardsURI; 54 55 static const char* const applianceIOTarName = "Appliance::IOTar"; 56 static const char* const applianceIOFileName = "Appliance::IOFile"; 57 58 static std::map<APPLIANCEIONAME, Utf8Str> applianceIONameMap; 44 59 45 60 static const struct … … 304 319 } 305 320 321 306 322 //////////////////////////////////////////////////////////////////////////////// 307 323 // … … 355 371 HRESULT Appliance::init(VirtualBox *aVirtualBox) 356 372 { 373 HRESULT rc = S_OK; 357 374 /* Enclose the state transition NotReady->InInit->Ready */ 358 375 AutoInitSpan autoInitSpan(this); … … 365 382 m = new Data; 366 383 384 initApplianceIONameMap(); 385 386 rc = initSetOfSupportedStandardsURI(); 387 367 388 /* Confirm a successful initialization */ 368 389 autoInitSpan.setSucceeded(); 369 390 370 return S_OK;391 return rc; 371 392 } 372 393 … … 604 625 //////////////////////////////////////////////////////////////////////////////// 605 626 627 HRESULT Appliance::initSetOfSupportedStandardsURI() 628 { 629 HRESULT rc = S_OK; 630 if (!supportedStandardsURI.empty()) 631 return rc; 632 633 /* Get the system properties. */ 634 SystemProperties *pSysProps = mVirtualBox->getSystemProperties(); 635 { 636 ComObjPtr<MediumFormat> trgFormat = pSysProps->mediumFormatFromExtension("iso"); 637 if (trgFormat.isNull()) 638 return setError(E_FAIL, tr("Can't find appropriate medium format for ISO type of a virtual disk.")); 639 640 Bstr bstrFormatName; 641 rc = trgFormat->COMGETTER(Name)(bstrFormatName.asOutParam()); 642 if (FAILED(rc)) return rc; 643 644 Utf8Str strTrgFormat = Utf8Str(bstrFormatName); 645 646 supportedStandardsURI.insert(std::make_pair(Utf8Str(strISOURI), strTrgFormat)); 647 } 648 649 { 650 ComObjPtr<MediumFormat> trgFormat = pSysProps->mediumFormatFromExtension("vmdk"); 651 if (trgFormat.isNull()) 652 return setError(E_FAIL, tr("Can't find appropriate medium format for VMDK type of a virtual disk.")); 653 654 Bstr bstrFormatName; 655 rc = trgFormat->COMGETTER(Name)(bstrFormatName.asOutParam()); 656 if (FAILED(rc)) return rc; 657 658 Utf8Str strTrgFormat = Utf8Str(bstrFormatName); 659 660 supportedStandardsURI.insert(std::make_pair(Utf8Str(strVMDKStreamURI), strTrgFormat)); 661 supportedStandardsURI.insert(std::make_pair(Utf8Str(strVMDKSparseURI), strTrgFormat)); 662 supportedStandardsURI.insert(std::make_pair(Utf8Str(strVMDKCompressedURI), strTrgFormat)); 663 supportedStandardsURI.insert(std::make_pair(Utf8Str(strVMDKCompressedURI2), strTrgFormat)); 664 } 665 666 { 667 ComObjPtr<MediumFormat> trgFormat = pSysProps->mediumFormatFromExtension("vhd"); 668 if (trgFormat.isNull()) 669 return setError(E_FAIL, tr("Can't find appropriate medium format for VHD type of a virtual disk.")); 670 671 Bstr bstrFormatName; 672 rc = trgFormat->COMGETTER(Name)(bstrFormatName.asOutParam()); 673 if (FAILED(rc)) return rc; 674 675 Utf8Str strTrgFormat = Utf8Str(bstrFormatName); 676 677 supportedStandardsURI.insert(std::make_pair(Utf8Str(strVHDURI), strTrgFormat)); 678 } 679 680 return rc; 681 } 682 683 Utf8Str Appliance::typeOfVirtualDiskFormatFromURI(Utf8Str uri) const 684 { 685 Utf8Str type; 686 std::map<Utf8Str, Utf8Str>::const_iterator cit = supportedStandardsURI.find(uri); 687 if (cit != supportedStandardsURI.end()) 688 { 689 type = cit->second; 690 } 691 692 return type; 693 } 694 695 std::set<Utf8Str> Appliance::URIFromTypeOfVirtualDiskFormat(Utf8Str type) 696 { 697 std::set<Utf8Str> uri; 698 std::map<Utf8Str, Utf8Str>::const_iterator cit = supportedStandardsURI.begin(); 699 while(cit != supportedStandardsURI.end()) 700 { 701 if (cit->second.compare(type,Utf8Str::CaseInsensitive) == 0) 702 uri.insert(cit->first); 703 ++cit; 704 } 705 706 return uri; 707 } 708 709 HRESULT Appliance::initApplianceIONameMap() 710 { 711 HRESULT rc = S_OK; 712 if (!applianceIONameMap.empty()) 713 return rc; 714 715 applianceIONameMap.insert(std::make_pair(applianceIOTar, applianceIOTarName)); 716 applianceIONameMap.insert(std::make_pair(applianceIOFile, applianceIOFileName)); 717 718 return rc; 719 } 720 721 Utf8Str Appliance::applianceIOName(APPLIANCEIONAME type) const 722 { 723 Utf8Str name; 724 std::map<APPLIANCEIONAME, Utf8Str>::const_iterator cit = applianceIONameMap.find(type); 725 if (cit != applianceIONameMap.end()) 726 { 727 name = cit->second; 728 } 729 730 return name; 731 } 732 606 733 /** 607 734 * Returns true if the appliance is in "idle" state. This should always be the
Note:
See TracChangeset
for help on using the changeset viewer.