- Timestamp:
- Jun 2, 2017 3:10:54 PM (7 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
-
include/MediumImpl.h (modified) (3 diffs)
-
src-server/ApplianceImplExport.cpp (modified) (3 diffs)
-
src-server/MediumImpl.cpp (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/MediumImpl.h
r67237 r67244 382 382 class DeleteTask; 383 383 class MergeTask; 384 #ifndef VBOX_WITH_NEW_TAR_CREATOR 384 385 class ExportTask; 386 #endif 385 387 class ImportTask; 386 388 class EncryptTask; … … 395 397 friend class DeleteTask; 396 398 friend class MergeTask; 399 #ifndef VBOX_WITH_NEW_TAR_CREATOR 397 400 friend class ExportTask; 401 #endif 398 402 friend class ImportTask; 399 403 friend class EncryptTask; … … 408 412 HRESULT i_taskCompactHandler(Medium::CompactTask &task); 409 413 HRESULT i_taskResizeHandler(Medium::ResizeTask &task); 414 #ifndef VBOX_WITH_NEW_TAR_CREATOR 410 415 HRESULT i_taskExportHandler(Medium::ExportTask &task); 416 #endif 411 417 HRESULT i_taskImportHandler(Medium::ImportTask &task); 412 418 HRESULT i_taskEncryptHandler(Medium::EncryptTask &task); -
trunk/src/VBox/Main/src-server/ApplianceImplExport.cpp
r67231 r67244 2539 2539 * Export a disk image. 2540 2540 */ 2541 /** @todo this progress object needs to be hooked up to pTask->pProgress... */2542 ComObjPtr<Progress> pProgress2;2543 pProgress2.createObject();2544 rc = pProgress2->init(mVirtualBox, static_cast<IAppliance*>(this),2545 BstrFmt(tr("Creating medium '%s'"),2546 strTargetFilePath.c_str()).raw(), TRUE);2547 if (FAILED(rc)) throw rc;2548 2549 2541 #ifdef VBOX_WITH_NEW_TAR_CREATOR 2550 2542 /* For compressed VMDK fun, we let i_exportFile produce the image bytes. */ … … 2564 2556 m->m_pSecretKeyStore, 2565 2557 hVfsIosDst, 2566 p Progress2);2558 pTask->pProgress); 2567 2559 RTVfsIoStrmRelease(hVfsIosDst); 2568 2560 if (FAILED(rc)) throw rc; 2569 2561 #else 2562 /** @todo this progress object needs to be hooked up to pTask->pProgress... */ 2563 ComObjPtr<Progress> pProgress2; 2564 pProgress2.createObject(); 2565 rc = pProgress2->init(mVirtualBox, static_cast<IAppliance*>(this), 2566 BstrFmt(tr("Creating medium '%s'"), 2567 strTargetFilePath.c_str()).raw(), TRUE); 2568 if (FAILED(rc)) throw rc; 2569 2570 2570 rc = pSourceDisk->i_exportFile(strTargetFilePath.c_str(), 2571 2571 format, … … 2576 2576 pProgress2); 2577 2577 if (FAILED(rc)) throw rc; 2578 #endif2579 2578 2580 2579 ComPtr<IProgress> pProgress3(pProgress2); 2581 2580 // now wait for the background disk operation to complete; this throws HRESULTs on error 2582 2581 i_waitForAsyncProgress(pTask->pProgress, pProgress3); 2582 #endif 2583 2583 } 2584 2584 else -
trunk/src/VBox/Main/src-server/MediumImpl.cpp
r67239 r67244 651 651 }; 652 652 653 #ifndef VBOX_WITH_NEW_TAR_CREATOR 653 654 class Medium::ExportTask : public Medium::Task 654 655 { … … 660 661 MediumVariant_T aVariant, 661 662 SecretKeyStore *pSecretKeyStore, 662 #ifdef VBOX_WITH_NEW_TAR_CREATOR663 RTVFSIOSTREAM aVfsIosDst,664 #else665 663 VDINTERFACEIO *aVDImageIOIf, 666 664 void *aVDImageIOUser, 667 #endif668 665 MediumLockList *aSourceMediumLockList, 669 666 bool fKeepSourceMediumLockList = false) … … 680 677 mVDImageIfaces = aMedium->m->vdImageIfaces; 681 678 682 #ifdef VBOX_WITH_NEW_TAR_CREATOR683 int vrc = VDIfCreateFromVfsStream(aVfsIosDst, RTFILE_O_WRITE, &mpVfsIoIf);684 AssertRCReturnVoidStmt(vrc, mRC = E_FAIL);685 686 vrc = VDInterfaceAdd(&mpVfsIoIf->Core, "Medium::ExportTaskVfsIos",687 VDINTERFACETYPE_IO, mpVfsIoIf,688 sizeof(VDINTERFACEIO), &mVDImageIfaces);689 AssertRCReturnVoidStmt(vrc, mRC = E_FAIL);690 #else691 692 679 if (aVDImageIOIf) 693 680 { … … 697 684 AssertRCReturnVoidStmt(vrc, mRC = E_FAIL); 698 685 } 699 #endif700 686 m_strTaskName = "createExport"; 701 687 } … … 705 691 if (!mfKeepSourceMediumLockList && mpSourceMediumLockList) 706 692 delete mpSourceMediumLockList; 707 #ifdef VBOX_WITH_NEW_TAR_CREATOR708 if (mpVfsIoIf)709 {710 VDIfDestroyFromVfsStream(mpVfsIoIf);711 mpVfsIoIf = NULL;712 }713 #endif714 693 } 715 694 … … 719 698 MediumVariant_T mVariant; 720 699 PVDINTERFACE mVDImageIfaces; 721 PVDINTERFACEIO mpVfsIoIf; /**< Pointer to the VFS I/O stream to VD I/O interface wrapper. */722 700 SecretKeyStore *m_pSecretKeyStore; 723 701 … … 726 704 bool mfKeepSourceMediumLockList; 727 705 }; 706 #endif /* !VBOX_WITH_NEW_TAR_CREATOR */ 728 707 729 708 class Medium::ImportTask : public Medium::Task … … 978 957 } 979 958 959 #ifndef VBOX_WITH_NEW_TAR_CREATOR 980 960 /** 981 961 * Implementation code for the "export" task. … … 985 965 return mMedium->i_taskExportHandler(*this); 986 966 } 967 #endif 987 968 988 969 /** … … 6165 6146 * @param aProgress Progress object to use. 6166 6147 * @return 6148 * 6167 6149 * @note The source format is defined by the Medium instance. 6168 *6169 * @todo The only consumer of this method (Appliance::i_writeFSImpl) is already6170 * on a worker thread, so perhaps consider bypassing the thread here and6171 * run in the task synchronously? VBoxSVC has enough threads as it is...6172 6150 */ 6173 6151 HRESULT Medium::i_exportFile(const char *aFilename, … … 6186 6164 AssertReturn(aProgress.isNotNull(), E_INVALIDARG); 6187 6165 6166 #ifdef VBOX_WITH_NEW_TAR_CREATOR 6167 6168 AutoCaller autoCaller(this); 6169 HRESULT hrc = autoCaller.rc(); 6170 if (SUCCEEDED(hrc)) 6171 { 6172 /* 6173 * Setup VD interfaces. 6174 */ 6175 PVDINTERFACE pVDImageIfaces = m->vdImageIfaces; 6176 PVDINTERFACEIO pVfsIoIf; 6177 int vrc = VDIfCreateFromVfsStream(hVfsIosDst, RTFILE_O_WRITE, &pVfsIoIf); 6178 if (RT_SUCCESS(vrc)) 6179 { 6180 vrc = VDInterfaceAdd(&pVfsIoIf->Core, "Medium::ExportTaskVfsIos", VDINTERFACETYPE_IO, 6181 pVfsIoIf, sizeof(VDINTERFACEIO), &pVDImageIfaces); 6182 if (RT_SUCCESS(vrc)) 6183 { 6184 /* 6185 * Get a readonly hdd for this medium (source). 6186 */ 6187 Medium::CryptoFilterSettings CryptoSettingsRead; 6188 MediumLockList SourceMediumLockList; 6189 PVDISK pSrcHdd; 6190 hrc = i_openHddForReading(pKeyStore, &pSrcHdd, &SourceMediumLockList, &CryptoSettingsRead); 6191 if (SUCCEEDED(hrc)) 6192 { 6193 /* 6194 * Create the target medium. 6195 */ 6196 Utf8Str strDstFormat(aFormat->i_getId()); 6197 6198 /* ensure the target directory exists */ 6199 uint64_t fDstCapabilities = aFormat->i_getCapabilities(); 6200 if (fDstCapabilities & MediumFormatCapabilities_File) 6201 { 6202 Utf8Str strDstLocation(aFilename); 6203 hrc = VirtualBox::i_ensureFilePathExists(strDstLocation.c_str(), 6204 !(aVariant & MediumVariant_NoCreateDir) /* fCreate */); 6205 } 6206 if (SUCCEEDED(hrc)) 6207 { 6208 PVDISK pDstHdd; 6209 vrc = VDCreate(m->vdDiskIfaces, i_convertDeviceType(), &pDstHdd); 6210 if (RT_SUCCESS(vrc)) 6211 { 6212 /* 6213 * Create an interface for getting progress callbacks. 6214 */ 6215 VDINTERFACEPROGRESS ProgressIf = VDINTERFACEPROGRESS_INITALIZER(aProgress->i_vdProgressCallback); 6216 PVDINTERFACE pProgress = NULL; 6217 vrc = VDInterfaceAdd(&ProgressIf.Core, "export-progress", VDINTERFACETYPE_PROGRESS, 6218 &*aProgress, sizeof(ProgressIf), &pProgress); 6219 AssertRC(vrc); 6220 6221 /* 6222 * Do the exporting. 6223 */ 6224 vrc = VDCopy(pSrcHdd, 6225 VD_LAST_IMAGE, 6226 pDstHdd, 6227 strDstFormat.c_str(), 6228 aFilename, 6229 false /* fMoveByRename */, 6230 0 /* cbSize */, 6231 aVariant & ~MediumVariant_NoCreateDir, 6232 NULL /* pDstUuid */, 6233 VD_OPEN_FLAGS_NORMAL | VD_OPEN_FLAGS_SEQUENTIAL, 6234 pProgress, 6235 pVDImageIfaces, 6236 NULL); 6237 if (RT_SUCCESS(vrc)) 6238 hrc = S_OK; 6239 else 6240 hrc = setErrorBoth(VBOX_E_FILE_ERROR, vrc, tr("Could not create the exported medium '%s'%s"), 6241 aFilename, i_vdError(vrc).c_str()); 6242 VDDestroy(pDstHdd); 6243 } 6244 else 6245 hrc = setErrorVrc(vrc); 6246 } 6247 } 6248 VDDestroy(pSrcHdd); 6249 } 6250 else 6251 hrc = setErrorVrc(vrc, "VDInterfaceAdd -> %Rrc", vrc); 6252 VDIfDestroyFromVfsStream(pVfsIoIf); 6253 } 6254 else 6255 hrc = setErrorVrc(vrc, "VDIfCreateFromVfsStream -> %Rrc", vrc); 6256 } 6257 return hrc; 6258 #else 6259 6188 6260 AutoCaller autoCaller(this); 6189 6261 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 6220 6292 /* setup task object to carry out the operation asynchronously */ 6221 6293 pTask = new Medium::ExportTask(this, aProgress, aFilename, aFormat, aVariant, 6222 #ifdef VBOX_WITH_NEW_TAR_CREATOR6223 pKeyStore, hVfsIosDst, pSourceMediumLockList);6224 #else6225 6294 pKeyStore, aVDImageIOIf, aVDImageIOUser, pSourceMediumLockList); 6226 #endif6227 6295 rc = pTask->rc(); 6228 6296 AssertComRC(rc); … … 6238 6306 6239 6307 return rc; 6308 #endif 6240 6309 } 6241 6310 … … 9698 9767 } 9699 9768 9769 #ifndef VBOX_WITH_NEW_TAR_CREATOR 9700 9770 /** 9701 9771 * Implementation code for the "export" task. … … 9891 9961 return rc; 9892 9962 } 9963 #endif /* !VBOX_WITH_NEW_TAR_CREATOR */ 9893 9964 9894 9965 /**
Note:
See TracChangeset
for help on using the changeset viewer.

