VirtualBox

Ignore:
Timestamp:
Aug 27, 2013 3:37:30 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
88462
Message:

Frontends/VirtualBox+VBoxManage: when unregistering a VM, also unregister the
hard disk images which are used exclusively (public bug #10311)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp

    r47991 r48087  
    154154                    RTEXITCODE_FAILURE);
    155155    SafeIfaceArray<IMedium> aMedia;
    156     CHECK_ERROR_RET(machine, Unregister(fDelete ? (CleanupMode_T)CleanupMode_DetachAllReturnHardDisksOnly : (CleanupMode_T)CleanupMode_DetachAllReturnNone,
     156    CHECK_ERROR_RET(machine, Unregister(CleanupMode_DetachAllReturnHardDisksOnly,
    157157                                        ComSafeArrayAsOutParam(aMedia)),
    158158                    RTEXITCODE_FAILURE);
     
    165165        rc = showProgress(pProgress);
    166166        CHECK_PROGRESS_ERROR_RET(pProgress, ("Machine delete failed"), RTEXITCODE_FAILURE);
     167    }
     168    else
     169    {
     170        /* Note that the IMachine::Unregister method will return the medium
     171         * reference in a sane order, which means that closing will normally
     172         * succeed, unless there is still another machine which uses the
     173         * medium. No harm done if we ignore the error. */
     174        for (size_t i = 0; i < aMedia.size(); i++)
     175        {
     176            IMedium *pMedium = aMedia[i];
     177            if (pMedium)
     178                rc = pMedium->Close();
     179        }
     180        rc = S_OK;
    167181    }
    168182    return RTEXITCODE_SUCCESS;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette