Changeset 29875 in vbox for trunk/src/VBox
- Timestamp:
- May 28, 2010 6:15:15 PM (15 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ApplianceImpl.cpp
r28800 r29875 673 673 } 674 674 675 /** 676 * Called from Appliance::importImpl() and Appliance::writeImpl() to set up a 677 * progress object with the proper weights and maximum progress values. 678 * 679 * @param pProgress 680 * @param bstrDescription 681 * @param mode 682 * @return 683 */ 675 684 HRESULT Appliance::setUpProgress(ComObjPtr<Progress> &pProgress, 676 685 const Bstr &bstrDescription, … … 685 694 disksWeight(); 686 695 696 m->ulWeightForManifestOperation = 0; 697 687 698 ULONG cOperations; 688 699 ULONG ulTotalOperationsWeight; … … 692 703 if (m->ulTotalDisksMB) 693 704 { 694 m->ulWeight PerOperation = (ULONG)((double)m->ulTotalDisksMB * 1 / 100); // use 1% of the progress for the XML695 ulTotalOperationsWeight = m->ulTotalDisksMB + m->ulWeight PerOperation;705 m->ulWeightForXmlOperation = (ULONG)((double)m->ulTotalDisksMB * 1 / 100); // use 1% of the progress for the XML 706 ulTotalOperationsWeight = m->ulTotalDisksMB + m->ulWeightForXmlOperation; 696 707 } 697 708 else 698 709 { 699 710 // no disks to export: 700 m->ulWeight PerOperation = 1;711 m->ulWeightForXmlOperation = 1; 701 712 ulTotalOperationsWeight = 1; 702 713 } … … 704 715 switch (mode) 705 716 { 706 case Regular: 717 case ImportFileNoManifest: 718 break; 719 720 case ImportFileWithManifest: 721 case WriteFile: 722 ++cOperations; // another one for creating the manifest 723 724 // assume that checking or creating the manifest will take 10% of the time it takes to export the disks 725 m->ulWeightForManifestOperation = m->ulTotalDisksMB / 10; 726 ulTotalOperationsWeight += m->ulWeightForManifestOperation; 707 727 break; 708 728 … … 718 738 ulTotalOperationsWeight += ulImportWeight; 719 739 720 m->ulWeight PerOperation = ulImportWeight; /* save for using later */740 m->ulWeightForXmlOperation = ulImportWeight; /* save for using later */ 721 741 722 742 ULONG ulInitWeight = (ULONG)((double)ulTotalOperationsWeight * 0.1 / 100); // use 0.1% for init … … 731 751 if (m->ulTotalDisksMB) 732 752 { 733 m->ulWeight PerOperation = (ULONG)((double)m->ulTotalDisksMB * 1 / 100); // use 1% of the progress for OVF file upload (we didn't know the size at this point)734 ulTotalOperationsWeight = m->ulTotalDisksMB + m->ulWeight PerOperation;753 m->ulWeightForXmlOperation = (ULONG)((double)m->ulTotalDisksMB * 1 / 100); // use 1% of the progress for OVF file upload (we didn't know the size at this point) 754 ulTotalOperationsWeight = m->ulTotalDisksMB + m->ulWeightForXmlOperation; 735 755 } 736 756 else … … 738 758 // no disks to export: 739 759 ulTotalOperationsWeight = 1; 740 m->ulWeight PerOperation = 1;760 m->ulWeightForXmlOperation = 1; 741 761 } 742 762 ULONG ulOVFCreationWeight = (ULONG)((double)ulTotalOperationsWeight * 50.0 / 100.0); /* Use 50% for the creation of the OVF & the disks */ … … 746 766 } 747 767 748 Log(("Setting up progress object: ulTotalMB = %d, cDisks = %d, => cOperations = %d, ulTotalOperationsWeight = %d, m->ulWeight PerOperation = %d\n",749 m->ulTotalDisksMB, m->cDisks, cOperations, ulTotalOperationsWeight, m->ulWeight PerOperation));768 Log(("Setting up progress object: ulTotalMB = %d, cDisks = %d, => cOperations = %d, ulTotalOperationsWeight = %d, m->ulWeightForXmlOperation = %d\n", 769 m->ulTotalDisksMB, m->cDisks, cOperations, ulTotalOperationsWeight, m->ulWeightForXmlOperation)); 750 770 751 771 rc = pProgress->init(mVirtualBox, static_cast<IAppliance*>(this), … … 755 775 ulTotalOperationsWeight, // ULONG ulTotalOperationsWeight, 756 776 bstrDescription, // CBSTR bstrFirstOperationDescription, 757 m->ulWeight PerOperation); // ULONG ulFirstOperationWeight,777 m->ulWeightForXmlOperation); // ULONG ulFirstOperationWeight, 758 778 return rc; 759 779 } -
trunk/src/VBox/Main/ApplianceImplExport.cpp
r29873 r29875 628 628 try 629 629 { 630 Bstr progressDesc = BstrFmt(tr("Export appliance '%s'"), 631 aLocInfo.strPath.c_str()); 632 633 rc = setUpProgress(aProgress, progressDesc, (aLocInfo.storageType == VFSType_File) ? Regular : WriteS3); 630 rc = setUpProgress(aProgress, 631 BstrFmt(tr("Export appliance '%s'"), aLocInfo.strPath.c_str()), 632 (aLocInfo.storageType == VFSType_File) ? WriteFile : WriteS3); 634 633 635 634 /* Initialize our worker task */ … … 1518 1517 1519 1518 // advance to the next operation 1520 if (!pProgress.isNull()) 1521 pProgress->SetNextOperation(BstrFmt(tr("Exporting to disk image '%s'"), strTargetFilePath.c_str()), 1522 pDiskEntry->ulSizeMB); // operation's weight, as set up with the IProgress originally); 1519 pProgress->SetNextOperation(BstrFmt(tr("Exporting to disk image '%s'"), strTargetFilePath.c_str()), 1520 pDiskEntry->ulSizeMB); // operation's weight, as set up with the IProgress originally); 1523 1521 1524 1522 // now wait for the background disk operation to complete; this throws HRESULTs on error … … 1596 1594 writer.write(locInfo.strPath.c_str(), false /*fSafe*/); 1597 1595 1598 /* Create & write the manifest file */ 1596 // Create & write the manifest file 1597 Utf8Str strMfFile = manifestFileName(locInfo.strPath.c_str()); 1598 const char *pcszManifestFileOnly = RTPathFilename(strMfFile.c_str()); 1599 pProgress->SetNextOperation(BstrFmt(tr("Creating manifest file '%s'"), pcszManifestFileOnly), 1600 m->ulWeightForManifestOperation); // operation's weight, as set up with the IProgress originally); 1601 1599 1602 const char** ppManifestFiles = (const char**)RTMemAlloc(sizeof(char*)*diskList.size() + 1); 1600 1603 ppManifestFiles[0] = locInfo.strPath.c_str(); … … 1605 1608 ++it1, ++i) 1606 1609 ppManifestFiles[i] = (*it1).c_str(); 1607 Utf8Str strMfFile = manifestFileName(locInfo.strPath.c_str());1608 1610 int vrc = RTManifestWriteFiles(strMfFile.c_str(), ppManifestFiles, diskList.size()+1); 1609 1611 RTMemFree(ppManifestFiles); 1610 1612 if (RT_FAILURE(vrc)) 1611 1613 throw setError(VBOX_E_FILE_ERROR, 1612 tr("Could n't create manifest file '%s' (%Rrc)"),1613 RTPathFilename(strMfFile.c_str()), vrc);1614 tr("Could not create manifest file '%s' (%Rrc)"), 1615 pcszManifestFileOnly, vrc); 1614 1616 } 1615 1617 catch(xml::Error &x) … … 1705 1707 tr("Cannot find source file '%s'"), strTmpOvf.c_str()); 1706 1708 /* Add the OVF file */ 1707 filesList.push_back(pair<Utf8Str, ULONG>(strTmpOvf, m->ulWeight PerOperation)); /* Use 1% of the total for the OVF file upload */1709 filesList.push_back(pair<Utf8Str, ULONG>(strTmpOvf, m->ulWeightForXmlOperation)); /* Use 1% of the total for the OVF file upload */ 1708 1710 Utf8Str strMfFile = manifestFileName(strTmpOvf); 1709 filesList.push_back(pair<Utf8Str, ULONG>(strMfFile , m->ulWeight PerOperation)); /* Use 1% of the total for the manifest file upload */1711 filesList.push_back(pair<Utf8Str, ULONG>(strMfFile , m->ulWeightForXmlOperation)); /* Use 1% of the total for the manifest file upload */ 1710 1712 1711 1713 /* Now add every disks of every virtual system */ … … 1748 1750 char *pszFilename = RTPathFilename(s.first.c_str()); 1749 1751 /* Advance to the next operation */ 1750 if (!pTask->pProgress.isNull()) 1751 pTask->pProgress->SetNextOperation(BstrFmt(tr("Uploading file '%s'"), pszFilename), s.second); 1752 pTask->pProgress->SetNextOperation(BstrFmt(tr("Uploading file '%s'"), pszFilename), s.second); 1752 1753 vrc = RTS3PutKey(hS3, bucket.c_str(), pszFilename, s.first.c_str()); 1753 1754 if (RT_FAILURE(vrc)) -
trunk/src/VBox/Main/ApplianceImplImport.cpp
r29873 r29875 770 770 hS3 = NIL_RTS3; 771 771 772 if (!pTask->pProgress.isNull()) 773 pTask->pProgress->SetNextOperation(Bstr(tr("Reading")), 1); 772 pTask->pProgress->SetNextOperation(Bstr(tr("Reading")), 1); 774 773 775 774 /* Prepare the temporary reading of the OVF */ … … 932 931 * @return 933 932 */ 934 HRESULT Appliance::importImpl(const LocationInfo &aLocInfo, ComObjPtr<Progress> &aProgress) 933 HRESULT Appliance::importImpl(const LocationInfo &aLocInfo, 934 ComObjPtr<Progress> &aProgress) 935 935 { 936 Bstr progressDesc = BstrFmt(tr("Importing appliance '%s'"),937 aLocInfo.strPath.c_str());938 936 HRESULT rc = S_OK; 939 937 938 SetUpProgressMode mode; 939 m->strManifestFile.setNull(); 940 if (aLocInfo.storageType == VFSType_File) 941 { 942 Utf8Str strMfFile = manifestFileName(aLocInfo.strPath); 943 if (RTPathExists(strMfFile.c_str())) 944 { 945 m->strManifestFile = strMfFile; 946 mode = ImportFileWithManifest; 947 } 948 else 949 mode = ImportFileNoManifest; 950 } 951 else 952 mode = ImportS3; 953 940 954 rc = setUpProgress(aProgress, 941 progressDesc,942 (aLocInfo.storageType == VFSType_File) ? Regular : ImportS3);955 BstrFmt(tr("Importing appliance '%s'"), aLocInfo.strPath.c_str()), 956 mode); 943 957 if (FAILED(rc)) throw rc; 944 958 … … 1003 1017 */ 1004 1018 HRESULT Appliance::manifestVerify(const LocationInfo &locInfo, 1005 const ovf::OVFReader &reader) 1019 const ovf::OVFReader &reader, 1020 ComObjPtr<Progress> &pProgress) 1006 1021 { 1007 1022 HRESULT rc = S_OK; 1008 1023 1009 Utf8Str strMfFile = manifestFileName(locInfo.strPath); 1010 if (RTPathExists(strMfFile.c_str())) 1011 { 1024 if (!m->strManifestFile.isEmpty()) 1025 { 1026 const char *pcszManifestFileOnly = RTPathFilename(m->strManifestFile.c_str()); 1027 pProgress->SetNextOperation(BstrFmt(tr("Verifying manifest file '%s'"), pcszManifestFileOnly), 1028 m->ulWeightForManifestOperation); // operation's weight, as set up with the IProgress originally 1029 1012 1030 list<Utf8Str> filesList; 1013 1031 Utf8Str strSrcDir(locInfo.strPath); … … 1054 1072 // this call can take a very long time 1055 1073 size_t cIndexOnError; 1056 vrc = RTManifestVerify( strMfFile.c_str(),1074 vrc = RTManifestVerify(m->strManifestFile.c_str(), 1057 1075 pTestList, 1058 1076 filesList.size() + 1, … … 1063 1081 tr("The SHA1 digest of '%s' does not match the one in '%s'"), 1064 1082 RTPathFilename(pTestList[cIndexOnError].pszTestFile), 1065 RTPathFilename(strMfFile.c_str()));1083 pcszManifestFileOnly); 1066 1084 else if (RT_FAILURE(vrc)) 1067 1085 rc = setError(VBOX_E_FILE_ERROR, 1068 1086 tr("Could not verify the content of '%s' against the available files (%Rrc)"), 1069 RTPathFilename(strMfFile.c_str()),1087 pcszManifestFileOnly, 1070 1088 vrc); 1071 1089 … … 1130 1148 { 1131 1149 // if a manifest file exists, verify the content; we then need all files which are referenced by the OVF & the OVF itself 1132 rc = manifestVerify(locInfo, reader );1150 rc = manifestVerify(locInfo, reader, pProgress); 1133 1151 if (FAILED(rc)) throw rc; 1134 1152 … … 1308 1326 1309 1327 // advance to the next operation 1310 stack.pProgress->SetNextOperation(BstrFmt(tr("Creating virtualdisk image '%s'"), strTargetPath.c_str()),1328 stack.pProgress->SetNextOperation(BstrFmt(tr("Creating disk image '%s'"), strTargetPath.c_str()), 1311 1329 di.ulSuggestedSizeMB); // operation's weight, as set up with the IProgress originally 1312 1330 } … … 2200 2218 hS3 = NIL_RTS3; 2201 2219 2202 if (!pTask->pProgress.isNull()) 2203 pTask->pProgress->SetNextOperation(BstrFmt(tr("Importing appliance")), m->ulWeightPerOperation); 2220 pTask->pProgress->SetNextOperation(BstrFmt(tr("Importing appliance")), m->ulWeightForXmlOperation); 2204 2221 2205 2222 ComObjPtr<Progress> progress; -
trunk/src/VBox/Main/include/ApplianceImpl.h
r29873 r29875 120 120 121 121 void disksWeight(); 122 enum SetUpProgressMode { Regular, ImportS3, WriteS3 };122 enum SetUpProgressMode { ImportFileWithManifest, ImportFileNoManifest, ImportS3, WriteFile, WriteS3 }; 123 123 HRESULT setUpProgress(ComObjPtr<Progress> &pProgress, 124 124 const Bstr &bstrDescription, … … 145 145 146 146 HRESULT importImpl(const LocationInfo &aLocInfo, ComObjPtr<Progress> &aProgress); 147 HRESULT manifestVerify(const LocationInfo &locInfo, const ovf::OVFReader &reader );147 HRESULT manifestVerify(const LocationInfo &locInfo, const ovf::OVFReader &reader, ComObjPtr<Progress> &pProgress); 148 148 149 149 HRESULT importFS(const LocationInfo &locInfo, ComObjPtr<Progress> &aProgress); -
trunk/src/VBox/Main/include/ApplianceImplPrivate.h
r29422 r29875 62 62 } 63 63 64 ApplianceState state;64 ApplianceState state; 65 65 66 LocationInfo locInfo;// location info for the currently processed OVF66 LocationInfo locInfo; // location info for the currently processed OVF 67 67 68 ovf::OVFReader *pReader; 69 70 bool fBusyWriting; // state protection; while this is true nobody else can call methods 68 ovf::OVFReader *pReader; 71 69 72 70 std::list< ComObjPtr<VirtualSystemDescription> > 73 virtualSystemDescriptions;71 virtualSystemDescriptions; 74 72 75 std::list<Utf8Str> 73 std::list<Utf8Str> llWarnings; 76 74 77 ULONG ulWeightPerOperation; 78 ULONG ulTotalDisksMB; 79 ULONG cDisks; 80 Utf8Str strOVFSHA1Digest; 75 Utf8Str strManifestFile; // on import, contains path of manifest file if it exists 76 77 ULONG ulWeightForXmlOperation; 78 ULONG ulWeightForManifestOperation; 79 ULONG ulTotalDisksMB; 80 ULONG cDisks; 81 Utf8Str strOVFSHA1Digest; 81 82 }; 82 83
Note:
See TracChangeset
for help on using the changeset viewer.