VirtualBox

Changeset 18194 in vbox for trunk/src


Ignore:
Timestamp:
Mar 24, 2009 3:04:37 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
44910
Message:

Main: #3727: VBoxManage controlvm dvdattach does not work if the image was attached before.

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

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

    r17238 r18194  
    590590
    591591        m.rollback();
     592        if (!m->image.isNull())
     593        {
     594            /* Reattach from the old image. */
     595            HRESULT rc = m->image->attachTo(mParent->id(), mParent->snapshotId());
     596            AssertComRC (rc);
     597            if (Global::IsOnline (adep.machineState()))
     598            {
     599                /* Lock from the old image. */
     600                rc = m->image->LockRead (NULL);
     601                AssertComRC (rc);
     602            }
     603        }
    592604    }
    593605
     
    609621    AssertComRCReturnVoid (peerCaller.rc());
    610622
    611     /* we need adep for the state check */
    612     Machine::AutoAnyStateDependency adep (mParent);
    613     AssertComRCReturnVoid (adep.rc());
    614 
    615623    /* lock both for writing since we modify both (mPeer is "master" so locked
    616624     * first) */
     
    619627    if (m.isBackedUp())
    620628    {
    621         Data *oldData = m.backedUpData();
    622 
    623         if (!oldData->image.isNull() &&
    624             !oldData->image.equalsTo (m->image))
    625         {
    626             /* detach the old image that will go away after commit */
    627             oldData->image->detachFrom (mParent->id(), mParent->snapshotId());
    628 
    629             /* unlock the image for reading if the VM is online */
    630             if (Global::IsOnline (adep.machineState()))
    631             {
    632                 HRESULT rc = oldData->image->UnlockRead (NULL);
    633                 AssertComRC (rc);
    634             }
    635         }
    636 
    637629        m.commit();
    638630        if (mPeer)
     
    676668{
    677669    AssertReturn (isWriteLockOnCurrentThread(), E_FAIL);
     670
     671    /* we need adep for the state check */
     672    Machine::AutoAnyStateDependency adep (mParent);
     673    AssertComRCReturn (adep.rc(), false);
     674
     675    if (!m->image.isNull())
     676    {
     677        HRESULT rc = m->image->detachFrom (mParent->id(), mParent->snapshotId());
     678        AssertComRC (rc);
     679        if (Global::IsOnline (adep.machineState()))
     680        {
     681            rc = m->image->UnlockRead (NULL);
     682            AssertComRC (rc);
     683        }
     684    }
    678685
    679686    m.backup();
  • trunk/src/VBox/Main/FloppyDriveImpl.cpp

    r17255 r18194  
    597597
    598598        m.rollback();
     599        if (!m->image.isNull())
     600        {
     601            /* Reattach from the old image. */
     602            HRESULT rc = m->image->attachTo(mParent->id(), mParent->snapshotId());
     603            AssertComRC (rc);
     604            if (Global::IsOnline (adep.machineState()))
     605            {
     606                /* Lock from the old image. */
     607                rc = m->image->LockRead (NULL);
     608                AssertComRC (rc);
     609            }
     610        }
    599611    }
    600612
     
    616628    AssertComRCReturnVoid (peerCaller.rc());
    617629
    618     /* we need adep for the state check */
    619     Machine::AutoAnyStateDependency adep (mParent);
    620     AssertComRCReturnVoid (adep.rc());
    621 
    622630    /* lock both for writing since we modify both (mPeer is "master" so locked
    623631     * first) */
     
    626634    if (m.isBackedUp())
    627635    {
    628         Data *oldData = m.backedUpData();
    629 
    630         if (!oldData->image.isNull() &&
    631             !oldData->image.equalsTo (m->image))
    632         {
    633             /* detach the old image that will go away after commit */
    634             oldData->image->detachFrom (mParent->id(), mParent->snapshotId());
    635 
    636             /* unlock the image for reading if the VM is online */
    637             if (Global::IsOnline (adep.machineState()))
    638             {
    639                 HRESULT rc = oldData->image->UnlockRead (NULL);
    640                 AssertComRC (rc);
    641             }
    642         }
    643 
    644636        m.commit();
    645637        if (mPeer)
     
    681673{
    682674    AssertReturn (isWriteLockOnCurrentThread(), E_FAIL);
     675
     676    /* we need adep for the state check */
     677    Machine::AutoAnyStateDependency adep (mParent);
     678    AssertComRCReturn (adep.rc(), false);
     679
     680    if (!m->image.isNull())
     681    {
     682        HRESULT rc = m->image->detachFrom (mParent->id(), mParent->snapshotId());
     683        AssertComRC (rc);
     684        if (Global::IsOnline (adep.machineState()))
     685        {
     686            rc = m->image->UnlockRead (NULL);
     687            AssertComRC (rc);
     688        }
     689    }
    683690
    684691    m.backup();
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