VirtualBox

Changeset 29875 in vbox for trunk/src


Ignore:
Timestamp:
May 28, 2010 6:15:15 PM (15 years ago)
Author:
vboxsync
Message:

OVF: have the progress bar notify the user when we're dealing with manifest files so that at least the user won't think the system is stuck importing/exporting image files

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

Legend:

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

    r28800 r29875  
    673673}
    674674
     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 */
    675684HRESULT Appliance::setUpProgress(ComObjPtr<Progress> &pProgress,
    676685                                 const Bstr &bstrDescription,
     
    685694    disksWeight();
    686695
     696    m->ulWeightForManifestOperation = 0;
     697
    687698    ULONG cOperations;
    688699    ULONG ulTotalOperationsWeight;
     
    692703    if (m->ulTotalDisksMB)
    693704    {
    694         m->ulWeightPerOperation = (ULONG)((double)m->ulTotalDisksMB * 1 / 100);    // use 1% of the progress for the XML
    695         ulTotalOperationsWeight = m->ulTotalDisksMB + m->ulWeightPerOperation;
     705        m->ulWeightForXmlOperation = (ULONG)((double)m->ulTotalDisksMB * 1 / 100);    // use 1% of the progress for the XML
     706        ulTotalOperationsWeight = m->ulTotalDisksMB + m->ulWeightForXmlOperation;
    696707    }
    697708    else
    698709    {
    699710        // no disks to export:
    700         m->ulWeightPerOperation = 1;
     711        m->ulWeightForXmlOperation = 1;
    701712        ulTotalOperationsWeight = 1;
    702713    }
     
    704715    switch (mode)
    705716    {
    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;
    707727        break;
    708728
     
    718738            ulTotalOperationsWeight += ulImportWeight;
    719739
    720             m->ulWeightPerOperation = ulImportWeight; /* save for using later */
     740            m->ulWeightForXmlOperation = ulImportWeight; /* save for using later */
    721741
    722742            ULONG ulInitWeight = (ULONG)((double)ulTotalOperationsWeight * 0.1  / 100);  // use 0.1% for init
     
    731751            if (m->ulTotalDisksMB)
    732752            {
    733                 m->ulWeightPerOperation = (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->ulWeightPerOperation;
     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;
    735755            }
    736756            else
     
    738758                // no disks to export:
    739759                ulTotalOperationsWeight = 1;
    740                 m->ulWeightPerOperation = 1;
     760                m->ulWeightForXmlOperation = 1;
    741761            }
    742762            ULONG ulOVFCreationWeight = (ULONG)((double)ulTotalOperationsWeight * 50.0 / 100.0); /* Use 50% for the creation of the OVF & the disks */
     
    746766    }
    747767
    748     Log(("Setting up progress object: ulTotalMB = %d, cDisks = %d, => cOperations = %d, ulTotalOperationsWeight = %d, m->ulWeightPerOperation = %d\n",
    749          m->ulTotalDisksMB, m->cDisks, cOperations, ulTotalOperationsWeight, m->ulWeightPerOperation));
     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));
    750770
    751771    rc = pProgress->init(mVirtualBox, static_cast<IAppliance*>(this),
     
    755775                         ulTotalOperationsWeight, // ULONG ulTotalOperationsWeight,
    756776                         bstrDescription, // CBSTR bstrFirstOperationDescription,
    757                          m->ulWeightPerOperation); // ULONG ulFirstOperationWeight,
     777                         m->ulWeightForXmlOperation); // ULONG ulFirstOperationWeight,
    758778    return rc;
    759779}
  • trunk/src/VBox/Main/ApplianceImplExport.cpp

    r29873 r29875  
    628628    try
    629629    {
    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);
    634633
    635634        /* Initialize our worker task */
     
    15181517
    15191518                // 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);
    15231521
    15241522                // now wait for the background disk operation to complete; this throws HRESULTs on error
     
    15961594        writer.write(locInfo.strPath.c_str(), false /*fSafe*/);
    15971595
    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
    15991602        const char** ppManifestFiles = (const char**)RTMemAlloc(sizeof(char*)*diskList.size() + 1);
    16001603        ppManifestFiles[0] = locInfo.strPath.c_str();
     
    16051608             ++it1, ++i)
    16061609            ppManifestFiles[i] = (*it1).c_str();
    1607         Utf8Str strMfFile = manifestFileName(locInfo.strPath.c_str());
    16081610        int vrc = RTManifestWriteFiles(strMfFile.c_str(), ppManifestFiles, diskList.size()+1);
    16091611        RTMemFree(ppManifestFiles);
    16101612        if (RT_FAILURE(vrc))
    16111613            throw setError(VBOX_E_FILE_ERROR,
    1612                            tr("Couldn't create manifest file '%s' (%Rrc)"),
    1613                            RTPathFilename(strMfFile.c_str()), vrc);
     1614                           tr("Could not create manifest file '%s' (%Rrc)"),
     1615                           pcszManifestFileOnly, vrc);
    16141616    }
    16151617    catch(xml::Error &x)
     
    17051707                           tr("Cannot find source file '%s'"), strTmpOvf.c_str());
    17061708        /* Add the OVF file */
    1707         filesList.push_back(pair<Utf8Str, ULONG>(strTmpOvf, m->ulWeightPerOperation)); /* 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 */
    17081710        Utf8Str strMfFile = manifestFileName(strTmpOvf);
    1709         filesList.push_back(pair<Utf8Str, ULONG>(strMfFile , m->ulWeightPerOperation)); /* 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 */
    17101712
    17111713        /* Now add every disks of every virtual system */
     
    17481750            char *pszFilename = RTPathFilename(s.first.c_str());
    17491751            /* 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);
    17521753            vrc = RTS3PutKey(hS3, bucket.c_str(), pszFilename, s.first.c_str());
    17531754            if (RT_FAILURE(vrc))
  • trunk/src/VBox/Main/ApplianceImplImport.cpp

    r29873 r29875  
    770770        hS3 = NIL_RTS3;
    771771
    772         if (!pTask->pProgress.isNull())
    773             pTask->pProgress->SetNextOperation(Bstr(tr("Reading")), 1);
     772        pTask->pProgress->SetNextOperation(Bstr(tr("Reading")), 1);
    774773
    775774        /* Prepare the temporary reading of the OVF */
     
    932931 * @return
    933932 */
    934 HRESULT Appliance::importImpl(const LocationInfo &aLocInfo, ComObjPtr<Progress> &aProgress)
     933HRESULT Appliance::importImpl(const LocationInfo &aLocInfo,
     934                              ComObjPtr<Progress> &aProgress)
    935935{
    936     Bstr progressDesc = BstrFmt(tr("Importing appliance '%s'"),
    937                                 aLocInfo.strPath.c_str());
    938936    HRESULT rc = S_OK;
    939937
     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
    940954    rc = setUpProgress(aProgress,
    941                        progressDesc,
    942                        (aLocInfo.storageType == VFSType_File) ? Regular : ImportS3);
     955                       BstrFmt(tr("Importing appliance '%s'"), aLocInfo.strPath.c_str()),
     956                       mode);
    943957    if (FAILED(rc)) throw rc;
    944958
     
    10031017 */
    10041018HRESULT Appliance::manifestVerify(const LocationInfo &locInfo,
    1005                                   const ovf::OVFReader &reader)
     1019                                  const ovf::OVFReader &reader,
     1020                                  ComObjPtr<Progress> &pProgress)
    10061021{
    10071022    HRESULT rc = S_OK;
    10081023
    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
    10121030        list<Utf8Str> filesList;
    10131031        Utf8Str strSrcDir(locInfo.strPath);
     
    10541072        // this call can take a very long time
    10551073        size_t cIndexOnError;
    1056         vrc = RTManifestVerify(strMfFile.c_str(),
     1074        vrc = RTManifestVerify(m->strManifestFile.c_str(),
    10571075                               pTestList,
    10581076                               filesList.size() + 1,
     
    10631081                          tr("The SHA1 digest of '%s' does not match the one in '%s'"),
    10641082                          RTPathFilename(pTestList[cIndexOnError].pszTestFile),
    1065                           RTPathFilename(strMfFile.c_str()));
     1083                          pcszManifestFileOnly);
    10661084        else if (RT_FAILURE(vrc))
    10671085            rc = setError(VBOX_E_FILE_ERROR,
    10681086                          tr("Could not verify the content of '%s' against the available files (%Rrc)"),
    1069                           RTPathFilename(strMfFile.c_str()),
     1087                          pcszManifestFileOnly,
    10701088                          vrc);
    10711089
     
    11301148    {
    11311149        // 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);
    11331151        if (FAILED(rc)) throw rc;
    11341152
     
    13081326
    13091327            // advance to the next operation
    1310             stack.pProgress->SetNextOperation(BstrFmt(tr("Creating virtual disk image '%s'"), strTargetPath.c_str()),
     1328            stack.pProgress->SetNextOperation(BstrFmt(tr("Creating disk image '%s'"), strTargetPath.c_str()),
    13111329                                              di.ulSuggestedSizeMB);     // operation's weight, as set up with the IProgress originally
    13121330        }
     
    22002218        hS3 = NIL_RTS3;
    22012219
    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);
    22042221
    22052222        ComObjPtr<Progress> progress;
  • trunk/src/VBox/Main/include/ApplianceImpl.h

    r29873 r29875  
    120120
    121121    void disksWeight();
    122     enum SetUpProgressMode { Regular, ImportS3, WriteS3 };
     122    enum SetUpProgressMode { ImportFileWithManifest, ImportFileNoManifest, ImportS3, WriteFile, WriteS3 };
    123123    HRESULT setUpProgress(ComObjPtr<Progress> &pProgress,
    124124                          const Bstr &bstrDescription,
     
    145145
    146146    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);
    148148
    149149    HRESULT importFS(const LocationInfo &locInfo, ComObjPtr<Progress> &aProgress);
  • trunk/src/VBox/Main/include/ApplianceImplPrivate.h

    r29422 r29875  
    6262    }
    6363
    64     ApplianceState  state;
     64    ApplianceState      state;
    6565
    66     LocationInfo    locInfo;       // location info for the currently processed OVF
     66    LocationInfo        locInfo;        // location info for the currently processed OVF
    6767
    68     ovf::OVFReader  *pReader;
    69 
    70     bool            fBusyWriting;          // state protection; while this is true nobody else can call methods
     68    ovf::OVFReader      *pReader;
    7169
    7270    std::list< ComObjPtr<VirtualSystemDescription> >
    73                     virtualSystemDescriptions;
     71                        virtualSystemDescriptions;
    7472
    75     std::list<Utf8Str>   llWarnings;
     73    std::list<Utf8Str>  llWarnings;
    7674
    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;
    8182};
    8283
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