- Timestamp:
- May 25, 2019 5:18:05 PM (6 years ago)
- Location:
- trunk/src/VBox/Main/src-server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/ApplianceImpl.cpp
r78428 r78749 1019 1019 1020 1020 /* Create the progress object */ 1021 pProgress.createObject(); 1021 try 1022 { 1023 rc = pProgress.createObject(); 1024 if (FAILED(rc)) 1025 return rc; 1026 } 1027 catch (std::bad_alloc &) 1028 { 1029 return E_OUTOFMEMORY; 1030 } 1022 1031 1023 1032 // compute the disks weight (this sets ulTotalDisksMB and cDisks in the instance data) … … 1026 1035 m->ulWeightForManifestOperation = 0; 1027 1036 1028 ULONG cOperations; 1037 ULONG cOperations = 1 // one for XML setup 1038 + m->cDisks; // plus one per disk 1029 1039 ULONG ulTotalOperationsWeight; 1030 1031 cOperations = 1 // one for XML setup1032 + m->cDisks; // plus one per disk1033 1040 if (m->ulTotalDisksMB) 1034 1041 { … … 1064 1071 case ImportS3: 1065 1072 { 1066 cOperations += 1 + 1; // another one for the manifest file & another one for the import1073 cOperations += 1 + 1; // another one for the manifest file & another one for the import 1067 1074 ulTotalOperationsWeight = m->ulTotalDisksMB; 1068 1075 if (!m->ulTotalDisksMB) … … 1081 1088 case WriteS3: 1082 1089 { 1083 cOperations += 1 + 1; // another one for the mf & another one for temporary creation1090 cOperations += 1 + 1; // another one for the mf & another one for temporary creation 1084 1091 1085 1092 if (m->ulTotalDisksMB) … … 1110 1117 m->ulTotalDisksMB, m->cDisks, cOperations, ulTotalOperationsWeight, m->ulWeightForXmlOperation)); 1111 1118 1112 rc = pProgress->init(mVirtualBox, static_cast<IAppliance*>(this), 1113 Bstr(strDescription).raw(), 1114 TRUE /* aCancelable */, 1115 cOperations, // ULONG cOperations, 1116 ulTotalOperationsWeight, // ULONG ulTotalOperationsWeight, 1117 Bstr(strDescription).raw(), // CBSTR bstrFirstOperationDescription, 1118 m->ulWeightForXmlOperation); // ULONG ulFirstOperationWeight, 1119 return rc; 1119 return pProgress->init(mVirtualBox, static_cast<IAppliance*>(this), 1120 strDescription, 1121 TRUE /* aCancelable */, 1122 cOperations, // ULONG cOperations, 1123 ulTotalOperationsWeight, // ULONG ulTotalOperationsWeight, 1124 strDescription, // CBSTR bstrFirstOperationDescription, 1125 m->ulWeightForXmlOperation); // ULONG ulFirstOperationWeight, 1120 1126 } 1121 1127 -
trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp
r78748 r78749 782 782 if (aOptions.size()) 783 783 { 784 m->optListImport.setCapacity(aOptions.size()); 785 for (size_t i = 0; i < aOptions.size(); ++i) 786 { 787 m->optListImport.insert(i, aOptions[i]); 784 try 785 { 786 m->optListImport.setCapacity(aOptions.size()); 787 for (size_t i = 0; i < aOptions.size(); ++i) 788 m->optListImport.insert(i, aOptions[i]); 789 } 790 catch (std::bad_alloc &) 791 { 792 return E_OUTOFMEMORY; 788 793 } 789 794 } … … 803 808 804 809 ComObjPtr<Progress> progress; 805 HRESULT rc = S_OK; 806 try 807 { 808 rc = i_importImpl(m->locInfo, progress); 809 } 810 catch (HRESULT aRC) 811 { 812 rc = aRC; 813 } 814 815 if (SUCCEEDED(rc)) 816 /* Return progress to the caller */ 810 HRESULT hrc = i_importImpl(m->locInfo, progress); 811 if (SUCCEEDED(hrc)) 817 812 progress.queryInterfaceTo(aProgress.asOutParam()); 818 813 819 return rc;814 return hrc; 820 815 } 821 816 … … 2818 2813 ComObjPtr<Progress> &progress) 2819 2814 { 2820 HRESULT rc = S_OK; 2821 2822 SetUpProgressMode mode; 2823 if (locInfo.storageType == VFSType_File) 2824 mode = ImportFile; 2825 else if (locInfo.storageType == VFSType_Cloud) 2826 mode = ImportCloud; 2815 HRESULT rc; 2816 2817 /* Initialize our worker task */ 2818 ThreadTask *pTask; 2819 if (locInfo.storageType != VFSType_Cloud) 2820 { 2821 rc = i_setUpProgress(progress, Utf8StrFmt(tr("Importing appliance '%s'"), locInfo.strPath.c_str()), 2822 locInfo.storageType == VFSType_File ? ImportFile : ImportS3); 2823 if (FAILED(rc)) 2824 return setError(rc, tr("Failed to create task for importing appliance into VirtualBox")); 2825 try 2826 { 2827 pTask = new TaskOVF(this, TaskOVF::Import, locInfo, progress); 2828 } 2829 catch (std::bad_alloc &) 2830 { 2831 return E_OUTOFMEMORY; 2832 } 2833 } 2827 2834 else 2828 mode = ImportS3; 2829 2830 /* Initialize our worker task */ 2831 TaskOVF* ovfTask = NULL; 2832 TaskCloud* cloudTask = NULL; 2833 try 2834 { 2835 if (mode == ImportFile) 2836 { 2837 rc = i_setUpProgress(progress, 2838 BstrFmt(tr("Importing appliance '%s'"), locInfo.strPath.c_str()), 2839 mode); 2840 if (FAILED(rc)) throw rc; 2841 2842 ovfTask = new TaskOVF(this, TaskOVF::Import, locInfo, progress); 2843 rc = ovfTask->createThread(); 2844 } 2845 else if (mode == ImportCloud) 2846 { 2847 progress.createObject(); 2848 if (locInfo.strProvider.equals("OCI")) 2849 { 2850 /* 2851 * 1. Create a custom image from the instance 2852 * - 2 operations (starting and waiting) 2853 * 2. Import the custom image into the Object Storage (OCI format - TAR file with QCOW2 image and JSON file) 2854 * - 2 operations (starting and waiting) 2855 * 3. Download the object from the Object Storage 2856 * - 2 operations (starting and waiting) 2857 * 4. Open the object, extract QCOW2 image and convert one QCOW2->VDI 2858 * - 1 operation (extracting and conversion are piped) 2859 * 5. Create VM with user settings and attach the converted image to VM 2860 * - 1 operation. 2861 * sum up = 2+2+2+1+1 = 8 op 2862 */ 2863 2864 /* 2865 * See src/VBox/ExtPacks/Puel/OCI/OCICloudClient.h. 2866 * Weight of cloud import operations (1-3 items from above): 2867 * Total = 750 = 10+40+50+50+200x2+200. 2868 * 2869 * Weight of local import operations (4-5 items from above): 2870 * Total = 250 = 200 (extract and convert) + 50 (create VM, attach disks) 2871 */ 2872 progress->init(mVirtualBox, static_cast<IAppliance*>(this), 2873 Bstr("Importing VM from Cloud...").raw(), 2874 TRUE /* aCancelable */, 2875 8, // ULONG cOperations, 2876 1000, // ULONG ulTotalOperationsWeight, 2877 Bstr("Importing VM from Cloud...").raw(), // aFirstOperationDescription 2878 10); // ULONG ulFirstOperationWeight 2879 } 2880 else 2881 return setErrorVrc(VBOX_E_NOT_SUPPORTED, 2882 tr("Only \"OCI\" cloud provider is supported for now. \"%s\" isn't supported."), 2883 locInfo.strProvider.c_str()); 2884 2885 cloudTask = new TaskCloud(this, TaskCloud::Import, locInfo, progress); 2886 rc = cloudTask->createThread(); 2887 if (FAILED(rc)) throw rc; 2888 } 2889 } 2890 catch (HRESULT aRc) 2891 { 2892 rc = aRc; 2893 } 2894 catch (...) 2895 { 2896 rc = setError(VBOX_E_OBJECT_NOT_FOUND, 2897 tr("Could not create a task object for importing appliance into VirtualBox")); 2898 } 2899 2900 if (FAILED(rc)) 2901 { 2902 if (ovfTask) 2903 delete ovfTask; 2904 if (cloudTask) 2905 delete cloudTask; 2906 throw rc; 2907 } 2908 2909 return rc; 2835 { 2836 if (locInfo.strProvider.equals("OCI")) 2837 { 2838 /* 2839 * 1. Create a custom image from the instance: 2840 * - 2 operations (starting and waiting) 2841 * 2. Import the custom image into the Object Storage (OCI format - TAR file with QCOW2 image and JSON file): 2842 * - 2 operations (starting and waiting) 2843 * 3. Download the object from the Object Storage: 2844 * - 2 operations (starting and waiting) 2845 * 4. Open the object, extract QCOW2 image and convert one QCOW2->VDI: 2846 * - 1 operation (extracting and conversion are piped) 2847 * 5. Create VM with user settings and attach the converted image to VM: 2848 * - 1 operation. 2849 * 2850 * Total: 2+2+2+1+1 = 8 operations 2851 * 2852 * See src/VBox/ExtPacks/Puel/OCI/OCICloudClient.h. 2853 * Weight of cloud import operations (1-3 items from above): 2854 * Total = 750 = 10+40+50+50+200x2+200. 2855 * 2856 * Weight of local import operations (4-5 items from above): 2857 * Total = 250 = 200 (extract and convert) + 50 (create VM, attach disks) 2858 */ 2859 try 2860 { 2861 rc = progress.createObject(); 2862 if (SUCCEEDED(rc)) 2863 rc = progress->init(mVirtualBox, static_cast<IAppliance *>(this), 2864 Utf8Str(tr("Importing VM from Cloud...")), 2865 TRUE /* aCancelable */, 2866 8, // ULONG cOperations, 2867 1000, // ULONG ulTotalOperationsWeight, 2868 Utf8Str(tr("Importing VM from Cloud...")), // aFirstOperationDescription 2869 10); // ULONG ulFirstOperationWeight 2870 if (SUCCEEDED(rc)) 2871 pTask = new TaskCloud(this, TaskCloud::Import, locInfo, progress); 2872 else 2873 pTask = NULL; /* shut up vcc */ 2874 } 2875 catch (std::bad_alloc &) 2876 { 2877 return E_OUTOFMEMORY; 2878 } 2879 if (FAILED(rc)) 2880 return setError(rc, tr("Failed to create task for importing appliance into VirtualBox")); 2881 } 2882 else 2883 return setError(E_NOTIMPL, tr("Only \"OCI\" cloud provider is supported for now. \"%s\" isn't supported."), 2884 locInfo.strProvider.c_str()); 2885 } 2886 2887 /* 2888 * Start the task thread. 2889 */ 2890 rc = pTask->createThread(); 2891 pTask = NULL; 2892 if (SUCCEEDED(rc)) 2893 return rc; 2894 return setError(rc, tr("Failed to start thread for importing appliance into VirtualBox")); 2910 2895 } 2911 2896
Note:
See TracChangeset
for help on using the changeset viewer.