VirtualBox

Changeset 37521 in vbox


Ignore:
Timestamp:
Jun 17, 2011 6:56:59 AM (13 years ago)
Author:
vboxsync
Message:

Main-CloneVM: fix cleanup

File:
1 edited

Legend:

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

    r37502 r37521  
    406406     *   cloned disks called exactly as the original one or should all new disks
    407407     *   get a new name with the new VM name in it.
     408     * - What about log files?
    408409     */
    409410
    410411    /* Where should all the media go? */
     412    Utf8Str strTrgSnapshotFolder;
    411413    Utf8Str strTrgMachineFolder = d->pTrgMachine->getSettingsFileFull();
    412414    strTrgMachineFolder.stripFilename();
     
    468470        if (FAILED(rc)) throw rc;
    469471        /* The absolute name of the snapshot folder. */
    470         Utf8Str strTrgSnapshotFolder = Utf8StrFmt("%s%c%s%c", strTrgMachineFolder.c_str(), RTPATH_DELIMITER, trgMCF.machineUserData.strSnapshotFolder.c_str(), RTPATH_DELIMITER);
     472        strTrgSnapshotFolder = Utf8StrFmt("%s%c%s%c", strTrgMachineFolder.c_str(), RTPATH_DELIMITER, trgMCF.machineUserData.strSnapshotFolder.c_str(), RTPATH_DELIMITER);
    471473
    472474        /* We need to create a map with the already created medias. This is
     
    602604                if (FAILED(rc)) throw rc;
    603605                pNewParent = diff;
     606                newMedias.append(diff);
    604607            }
    605608            Bstr bstrSrcId;
     
    743746        for (size_t i = newMedias.size(); i > 0; --i)
    744747        {
     748            bool fFile = false;
     749            Utf8Str strLoc;
    745750            ComObjPtr<Medium> &pMedium = newMedias.at(i - 1);
    746             AutoCaller mac(pMedium);
    747             if (FAILED(mac.rc())) { continue; rc = mac.rc(); }
    748             AutoReadLock mlock(pMedium COMMA_LOCKVAL_SRC_POS);
    749             bool fFile = pMedium->isMediumFormatFile();
    750             Utf8Str strLoc = pMedium->getLocationFull();
    751             mlock.release();
    752             /* Close the medium. If this succeed, delete it finally from the
    753              * disk. */
    754             rc = pMedium->close(NULL, mac);
    755             if (FAILED(rc)) continue;
     751            {
     752                AutoCaller mac(pMedium);
     753                if (FAILED(mac.rc())) { continue; rc = mac.rc(); }
     754                AutoReadLock mlock(pMedium COMMA_LOCKVAL_SRC_POS);
     755                fFile = pMedium->isMediumFormatFile();
     756                strLoc = pMedium->getLocationFull();
     757            }
    756758            if (fFile)
    757759            {
     
    761763            }
    762764        }
     765        /* Delete the snapshot folder when not empty. */
     766        if (!strTrgSnapshotFolder.isEmpty())
     767            RTDirRemove(strTrgSnapshotFolder.c_str());
    763768        /* Delete the machine folder when not empty. */
    764769        RTDirRemove(strTrgMachineFolder.c_str());
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