VirtualBox

Changeset 37687 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
Jun 29, 2011 3:22:11 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
72547
Message:

Main/Console+Machine: add notification for guest triggered eject, which right now results in updating the VM config
Devices/Storage/ATA+AHCI: trigger the eject notification

File:
1 edited

Legend:

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

    r37686 r37687  
    1164011640}
    1164111641
     11642STDMETHODIMP SessionMachine::EjectMedium(IMediumAttachment *aAttachment,
     11643                                         IMediumAttachment **aNewAttachment)
     11644{
     11645    CheckComArgNotNull(aAttachment);
     11646    CheckComArgOutPointerValid(aNewAttachment);
     11647
     11648    AutoCaller autoCaller(this);
     11649    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     11650
     11651    /* Need to query the details first, as the IMediumAttachment reference
     11652     * might be to the original settings, which we are going to change. */
     11653    Bstr ctrlName;
     11654    HRESULT rc = aAttachment->COMGETTER(Controller)(ctrlName.asOutParam());
     11655    AssertComRC(rc);
     11656    LONG lDev;
     11657    rc = aAttachment->COMGETTER(Device)(&lDev);
     11658    AssertComRC(rc);
     11659    LONG lPort;
     11660    rc = aAttachment->COMGETTER(Port)(&lPort);
     11661    AssertComRC(rc);
     11662
     11663    // request the host lock first, since might be calling Host methods for getting host drives;
     11664    // next, protect the media tree all the while we're in here, as well as our member variables
     11665    AutoMultiWriteLock3 multiLock(mParent->host()->lockHandle(),
     11666                                  this->lockHandle(),
     11667                                  &mParent->getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS);
     11668
     11669    ComObjPtr<MediumAttachment> pAttach = static_cast<MediumAttachment *>(aAttachment);
     11670
     11671    /* Remember previously mounted medium. The medium before taking the
     11672     * backup is not necessarily the same thing. */
     11673    ComObjPtr<Medium> oldmedium;
     11674    oldmedium = pAttach->getMedium();
     11675
     11676    setModified(IsModified_Storage);
     11677    mMediaData.backup();
     11678
     11679    GuidList llRegistriesThatNeedSaving;
     11680
     11681    {
     11682        // The backup operation makes the pAttach reference point to the
     11683        // old settings. Re-get the correct reference.
     11684        pAttach = findAttachment(mMediaData->mAttachments,
     11685                                 ctrlName.raw(),
     11686                                 lPort,
     11687                                 lDev);
     11688        AutoWriteLock attLock(pAttach COMMA_LOCKVAL_SRC_POS);
     11689        if (!oldmedium.isNull())
     11690            oldmedium->removeBackReference(mData->mUuid);
     11691
     11692        pAttach->updateMedium(NULL);
     11693
     11694        pAttach.queryInterfaceTo(aNewAttachment);
     11695    }
     11696
     11697    setModified(IsModified_Storage);
     11698
     11699    multiLock.release();
     11700
     11701    mParent->saveRegistries(llRegistriesThatNeedSaving);
     11702
     11703    return rc;
     11704}
     11705
    1164211706// public methods only for internal purposes
    1164311707/////////////////////////////////////////////////////////////////////////////
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