VirtualBox

Changeset 48087 in vbox for trunk


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)

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/manual/user_ChangeLogImpl.xml

    r48053 r48087  
    3131      <listitem>
    3232        <para>GUI: host touch devices support (GUI passes host touch-events to guest)</para>
     33      </listitem>
     34
     35      <listitem>
     36        <para>GUI, VBoxManage: when unregistering a VM, also unregister the
     37          hard disk images which are used exclusively (bug #10311)</para>
    3338      </listitem>
    3439
  • 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;
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp

    r45362 r48087  
    14921492        else if (iResultCode == AlertButton_Choice2)
    14931493        {
    1494             /* Just unregister machine: */
    1495             machine.Unregister(KCleanupMode_DetachAllReturnNone);
     1494            /* Unregister machine first: */
     1495            CMediumVector mediums = machine.Unregister(KCleanupMode_DetachAllReturnHardDisksOnly);
    14961496            if (!machine.isOk())
    14971497            {
    14981498                msgCenter().cannotRemoveMachine(machine);
    14991499                continue;
     1500            }
     1501            /* Finally close all media, deliberately ignoring errors: */
     1502            foreach (CMedium medium, mediums)
     1503            {
     1504                if (!medium.isNull())
     1505                    medium.Close();
    15001506            }
    15011507        }
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