VirtualBox

Changeset 15991 in vbox


Ignore:
Timestamp:
Jan 16, 2009 2:02:20 PM (16 years ago)
Author:
vboxsync
Message:

Main: Fixed: CD/DVD and Floppy not locked for reading when manually attached at VM runtime (#3504).

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

Legend:

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

    r15945 r15991  
    25092509HRESULT Console::onDVDDriveChange()
    25102510{
    2511     LogFlowThisFunc (("\n"));
     2511    LogFlowThisFuncEnter();
    25122512
    25132513    AutoCaller autoCaller (this);
     
    25782578
    25792579    AssertComRC (rc);
    2580     if (FAILED (rc))
    2581     {
    2582         LogFlowThisFunc (("Returns %#x\n", rc));
    2583         return rc;
    2584     }
    2585 
    2586     rc = doDriveChange ("piix3ide", 0, 2, eState, &meDVDState,
    2587                         Utf8Str (Path).raw(), fPassthrough);
    2588 
    2589     /* notify console callbacks on success */
    25902580    if (SUCCEEDED (rc))
    25912581    {
    2592         CallbackList::iterator it = mCallbacks.begin();
    2593         while (it != mCallbacks.end())
    2594             (*it++)->OnDVDDriveChange();
    2595     }
    2596 
     2582        rc = doDriveChange ("piix3ide", 0, 2, eState, &meDVDState,
     2583                            Utf8Str (Path).raw(), fPassthrough);
     2584
     2585        /* notify console callbacks on success */
     2586        if (SUCCEEDED (rc))
     2587        {
     2588            CallbackList::iterator it = mCallbacks.begin();
     2589            while (it != mCallbacks.end())
     2590                (*it++)->OnDVDDriveChange();
     2591        }
     2592    }
     2593
     2594    LogFlowThisFunc (("Returns %Rhrc (%#x)\n", rc, rc));
     2595    LogFlowThisFuncLeave();
    25972596    return rc;
    25982597}
     
    26062605HRESULT Console::onFloppyDriveChange()
    26072606{
    2608     LogFlowThisFunc (("\n"));
     2607    LogFlowThisFuncEnter();
    26092608
    26102609    AutoCaller autoCaller (this);
     
    26802679
    26812680    AssertComRC (rc);
    2682     if (FAILED (rc))
    2683     {
    2684         LogFlowThisFunc (("Returns %#x\n", rc));
    2685         return rc;
    2686     }
    2687 
    2688     rc = doDriveChange ("i82078", 0, 0, eState, &meFloppyState,
    2689                         Utf8Str (Path).raw(), false);
    2690 
    2691     /* notify console callbacks on success */
    26922681    if (SUCCEEDED (rc))
    26932682    {
    2694         CallbackList::iterator it = mCallbacks.begin();
    2695         while (it != mCallbacks.end())
    2696             (*it++)->OnFloppyDriveChange();
    2697     }
    2698 
     2683        rc = doDriveChange ("i82078", 0, 0, eState, &meFloppyState,
     2684                            Utf8Str (Path).raw(), false);
     2685
     2686        /* notify console callbacks on success */
     2687        if (SUCCEEDED (rc))
     2688        {
     2689            CallbackList::iterator it = mCallbacks.begin();
     2690            while (it != mCallbacks.end())
     2691                (*it++)->OnFloppyDriveChange();
     2692        }
     2693    }
     2694
     2695    LogFlowThisFunc (("Returns %Rhrc (%#x)\n", rc, rc));
     2696    LogFlowThisFuncLeave();
    26992697    return rc;
    27002698}
  • trunk/src/VBox/Main/DVDDriveImpl.cpp

    r15661 r15991  
    2929#include "VirtualBoxImpl.h"
    3030
     31#include "Global.h"
     32
    3133#include "Logging.h"
    3234
     
    7072    /* mPeer is left null */
    7173
    72     mData.allocate();
     74    m.allocate();
    7375
    7476    /* Confirm a successful initialization */
     
    105107
    106108    AutoReadLock thatLock (aThat);
    107     mData.share (aThat->mData);
     109    m.share (aThat->m);
    108110
    109111    /* Confirm a successful initialization */
     
    137139
    138140    AutoReadLock thatLock (aThat);
    139     mData.attachCopy (aThat->mData);
     141    m.attachCopy (aThat->m);
    140142
    141143    /* at present, this must be a snapshot machine */
    142144    Assert (!aParent->snapshotId().isEmpty());
    143145
    144     if (mData->mState == DriveState_ImageMounted)
     146    if (m->state == DriveState_ImageMounted)
    145147    {
    146148        /* associate the DVD image media with the snapshot */
    147         HRESULT rc = mData->mImage->attachTo (aParent->id(),
    148                                               aParent->snapshotId());
     149        HRESULT rc = m->image->attachTo (aParent->id(),
     150                                         aParent->snapshotId());
    149151        AssertComRC (rc);
    150152    }
     
    171173    if ((mParent->type() == Machine::IsMachine ||
    172174         mParent->type() == Machine::IsSnapshotMachine) &&
    173         mData->mState == DriveState_ImageMounted)
     175        m->state == DriveState_ImageMounted)
    174176    {
    175177        /* Deassociate the DVD image (only when mParent is a real Machine or a
     
    178180         * re-initialization of the VM after successfully re-checking the
    179181         * accessibility state. */
    180         HRESULT rc = mData->mImage->detachFrom (mParent->id(),
    181                                                 mParent->snapshotId());
     182        HRESULT rc = m->image->detachFrom (mParent->id(),
     183                                           mParent->snapshotId());
    182184        AssertComRC (rc);
    183185    }
    184186
    185     mData.free();
     187    m.free();
    186188
    187189    unconst (mPeer).setNull();
     
    201203    AutoReadLock alock (this);
    202204
    203     *aState = mData->mState;
     205    *aState = m->state;
    204206
    205207    return S_OK;
     
    215217    AutoReadLock alock (this);
    216218
    217     *aPassthrough = mData->mPassthrough;
     219    *aPassthrough = m->passthrough;
    218220
    219221    return S_OK;
     
    231233    AutoWriteLock alock (this);
    232234
    233     if (mData->mPassthrough != aPassthrough)
    234     {
    235         mData.backup();
    236         mData->mPassthrough = aPassthrough;
     235    if (m->passthrough != aPassthrough)
     236    {
     237        m.backup();
     238        m->passthrough = aPassthrough;
    237239    }
    238240
     
    268270    if (SUCCEEDED (rc))
    269271    {
    270         if (mData->mState != DriveState_ImageMounted ||
    271             !mData->mImage.equalsTo (image))
     272        if (m->state != DriveState_ImageMounted ||
     273            !m->image.equalsTo (image))
    272274        {
    273275            rc = image->attachTo (mParent->id(), mParent->snapshotId());
     
    276278                /* umount() will backup data */
    277279                rc = unmount();
     280
    278281                if (SUCCEEDED (rc))
    279282                {
    280                     mData->mImage = image;
    281                     mData->mState = DriveState_ImageMounted;
     283                    /* lock the image for reading if the VM is online. It will
     284                     * be unlocked either when unmounted from this drive or by
     285                     * SessionMachine::setMachineState() when the VM is
     286                     * terminated */
     287                    if (Global::IsOnline (adep.machineState()))
     288                        rc = image->LockRead (NULL);
     289                }
     290
     291                if (SUCCEEDED (rc))
     292                {
     293                    m->image = image;
     294                    m->state = DriveState_ImageMounted;
    282295
    283296                    /* leave the lock before informing callbacks */
     
    306319    AutoWriteLock alock (this);
    307320
    308     if (mData->mState != DriveState_HostDriveCaptured ||
    309         !mData->mHostDrive.equalsTo (aHostDVDDrive))
     321    if (m->state != DriveState_HostDriveCaptured ||
     322        !m->hostDrive.equalsTo (aHostDVDDrive))
    310323    {
    311324        /* umount() will backup data */
     
    313326        if (SUCCEEDED (rc))
    314327        {
    315             mData->mHostDrive = aHostDVDDrive;
    316             mData->mState = DriveState_HostDriveCaptured;
     328            m->hostDrive = aHostDVDDrive;
     329            m->state = DriveState_HostDriveCaptured;
    317330
    318331            /* leave the lock before informing callbacks */
     
    337350    AutoWriteLock alock (this);
    338351
    339     if (mData->mState != DriveState_NotMounted)
     352    if (m->state != DriveState_NotMounted)
    340353    {
    341354        /* umount() will backup data */
     
    343356        if (SUCCEEDED (rc))
    344357        {
    345             mData->mState = DriveState_NotMounted;
     358            m->state = DriveState_NotMounted;
    346359
    347360            /* leave the lock before informing callbacks */
     
    364377    AutoReadLock alock (this);
    365378
    366     mData->mImage.queryInterfaceTo (aDVDImage);
     379    m->image.queryInterfaceTo (aDVDImage);
    367380
    368381    return S_OK;
     
    378391    AutoReadLock alock (this);
    379392
    380     mData->mHostDrive.queryInterfaceTo (aHostDrive);
     393    m->hostDrive.queryInterfaceTo (aHostDrive);
    381394
    382395    return S_OK;
     
    422435
    423436    /* optional, defaults to false */
    424     mData->mPassthrough = dvdDriveNode.value <bool> ("passthrough");
     437    m->passthrough = dvdDriveNode.value <bool> ("passthrough");
    425438
    426439    Key typeNode;
     
    490503    Key node = aMachineNode.createKey ("DVDDrive");
    491504
    492     node.setValue <bool> ("passthrough", !!mData->mPassthrough);
    493 
    494     switch (mData->mState)
     505    node.setValue <bool> ("passthrough", !!m->passthrough);
     506
     507    switch (m->state)
    495508    {
    496509        case DriveState_ImageMounted:
    497510        {
    498             Assert (!mData->mImage.isNull());
     511            Assert (!m->image.isNull());
    499512
    500513            Guid id;
    501             HRESULT rc = mData->mImage->COMGETTER(Id) (id.asOutParam());
     514            HRESULT rc = m->image->COMGETTER(Id) (id.asOutParam());
    502515            AssertComRC (rc);
    503516            Assert (!id.isEmpty());
     
    509522        case DriveState_HostDriveCaptured:
    510523        {
    511             Assert (!mData->mHostDrive.isNull());
     524            Assert (!m->hostDrive.isNull());
    512525
    513526            Bstr name;
    514             HRESULT  rc = mData->mHostDrive->COMGETTER(Name) (name.asOutParam());
     527            HRESULT  rc = m->hostDrive->COMGETTER(Name) (name.asOutParam());
    515528            AssertComRC (rc);
    516529            Assert (!name.isEmpty());
     
    524537            break;
    525538        default:
    526             ComAssertMsgFailedRet (("Invalid drive state: %d", mData->mState),
     539            ComAssertMsgFailedRet (("Invalid drive state: %d", m->state),
    527540                                    E_FAIL);
    528541    }
     
    540553    AssertComRCReturn (autoCaller.rc(), false);
    541554
     555    /* we need adep for the state check */
     556    Machine::AutoAnyStateDependency adep (mParent);
     557    AssertComRCReturn (adep.rc(), false);
     558
    542559    AutoWriteLock alock (this);
    543560
    544561    bool changed = false;
    545562
    546     if (mData.isBackedUp())
     563    if (m.isBackedUp())
    547564    {
    548565        /* we need to check all data to see whether anything will be changed
    549566         * after rollback */
    550         changed = mData.hasActualChanges();
     567        changed = m.hasActualChanges();
    551568
    552569        if (changed)
    553570        {
    554             Data *oldData = mData.backedUpData();
    555 
    556             if (!mData->mImage.isNull() &&
    557                 !oldData->mImage.equalsTo (mData->mImage))
     571            Data *oldData = m.backedUpData();
     572
     573            if (!m->image.isNull() &&
     574                !oldData->image.equalsTo (m->image))
    558575            {
    559576                /* detach the current image that will go away after rollback */
    560                 mData->mImage->detachFrom (mParent->id(), mParent->snapshotId());
     577                m->image->detachFrom (mParent->id(), mParent->snapshotId());
     578
     579                /* unlock the image for reading if the VM is online */
     580                if (Global::IsOnline (adep.machineState()))
     581                {
     582                    HRESULT rc = m->image->UnlockRead (NULL);
     583                    AssertComRC (rc);
     584                }
    561585            }
    562586        }
    563587
    564         mData.rollback();
     588        m.rollback();
    565589    }
    566590
     
    582606    AssertComRCReturnVoid (peerCaller.rc());
    583607
     608    /* we need adep for the state check */
     609    Machine::AutoAnyStateDependency adep (mParent);
     610    AssertComRCReturnVoid (adep.rc());
     611
    584612    /* lock both for writing since we modify both (mPeer is "master" so locked
    585613     * first) */
    586614    AutoMultiWriteLock2 alock (mPeer, this);
    587615
    588     if (mData.isBackedUp())
    589     {
    590         Data *oldData = mData.backedUpData();
    591 
    592         if (!oldData->mImage.isNull() &&
    593             !oldData->mImage.equalsTo (mData->mImage))
     616    if (m.isBackedUp())
     617    {
     618        Data *oldData = m.backedUpData();
     619
     620        if (!oldData->image.isNull() &&
     621            !oldData->image.equalsTo (m->image))
    594622        {
    595623            /* detach the old image that will go away after commit */
    596             oldData->mImage->detachFrom (mParent->id(), mParent->snapshotId());
    597         }
    598 
    599         mData.commit();
     624            oldData->image->detachFrom (mParent->id(), mParent->snapshotId());
     625
     626            /* unlock the image for reading if the VM is online */
     627            if (Global::IsOnline (adep.machineState()))
     628            {
     629                HRESULT rc = oldData->image->UnlockRead (NULL);
     630                AssertComRC (rc);
     631            }
     632        }
     633
     634        m.commit();
    600635        if (mPeer)
    601636        {
    602637            /* attach new data to the peer and reshare it */
    603             mPeer->mData.attach (mData);
     638            mPeer->m.attach (m);
    604639        }
    605640    }
     
    627662
    628663    /* this will back up current data */
    629     mData.assignCopy (aThat->mData);
     664    m.assignCopy (aThat->m);
    630665}
    631666
     
    639674    AssertReturn (isWriteLockOnCurrentThread(), E_FAIL);
    640675
    641     mData.backup();
    642 
    643     if (mData->mImage)
    644         mData->mImage.setNull();
    645     if (mData->mHostDrive)
    646         mData->mHostDrive.setNull();
    647 
    648     mData->mState = DriveState_NotMounted;
     676    m.backup();
     677
     678    if (m->image)
     679        m->image.setNull();
     680    if (m->hostDrive)
     681        m->hostDrive.setNull();
     682
     683    m->state = DriveState_NotMounted;
    649684
    650685    return S_OK;
  • trunk/src/VBox/Main/FloppyDriveImpl.cpp

    r15714 r15991  
    2929#include "VirtualBoxImpl.h"
    3030
     31#include "Global.h"
     32
    3133#include "Logging.h"
    3234
     
    7072    /* mPeer is left null */
    7173
    72     mData.allocate();
     74    m.allocate();
    7375
    7476    /* Confirm a successful initialization */
     
    105107
    106108    AutoReadLock thatLock (aThat);
    107     mData.share (aThat->mData);
     109    m.share (aThat->m);
    108110
    109111    /* Confirm a successful initialization */
     
    137139
    138140    AutoReadLock thatLock (aThat);
    139     mData.attachCopy (aThat->mData);
     141    m.attachCopy (aThat->m);
    140142
    141143    /* at present, this must be a snapshot machine */
    142144    Assert (!aParent->snapshotId().isEmpty());
    143145
    144     if (mData->mState == DriveState_ImageMounted)
     146    if (m->state == DriveState_ImageMounted)
    145147    {
    146148        /* associate the DVD image media with the snapshot */
    147         HRESULT rc = mData->mImage->attachTo (aParent->id(),
    148                                               aParent->snapshotId());
     149        HRESULT rc = m->image->attachTo (aParent->id(),
     150                                         aParent->snapshotId());
    149151        AssertComRC (rc);
    150152    }
     
    171173    if ((mParent->type() == Machine::IsMachine ||
    172174         mParent->type() == Machine::IsSnapshotMachine) &&
    173         mData->mState == DriveState_ImageMounted)
     175        m->state == DriveState_ImageMounted)
    174176    {
    175177        /* Deassociate the DVD image (only when mParent is a real Machine or a
     
    178180         * re-initialization of the VM after successfully re-checking the
    179181         * accessibility state. */
    180         HRESULT rc = mData->mImage->detachFrom (mParent->id(),
    181                                                 mParent->snapshotId());
     182        HRESULT rc = m->image->detachFrom (mParent->id(),
     183                                           mParent->snapshotId());
    182184        AssertComRC (rc);
    183185    }
    184186
    185     mData.free();
     187    m.free();
    186188
    187189    unconst (mPeer).setNull();
     
    201203    AutoReadLock alock (this);
    202204
    203     *aEnabled = mData->mEnabled;
     205    *aEnabled = m->enabled;
    204206
    205207    return S_OK;
     
    219221    AutoWriteLock alock (this);
    220222
    221     if (mData->mEnabled != aEnabled)
    222     {
    223         mData.backup();
    224         mData->mEnabled = aEnabled;
     223    if (m->enabled != aEnabled)
     224    {
     225        m.backup();
     226        m->enabled = aEnabled;
    225227
    226228        /* leave the lock before informing callbacks */
     
    242244    AutoReadLock alock (this);
    243245
    244     *aState = mData->mState;
     246    *aState = m->state;
    245247
    246248    return S_OK;
     
    275277    if (SUCCEEDED (rc))
    276278    {
    277         if (mData->mState != DriveState_ImageMounted ||
    278             !mData->mImage.equalsTo (image))
     279        if (m->state != DriveState_ImageMounted ||
     280            !m->image.equalsTo (image))
    279281        {
    280282            rc = image->attachTo (mParent->id(), mParent->snapshotId());
     
    283285                /* umount() will backup data */
    284286                rc = unmount();
     287
    285288                if (SUCCEEDED (rc))
    286289                {
    287                     mData->mImage = image;
    288                     mData->mState = DriveState_ImageMounted;
     290                    /* lock the image for reading if the VM is online. It will
     291                     * be unlocked either when unmounted from this drive or by
     292                     * SessionMachine::setMachineState() when the VM is
     293                     * terminated */
     294                    if (Global::IsOnline (adep.machineState()))
     295                        rc = image->LockRead (NULL);
     296                }
     297
     298                if (SUCCEEDED (rc))
     299                {
     300                    m->image = image;
     301                    m->state = DriveState_ImageMounted;
    289302
    290303                    /* leave the lock before informing callbacks */
     
    313326    AutoWriteLock alock (this);
    314327
    315     if (mData->mState != DriveState_HostDriveCaptured ||
    316         !mData->mHostDrive.equalsTo (aHostFloppyDrive))
     328    if (m->state != DriveState_HostDriveCaptured ||
     329        !m->hostDrive.equalsTo (aHostFloppyDrive))
    317330    {
    318331        /* umount() will backup data */
     
    320333        if (SUCCEEDED (rc))
    321334        {
    322             mData->mHostDrive = aHostFloppyDrive;
    323             mData->mState = DriveState_HostDriveCaptured;
     335            m->hostDrive = aHostFloppyDrive;
     336            m->state = DriveState_HostDriveCaptured;
    324337
    325338            /* leave the lock before informing callbacks */
     
    344357    AutoWriteLock alock (this);
    345358
    346     if (mData->mState != DriveState_NotMounted)
     359    if (m->state != DriveState_NotMounted)
    347360    {
    348361        /* umount() will backup data */
     
    350363        if (SUCCEEDED (rc))
    351364        {
    352             mData->mState = DriveState_NotMounted;
     365            m->state = DriveState_NotMounted;
    353366
    354367            /* leave the lock before informing callbacks */
     
    371384    AutoReadLock alock (this);
    372385
    373     mData->mImage.queryInterfaceTo (aFloppyImage);
     386    m->image.queryInterfaceTo (aFloppyImage);
    374387
    375388    return S_OK;
     
    385398    AutoReadLock alock (this);
    386399
    387     mData->mHostDrive.queryInterfaceTo (aHostDrive);
     400    m->hostDrive.queryInterfaceTo (aHostDrive);
    388401
    389402    return S_OK;
     
    429442
    430443    /* optional, defaults to true */
    431     mData->mEnabled = floppyDriveNode.value <bool> ("enabled");
     444    m->enabled = floppyDriveNode.value <bool> ("enabled");
    432445
    433446    Key typeNode;
     
    497510    Key node = aMachineNode.createKey ("FloppyDrive");
    498511
    499     node.setValue <bool> ("enabled", !!mData->mEnabled);
    500 
    501     switch (mData->mState)
     512    node.setValue <bool> ("enabled", !!m->enabled);
     513
     514    switch (m->state)
    502515    {
    503516        case DriveState_ImageMounted:
    504517        {
    505             Assert (!mData->mImage.isNull());
     518            Assert (!m->image.isNull());
    506519
    507520            Guid id;
    508             HRESULT rc = mData->mImage->COMGETTER(Id) (id.asOutParam());
     521            HRESULT rc = m->image->COMGETTER(Id) (id.asOutParam());
    509522            AssertComRC (rc);
    510523            Assert (!id.isEmpty());
     
    516529        case DriveState_HostDriveCaptured:
    517530        {
    518             Assert (!mData->mHostDrive.isNull());
     531            Assert (!m->hostDrive.isNull());
    519532
    520533            Bstr name;
    521             HRESULT  rc = mData->mHostDrive->COMGETTER(Name) (name.asOutParam());
     534            HRESULT  rc = m->hostDrive->COMGETTER(Name) (name.asOutParam());
    522535            AssertComRC (rc);
    523536            Assert (!name.isEmpty());
     
    531544            break;
    532545        default:
    533             ComAssertMsgFailedRet (("Invalid drive state: %d", mData->mState),
     546            ComAssertMsgFailedRet (("Invalid drive state: %d", m->state),
    534547                                    E_FAIL);
    535548    }
     
    547560    AssertComRCReturn (autoCaller.rc(), false);
    548561
     562    /* we need adep for the state check */
     563    Machine::AutoAnyStateDependency adep (mParent);
     564    AssertComRCReturn (adep.rc(), false);
     565
    549566    AutoWriteLock alock (this);
    550567
    551568    bool changed = false;
    552569
    553     if (mData.isBackedUp())
     570    if (m.isBackedUp())
    554571    {
    555572        /* we need to check all data to see whether anything will be changed
    556573         * after rollback */
    557         changed = mData.hasActualChanges();
     574        changed = m.hasActualChanges();
    558575
    559576        if (changed)
    560577        {
    561             Data *oldData = mData.backedUpData();
    562 
    563             if (!mData->mImage.isNull() &&
    564                 !oldData->mImage.equalsTo (mData->mImage))
     578            Data *oldData = m.backedUpData();
     579
     580            if (!m->image.isNull() &&
     581                !oldData->image.equalsTo (m->image))
    565582            {
    566583                /* detach the current image that will go away after rollback */
    567                 mData->mImage->detachFrom (mParent->id(), mParent->snapshotId());
     584                m->image->detachFrom (mParent->id(), mParent->snapshotId());
     585
     586                /* unlock the image for reading if the VM is online */
     587                if (Global::IsOnline (adep.machineState()))
     588                {
     589                    HRESULT rc = m->image->UnlockRead (NULL);
     590                    AssertComRC (rc);
     591                }
    568592            }
    569593        }
    570594
    571         mData.rollback();
     595        m.rollback();
    572596    }
    573597
     
    589613    AssertComRCReturnVoid (peerCaller.rc());
    590614
     615    /* we need adep for the state check */
     616    Machine::AutoAnyStateDependency adep (mParent);
     617    AssertComRCReturnVoid (adep.rc());
     618
    591619    /* lock both for writing since we modify both (mPeer is "master" so locked
    592620     * first) */
    593621    AutoMultiWriteLock2 alock (mPeer, this);
    594622
    595     if (mData.isBackedUp())
    596     {
    597         Data *oldData = mData.backedUpData();
    598 
    599         if (!oldData->mImage.isNull() &&
    600             !oldData->mImage.equalsTo (mData->mImage))
     623    if (m.isBackedUp())
     624    {
     625        Data *oldData = m.backedUpData();
     626
     627        if (!oldData->image.isNull() &&
     628            !oldData->image.equalsTo (m->image))
    601629        {
    602630            /* detach the old image that will go away after commit */
    603             oldData->mImage->detachFrom (mParent->id(), mParent->snapshotId());
    604         }
    605 
    606         mData.commit();
     631            oldData->image->detachFrom (mParent->id(), mParent->snapshotId());
     632
     633            /* unlock the image for reading if the VM is online */
     634            if (Global::IsOnline (adep.machineState()))
     635            {
     636                HRESULT rc = oldData->image->UnlockRead (NULL);
     637                AssertComRC (rc);
     638            }
     639        }
     640
     641        m.commit();
    607642        if (mPeer)
    608643        {
    609644            /* attach new data to the peer and reshare it */
    610             mPeer->mData.attach (mData);
     645            mPeer->m.attach (m);
    611646        }
    612647    }
     
    632667
    633668    /* this will back up current data */
    634     mData.assignCopy (aThat->mData);
     669    m.assignCopy (aThat->m);
    635670}
    636671
     
    644679    AssertReturn (isWriteLockOnCurrentThread(), E_FAIL);
    645680
    646     mData.backup();
    647 
    648     if (mData->mImage)
    649         mData->mImage.setNull();
    650     if (mData->mHostDrive)
    651         mData->mHostDrive.setNull();
    652 
    653     mData->mState = DriveState_NotMounted;
     681    m.backup();
     682
     683    if (m->image)
     684        m->image.setNull();
     685    if (m->hostDrive)
     686        m->hostDrive.setNull();
     687
     688    m->state = DriveState_NotMounted;
    654689
    655690    return S_OK;
  • trunk/src/VBox/Main/MachineImpl.cpp

    r15945 r15991  
    1042810428        {
    1042910429            AutoReadLock driveLock (mDVDDrive);
    10430             if (mDVDDrive->data()->mState == DriveState_ImageMounted)
     10430            if (mDVDDrive->data()->state == DriveState_ImageMounted)
    1043110431            {
    10432                 rc = mDVDDrive->data()->mImage->UnlockRead (NULL);
     10432                rc = mDVDDrive->data()->image->UnlockRead (NULL);
    1043310433                AssertComRC (rc);
    1043410434            }
     
    1043610436        {
    1043710437            AutoReadLock driveLock (mFloppyDrive);
    10438             if (mFloppyDrive->data()->mState == DriveState_ImageMounted)
     10438            if (mFloppyDrive->data()->state == DriveState_ImageMounted)
    1043910439            {
    10440                 rc = mFloppyDrive->data()->mImage->UnlockRead (NULL);
     10440                rc = mFloppyDrive->data()->image->UnlockRead (NULL);
    1044110441                AssertComRC (rc);
    1044210442            }
  • trunk/src/VBox/Main/include/DVDDriveImpl.h

    r15334 r15991  
    4343        Data()
    4444        {
    45             mState = DriveState_NotMounted;
    46             mPassthrough = false;
     45            state = DriveState_NotMounted;
     46            passthrough = false;
    4747        }
    4848
     
    5050        {
    5151            return this == &that ||
    52                    (mState == that.mState &&
    53                     mImage.equalsTo (that.mImage) &&
    54                     mHostDrive.equalsTo (that.mHostDrive));
     52                   (state == that.state &&
     53                    image.equalsTo (that.image) &&
     54                    hostDrive.equalsTo (that.hostDrive));
    5555        }
    5656
    57         ComObjPtr <DVDImage2> mImage;
    58         ComPtr <IHostDVDDrive> mHostDrive;
    59         DriveState_T mState;
    60         BOOL mPassthrough;
     57        ComObjPtr <DVDImage2> image;
     58        ComPtr <IHostDVDDrive> hostDrive;
     59        DriveState_T state;
     60        BOOL passthrough;
    6161    };
    6262
     
    102102    HRESULT saveSettings (settings::Key &aMachineNode);
    103103
    104     bool isModified() { AutoWriteLock alock (this); return mData.isBackedUp(); }
    105     bool isReallyModified() { AutoWriteLock alock (this); return mData.hasActualChanges(); }
     104    bool isModified() { AutoWriteLock alock (this); return m.isBackedUp(); }
     105    bool isReallyModified() { AutoWriteLock alock (this); return m.hasActualChanges(); }
    106106    bool rollback();
    107107    void commit();
     
    113113    // (ensure there is a caller and a read lock before calling them!)
    114114
    115     Backupable <Data> &data() { return mData; }
     115    Backupable <Data> &data() { return m; }
    116116
    117117    // for VirtualBoxSupportErrorInfoImpl
     
    123123    const ComObjPtr <DVDDrive> mPeer;
    124124
    125     Backupable <Data> mData;
     125    Backupable <Data> m;
    126126};
    127127
  • trunk/src/VBox/Main/include/FloppyDriveImpl.h

    r15334 r15991  
    4343        Data()
    4444        {
    45             mEnabled    = true;
    46             mState = DriveState_NotMounted;
     45            enabled = true;
     46            state = DriveState_NotMounted;
    4747        }
    4848
     
    5050        {
    5151            return this == &that ||
    52                    (mState == that.mState &&
    53                     mImage.equalsTo (that.mImage) &&
    54                     mHostDrive.equalsTo (that.mHostDrive));
     52                   (state == that.state &&
     53                    image.equalsTo (that.image) &&
     54                    hostDrive.equalsTo (that.hostDrive));
    5555        }
    5656
    57         BOOL mEnabled;
    58         ComObjPtr <FloppyImage2> mImage;
    59         ComPtr <IHostFloppyDrive> mHostDrive;
    60         DriveState_T mState;
     57        BOOL enabled;
     58        ComObjPtr <FloppyImage2> image;
     59        ComPtr <IHostFloppyDrive> hostDrive;
     60        DriveState_T state;
    6161    };
    6262
     
    102102    HRESULT saveSettings (settings::Key &aMachineNode);
    103103
    104     bool isModified() { AutoWriteLock alock (this); return mData.isBackedUp(); }
    105     bool isReallyModified() { AutoWriteLock alock (this); return mData.hasActualChanges(); }
     104    bool isModified() { AutoWriteLock alock (this); return m.isBackedUp(); }
     105    bool isReallyModified() { AutoWriteLock alock (this); return m.hasActualChanges(); }
    106106    bool rollback();
    107107    void commit();
     
    113113    // (ensure there is a caller and a read lock before calling them!)
    114114
    115     Backupable <Data> &data() { return mData; }
     115    Backupable <Data> &data() { return m; }
    116116
    117117    // for VirtualBoxSupportErrorInfoImpl
     
    123123    const ComObjPtr <FloppyDrive> mPeer;
    124124
    125     Backupable <Data> mData;
     125    Backupable <Data> m;
    126126};
    127127
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