VirtualBox

Changeset 24524 in vbox


Ignore:
Timestamp:
Nov 9, 2009 5:47:03 PM (15 years ago)
Author:
vboxsync
Message:

Main/Machine: fix error handling in MountMedium, dropping the error code and not undoing the mount on failure are two severe bugs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/MachineImpl.cpp

    r24511 r24524  
    28232823                        tr("No drive attached to device slot %d on port %d of controller '%ls'"),
    28242824                        aDevice, aControllerPort, aControllerName);
     2825
     2826    /* Remember previously mounted medium. The medium before taking the
     2827     * backup is not necessarily the same thing. */
     2828    ComObjPtr<Medium> oldmedium;
     2829    oldmedium = pAttach->medium();
    28252830
    28262831    Guid id(aId);
     
    29002905    }
    29012906
    2902     alock.unlock();
    2903     onMediumChange(pAttach, aForce);
     2907    alock.leave();
     2908    rc = onMediumChange(pAttach, aForce);
     2909    alock.enter();
     2910
     2911    /* On error roll back this change only. */
     2912    if (FAILED(rc))
     2913    {
     2914        if (!medium.isNull())
     2915            medium->detachFrom(mData->mUuid);
     2916        pAttach = findAttachment(mMediaData->mAttachments,
     2917                                 aControllerName,
     2918                                 aControllerPort,
     2919                                 aDevice);
     2920        /* If the attachment is gone in the mean time, bail out. */
     2921        if (pAttach.isNull())
     2922            return rc;
     2923        AutoWriteLock attLock(pAttach);
     2924        pAttach->updateMedium(oldmedium, false /* aImplicit */);
     2925    }
    29042926
    29052927    return rc;
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