VirtualBox

Ignore:
Timestamp:
Aug 13, 2010 6:40:53 PM (14 years ago)
Author:
vboxsync
Message:

Main/FE/Qt4: add initial OVA support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/ApplianceImpl.cpp

    r31562 r31676  
    667667    BOOL fCanceled;
    668668    ULONG currentPercent;
     669    ULONG cOp = 0;
    669670    while (SUCCEEDED(pProgressAsync->COMGETTER(Completed(&fCompleted))))
    670671    {
     
    676677            break;
    677678        }
    678 
    679         rc = pProgressAsync->COMGETTER(Percent(&currentPercent));
     679        /* Check if the current operation have changed. It is also possible
     680           that in the meantime more than one async operation was finished. So
     681           we have to loop as long as we reached the same operation count. */
     682        ULONG curOp;
     683        for(;;)
     684        {
     685            rc = pProgressAsync->COMGETTER(Operation(&curOp));
     686            if (FAILED(rc)) throw rc;
     687            if (cOp != curOp)
     688            {
     689                Bstr bstr;
     690                ULONG currentWeight;
     691                rc = pProgressAsync->COMGETTER(OperationDescription(bstr.asOutParam()));
     692                if (FAILED(rc)) throw rc;
     693                rc = pProgressAsync->COMGETTER(OperationWeight(&currentWeight));
     694                if (FAILED(rc)) throw rc;
     695                rc = pProgressThis->SetNextOperation(bstr, currentWeight);
     696                if (FAILED(rc)) throw rc;
     697                ++cOp;
     698            }else
     699                break;
     700        }
     701
     702        rc = pProgressAsync->COMGETTER(OperationPercent(&currentPercent));
    680703        if (FAILED(rc)) throw rc;
    681         if (!pProgressThis.isNull())
    682             pProgressThis->SetCurrentOperationProgress(currentPercent);
     704        pProgressThis->SetCurrentOperationProgress(currentPercent);
    683705        if (fCompleted)
    684706            break;
     
    745767}
    746768
     769#include <iprt/tar.h>
    747770/**
    748771 * Called from Appliance::importImpl() and Appliance::writeImpl() to set up a
     
    754777 * @return
    755778 */
    756 HRESULT Appliance::setUpProgress(ComObjPtr<Progress> &pProgress,
     779HRESULT Appliance::setUpProgress(const LocationInfo &locInfo,
     780                                 ComObjPtr<Progress> &pProgress,
    757781                                 const Bstr &bstrDescription,
    758782                                 SetUpProgressMode mode)
     
    785809    }
    786810
     811    bool fOVA = locInfo.strPath.endsWith(".ova", Utf8Str::CaseInsensitive);
    787812    switch (mode)
    788813    {
    789814        case ImportFileNoManifest:
    790         break;
    791 
     815        {
     816            if (fOVA)
     817            {
     818                // Another operation for packing
     819                ++cOperations;
     820
     821                // assume that packing the files into the archive has the same weight than creating all files in the ovf exporting step
     822                ulTotalOperationsWeight += m->ulTotalDisksMB;
     823            }
     824            break;
     825        }
    792826        case ImportFileWithManifest:
    793827        case WriteFile:
     828        {
    794829            ++cOperations;          // another one for creating the manifest
    795830
    796             // assume that checking or creating the manifest will take 10% of the time it takes to export the disks
     831            // assume that creating the manifest will take 10% of the time it takes to export the disks
    797832            m->ulWeightForManifestOperation = m->ulTotalDisksMB / 10;
    798833            ulTotalOperationsWeight += m->ulWeightForManifestOperation;
    799         break;
    800 
     834            if (fOVA)
     835            {
     836                // Another operation for packing
     837                ++cOperations;
     838
     839                // assume that packing the files into the archive has the same weight than creating all files in the ovf exporting step
     840                ulTotalOperationsWeight += m->ulTotalDisksMB;
     841            }
     842            break;
     843        }
    801844        case ImportS3:
    802845        {
     
    814857            ULONG ulInitWeight = (ULONG)((double)ulTotalOperationsWeight * 0.1  / 100);  // use 0.1% for init
    815858            ulTotalOperationsWeight += ulInitWeight;
     859            break;
    816860        }
    817         break;
    818 
    819861        case WriteS3:
    820862        {
     
    834876            ULONG ulOVFCreationWeight = (ULONG)((double)ulTotalOperationsWeight * 50.0 / 100.0); /* Use 50% for the creation of the OVF & the disks */
    835877            ulTotalOperationsWeight += ulOVFCreationWeight;
     878            break;
    836879        }
    837         break;
    838880    }
    839881
     
    916958}
    917959
    918 Utf8Str Appliance::manifestFileName(Utf8Str aPath) const
    919 {
     960Utf8Str Appliance::manifestFileName(const Utf8Str& aPath) const
     961{
     962    Utf8Str strTmpPath = aPath;
    920963    /* Get the name part */
    921     char *pszMfName = RTStrDup(RTPathFilename(aPath.c_str()));
     964    char *pszMfName = RTStrDup(RTPathFilename(strTmpPath.c_str()));
    922965    /* Strip any extensions */
    923966    RTPathStripExt(pszMfName);
    924967    /* Path without the filename */
    925     aPath.stripFilename();
     968    strTmpPath.stripFilename();
    926969    /* Format the manifest path */
    927     Utf8StrFmt strMfFile("%s/%s.mf", aPath.c_str(), pszMfName);
     970    Utf8StrFmt strMfFile("%s/%s.mf", strTmpPath.c_str(), pszMfName);
    928971    RTStrFree(pszMfName);
    929972    return strMfFile;
     
    9731016        case TaskOVF::Read:
    9741017            if (task->locInfo.storageType == VFSType_File)
    975                 taskrc = pAppliance->readFS(task->locInfo);
     1018                taskrc = pAppliance->readFS(task->locInfo, task->pProgress);
    9761019            else if (task->locInfo.storageType == VFSType_S3)
    9771020                taskrc = pAppliance->readS3(task.get());
     
    9801023        case TaskOVF::Import:
    9811024            if (task->locInfo.storageType == VFSType_File)
    982                 taskrc = pAppliance->importFS(task->locInfo, task->pProgress);
     1025                taskrc = pAppliance->importFS(task.get());
    9831026            else if (task->locInfo.storageType == VFSType_S3)
    9841027                taskrc = pAppliance->importS3(task.get());
     
    9871030        case TaskOVF::Write:
    9881031            if (task->locInfo.storageType == VFSType_File)
    989                 taskrc = pAppliance->writeFS(task->locInfo, task->enFormat, task->pProgress);
     1032                taskrc = pAppliance->writeFS(task.get());
    9901033            else if (task->locInfo.storageType == VFSType_S3)
    9911034                taskrc = pAppliance->writeS3(task.get());
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