VirtualBox

Changeset 37522 in vbox


Ignore:
Timestamp:
Jun 17, 2011 7:26:09 AM (14 years ago)
Author:
vboxsync
Message:

Main-CloneVM: put images into the target snapshot folder if they where in the snapshot folder of the source as well

File:
1 edited

Legend:

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

    r37521 r37522  
    399399    /*
    400400     * Todo:
    401      * - Regardless where the old media comes from (e.g. snapshots folder) it
    402      *   goes to the new main VM folder. Maybe we like to be a little bit
    403      *   smarter here.
    404401     * - Snapshot diffs (can) have the uuid as name. After cloning this isn't
    405402     *   right anymore. Is it worth to change to the new uuid? Or should the
     
    470467        if (FAILED(rc)) throw rc;
    471468        /* The absolute name of the snapshot folder. */
    472         strTrgSnapshotFolder = Utf8StrFmt("%s%c%s%c", strTrgMachineFolder.c_str(), RTPATH_DELIMITER, trgMCF.machineUserData.strSnapshotFolder.c_str(), RTPATH_DELIMITER);
     469        strTrgSnapshotFolder = Utf8StrFmt("%s%c%s", strTrgMachineFolder.c_str(), RTPATH_DELIMITER, trgMCF.machineUserData.strSnapshotFolder.c_str());
    473470
    474471        /* We need to create a map with the already created medias. This is
     
    529526                    if (FAILED(rc)) throw rc;
    530527
     528                    /* Check if this medium comes from the snapshot folder, if
     529                     * so, put it there in the cloned machine as well.
     530                     * Otherwise it goes to the machine folder. */
    531531                    Utf8Str strFile = Utf8StrFmt("%s%c%lS", strTrgMachineFolder.c_str(), RTPATH_DELIMITER, bstrSrcName.raw());
     532                    Bstr bstrSrcPath;
     533                    rc = pMedium->COMGETTER(Location)(bstrSrcPath.asOutParam());
     534                    if (FAILED(rc)) throw rc;
     535                    if (   !bstrSrcPath.isEmpty()
     536                        &&  RTPathStartsWith(Utf8Str(bstrSrcPath).c_str(), Utf8Str(bstrSrcSnapshotFolder).c_str()))
     537                        strFile = Utf8StrFmt("%s%c%lS", strTrgSnapshotFolder.c_str(), RTPATH_DELIMITER, bstrSrcName.raw());
     538                    else
     539                        strFile = Utf8StrFmt("%s%c%lS", strTrgMachineFolder.c_str(), RTPATH_DELIMITER, bstrSrcName.raw());
     540
    532541                    rc = pTarget->init(p->mParent,
    533542                                       Utf8Str(bstrSrcFormat),
     
    584593                rc = diff->init(p->mParent,
    585594                                pNewParent->getPreferredDiffFormat(),
    586                                 strTrgSnapshotFolder,
     595                                Utf8StrFmt("%s%c", strTrgSnapshotFolder.c_str(), RTPATH_DELIMITER),
    587596                                d->pTrgMachine->mData->mUuid,
    588597                                NULL); // pllRegistriesThatNeedSaving
     
    621630        {
    622631            SAVESTATETASK sst = d->llSaveStateFiles.at(i);
    623             const Utf8Str &strTrgSaveState = Utf8StrFmt("%s%s", strTrgSnapshotFolder.c_str(), RTPathFilename(sst.strSaveStateFile.c_str()));
     632            const Utf8Str &strTrgSaveState = Utf8StrFmt("%s%c%s", strTrgSnapshotFolder.c_str(), RTPATH_DELIMITER, RTPathFilename(sst.strSaveStateFile.c_str()));
    624633
    625634            /* Move to next sub-operation. */
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