VirtualBox

Changeset 67244 in vbox for trunk


Ignore:
Timestamp:
Jun 2, 2017 3:10:54 PM (7 years ago)
Author:
vboxsync
Message:

Main,VD: Compressed the Medium::i_exportFile method (VBOX_WITH_NEW_TAR_CREATOR) and hooked it up to the export progress object.

Location:
trunk/src/VBox/Main
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/MediumImpl.h

    r67237 r67244  
    382382    class DeleteTask;
    383383    class MergeTask;
     384#ifndef VBOX_WITH_NEW_TAR_CREATOR
    384385    class ExportTask;
     386#endif
    385387    class ImportTask;
    386388    class EncryptTask;
     
    395397    friend class DeleteTask;
    396398    friend class MergeTask;
     399#ifndef VBOX_WITH_NEW_TAR_CREATOR
    397400    friend class ExportTask;
     401#endif
    398402    friend class ImportTask;
    399403    friend class EncryptTask;
     
    408412    HRESULT i_taskCompactHandler(Medium::CompactTask &task);
    409413    HRESULT i_taskResizeHandler(Medium::ResizeTask &task);
     414#ifndef VBOX_WITH_NEW_TAR_CREATOR
    410415    HRESULT i_taskExportHandler(Medium::ExportTask &task);
     416#endif
    411417    HRESULT i_taskImportHandler(Medium::ImportTask &task);
    412418    HRESULT i_taskEncryptHandler(Medium::EncryptTask &task);
  • trunk/src/VBox/Main/src-server/ApplianceImplExport.cpp

    r67231 r67244  
    25392539                     * Export a disk image.
    25402540                     */
    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 
    25492541#ifdef VBOX_WITH_NEW_TAR_CREATOR
    25502542                    /* For compressed VMDK fun, we let i_exportFile produce the image bytes. */
     
    25642556                                                   m->m_pSecretKeyStore,
    25652557                                                   hVfsIosDst,
    2566                                                    pProgress2);
     2558                                                   pTask->pProgress);
    25672559                    RTVfsIoStrmRelease(hVfsIosDst);
    25682560                    if (FAILED(rc)) throw rc;
    25692561#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
    25702570                    rc = pSourceDisk->i_exportFile(strTargetFilePath.c_str(),
    25712571                                                   format,
     
    25762576                                                   pProgress2);
    25772577                    if (FAILED(rc)) throw rc;
    2578 #endif
    25792578
    25802579                    ComPtr<IProgress> pProgress3(pProgress2);
    25812580                    // now wait for the background disk operation to complete; this throws HRESULTs on error
    25822581                    i_waitForAsyncProgress(pTask->pProgress, pProgress3);
     2582#endif
    25832583                }
    25842584                else
  • trunk/src/VBox/Main/src-server/MediumImpl.cpp

    r67239 r67244  
    651651};
    652652
     653#ifndef VBOX_WITH_NEW_TAR_CREATOR
    653654class Medium::ExportTask : public Medium::Task
    654655{
     
    660661               MediumVariant_T aVariant,
    661662               SecretKeyStore *pSecretKeyStore,
    662 #ifdef VBOX_WITH_NEW_TAR_CREATOR
    663                RTVFSIOSTREAM aVfsIosDst,
    664 #else
    665663               VDINTERFACEIO *aVDImageIOIf,
    666664               void *aVDImageIOUser,
    667 #endif
    668665               MediumLockList *aSourceMediumLockList,
    669666               bool fKeepSourceMediumLockList = false)
     
    680677        mVDImageIfaces = aMedium->m->vdImageIfaces;
    681678
    682 #ifdef VBOX_WITH_NEW_TAR_CREATOR
    683         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 #else
    691 
    692679        if (aVDImageIOIf)
    693680        {
     
    697684            AssertRCReturnVoidStmt(vrc, mRC = E_FAIL);
    698685        }
    699 #endif
    700686        m_strTaskName = "createExport";
    701687    }
     
    705691        if (!mfKeepSourceMediumLockList && mpSourceMediumLockList)
    706692            delete mpSourceMediumLockList;
    707 #ifdef VBOX_WITH_NEW_TAR_CREATOR
    708         if (mpVfsIoIf)
    709         {
    710             VDIfDestroyFromVfsStream(mpVfsIoIf);
    711             mpVfsIoIf = NULL;
    712         }
    713 #endif
    714693    }
    715694
     
    719698    MediumVariant_T mVariant;
    720699    PVDINTERFACE mVDImageIfaces;
    721     PVDINTERFACEIO mpVfsIoIf; /**< Pointer to the VFS I/O stream to VD I/O interface wrapper. */
    722700    SecretKeyStore *m_pSecretKeyStore;
    723701
     
    726704    bool mfKeepSourceMediumLockList;
    727705};
     706#endif /* !VBOX_WITH_NEW_TAR_CREATOR */
    728707
    729708class Medium::ImportTask : public Medium::Task
     
    978957}
    979958
     959#ifndef VBOX_WITH_NEW_TAR_CREATOR
    980960/**
    981961 * Implementation code for the "export" task.
     
    985965    return mMedium->i_taskExportHandler(*this);
    986966}
     967#endif
    987968
    988969/**
     
    61656146 * @param aProgress         Progress object to use.
    61666147 * @return
     6148 *
    61676149 * @note The source format is defined by the Medium instance.
    6168  *
    6169  * @todo The only consumer of this method (Appliance::i_writeFSImpl) is already
    6170  *       on a worker thread, so perhaps consider bypassing the thread here and
    6171  *       run in the task synchronously?  VBoxSVC has enough threads as it is...
    61726150 */
    61736151HRESULT Medium::i_exportFile(const char *aFilename,
     
    61866164    AssertReturn(aProgress.isNotNull(), E_INVALIDARG);
    61876165
     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
    61886260    AutoCaller autoCaller(this);
    61896261    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     
    62206292        /* setup task object to carry out the operation asynchronously */
    62216293        pTask = new Medium::ExportTask(this, aProgress, aFilename, aFormat, aVariant,
    6222 #ifdef VBOX_WITH_NEW_TAR_CREATOR
    6223                                        pKeyStore, hVfsIosDst, pSourceMediumLockList);
    6224 #else
    62256294                                       pKeyStore, aVDImageIOIf, aVDImageIOUser, pSourceMediumLockList);
    6226 #endif
    62276295        rc = pTask->rc();
    62286296        AssertComRC(rc);
     
    62386306
    62396307    return rc;
     6308#endif
    62406309}
    62416310
     
    96989767}
    96999768
     9769#ifndef VBOX_WITH_NEW_TAR_CREATOR
    97009770/**
    97019771 * Implementation code for the "export" task.
     
    98919961    return rc;
    98929962}
     9963#endif /* !VBOX_WITH_NEW_TAR_CREATOR */
    98939964
    98949965/**
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette