VirtualBox

Changeset 37580 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Jun 21, 2011 1:23:35 PM (14 years ago)
Author:
vboxsync
Message:

Main/MachineImplCloneVM.cpp: change the sub-operation weights so that there are no overflows.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp

    r37558 r37580  
    3535{
    3636    ComPtr<IMedium>         pMedium;
    37     uint64_t                uSize;
     37    ULONG                   uWeight;
    3838}MEDIUMTASK;
    3939
     
    4848    Guid                    snapshotUuid;
    4949    Utf8Str                 strSaveStateFile;
    50     uint64_t                cbSize;
     50    ULONG                   uWeight;
    5151}SAVESTATETASK;
    5252
     
    333333            rc = machine->COMGETTER(MediumAttachments)(ComSafeArrayAsOutParam(sfaAttachments));
    334334            if (FAILED(rc)) throw rc;
    335             /* Add all attachments (and there parents) of the different
     335            /* Add all attachments (and their parents) of the different
    336336             * machines to a worker list. */
    337337            for (size_t a = 0; a < sfaAttachments.size(); ++a)
     
    371371                    MEDIUMTASK mt;
    372372                    mt.pMedium = pSrcMedium;
    373                     mt.uSize   = lSize;
     373                    mt.uWeight = (lSize + _1M - 1) / _1M;
    374374                    mtc.chain.append(mt);
    375375
     
    382382                 * diff image is small in size, it could need some time to create
    383383                 * it. Adding the biggest size in the chain should balance this a
    384                  * little bit more. */
    385                 int64_t uMaxSize = 0;
     384                 * little bit more, i.e. the weight is the sum of the data which
     385                 * needs to be read and written. */
     386                uint64_t uMaxSize = 0;
    386387                for (size_t e = mtc.chain.size(); e > 0; --e)
    387388                {
    388389                    MEDIUMTASK &mt = mtc.chain.at(e - 1);
     390                    mt.uWeight += uMaxSize;
     391
     392                    /* Calculate progress data */
     393                    ++uCount;
     394                    uTotalWeight += mt.uWeight;
     395
    389396                    /* Save the max size for better weighting of diff image
    390397                     * creation. */
    391                     uMaxSize = RT_MAX(uMaxSize, mt.uSize);
    392                     mt.uSize = (mt.uSize + uMaxSize) / 2;
    393 
    394                     /* Calculate progress data */
    395                     ++uCount;
    396                     uTotalWeight += mt.uSize;
     398                    uMaxSize = RT_MAX(uMaxSize, mt.uWeight);
    397399                }
    398400                d->llMedias.append(mtc);
     
    406408                sst.snapshotUuid     = machine->getSnapshotId();
    407409                sst.strSaveStateFile = bstrSrcSaveStatePath;
    408                 int vrc = RTFileQuerySize(sst.strSaveStateFile.c_str(), &sst.cbSize);
     410                uint64_t cbSize;
     411                int vrc = RTFileQuerySize(sst.strSaveStateFile.c_str(), &cbSize);
    409412                if (RT_FAILURE(vrc))
    410413                    throw p->setError(VBOX_E_IPRT_ERROR, p->tr("Could not query file size of '%s' (%Rrc)"), sst.strSaveStateFile.c_str(), vrc);
     414                /* same rule as above: count both the data which needs to
     415                 * be read and written */
     416                sst.uWeight = 2 * (cbSize + _1M - 1) / _1M;
    411417                d->llSaveStateFiles.append(sst);
    412418                ++uCount;
    413                 uTotalWeight += sst.cbSize;
     419                uTotalWeight += sst.uWeight;
    414420            }
    415421        }
     
    555561                if (FAILED(rc)) throw rc;
    556562
    557                 rc = d->pProgress->SetNextOperation(BstrFmt(p->tr("Cloning Disk '%ls' ..."), bstrSrcName.raw()).raw(), mt.uSize);
     563                rc = d->pProgress->SetNextOperation(BstrFmt(p->tr("Cloning Disk '%ls' ..."), bstrSrcName.raw()).raw(), mt.uWeight);
    558564                if (FAILED(rc)) throw rc;
    559565
     
    709715
    710716            /* Move to next sub-operation. */
    711             rc = d->pProgress->SetNextOperation(BstrFmt(p->tr("Copy save state file '%s' ..."), RTPathFilename(sst.strSaveStateFile.c_str())).raw(), sst.cbSize);
     717            rc = d->pProgress->SetNextOperation(BstrFmt(p->tr("Copy save state file '%s' ..."), RTPathFilename(sst.strSaveStateFile.c_str())).raw(), sst.uWeight);
    712718            if (FAILED(rc)) throw rc;
    713719            /* Copy the file only if it was not copied already. */
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