VirtualBox

Changeset 1874 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Apr 3, 2007 11:00:09 AM (18 years ago)
Author:
vboxsync
Message:

Main: Fixed: Simultaneous usage of immutable VDIs by more than one running VM was not possible.

Location:
trunk/src/VBox
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/VBoxHDD.cpp

    r1565 r1874  
    347347                                    N_("VHDD: Configuration error: Querying \"Path\" as string failed"));
    348348
    349         rc = CFGMR3QueryBool(pCfgHandle, "ReadOnly", &fReadOnly);
     349        rc = CFGMR3QueryBool(pCurNode, "ReadOnly", &fReadOnly);
    350350        if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    351351            fReadOnly = false;
  • trunk/src/VBox/Main/ConsoleImpl.cpp

    r1721 r1874  
    48694869                rc = CFGMR3InsertString(pCur,  "Path", psz);                            RC_CHECK();
    48704870                STR_FREE();
     4871                rc = CFGMR3InsertInteger(pCur, "ReadOnly", 1);                          RC_CHECK();
    48714872
    48724873                /* next */
  • trunk/src/VBox/Main/HardDiskImpl.cpp

    r1553 r1874  
    567567 *  in the first place.
    568568 *
    569  *  When @a aCheckBusy is true, this method checks that mBusy = false and
    570  *  mReaders = 0 (and returns an appropriate error if not). This lets
    571  *  reimplementations successfully call setBusy() to lock the disk for the
    572  *  duration of the check if they need. Note that in this case, the
    573  *  reimplementation must enter the object lock before calling this method
    574  *  and not leave it before calling setBusy() to avoid race condition.
    575  *
    576  *  @param aAccessError On output, a null string indicates the hard disk is
    577  *                      accessible, otherwise contains a message describing
    578  *                      the reason of inaccessibility.
    579  *  @param aCheckBusy   Whether to do the busy check or not.
     569 *  When @a aCheckBusy is true, this method checks that mBusy = false (and
     570 *  returns an appropriate error if not). This lets reimplementations
     571 *  successfully call addReader() after getBaseAccessible() succeeds to
     572 *  reference the disk and protect it from being modified or deleted before
     573 *  the remaining check steps are done. Note that in this case, the
     574 *  reimplementation must enter the object lock before calling this method and
     575 *  must not leave it before calling addReader() to avoid race condition.
     576 *
     577 *  When @a aCheckReaders is true, this method checks that mReaders = 0 (and
     578 *  returns an appropriate error if not). When set to true together with
     579 *  @a aCheckBusy, this lets reimplementations successfully call setBusy() after
     580 *  getBaseAccessible() succeeds to lock the disk and make sure nobody is
     581 *  referencing it until the remaining check steps are done. Note that in this
     582 *  case, the reimplementation must enter the object lock before calling this
     583 *  method and must not leave it before calling setBusy() to avoid race
     584 *  condition.
     585 *
     586 *  @param aAccessError     On output, a null string indicates the hard disk is
     587 *                          accessible, otherwise contains a message describing
     588 *                          the reason of inaccessibility.
     589 *  @param aCheckBusy       Whether to do the busy check or not.
     590 *  @param aCheckReaders    Whether to do readers check or not.
    580591 */
    581592HRESULT HardDisk::getBaseAccessible (Bstr &aAccessError,
    582                                      bool aCheckBusy /* = false */)
     593                                     bool aCheckBusy /* = false */,
     594                                     bool aCheckReaders /* = false */)
    583595{
    584596    AutoLock alock (this);
     
    594606                tr ("Hard disk '%ls' is being exclusively used by another task"),
    595607                toString().raw());
     608            return S_OK;
    596609        }
    597         else if (mReaders > 0)
     610    }
     611
     612    if (aCheckReaders)
     613    {
     614        if (mReaders > 0)
    598615        {
    599616            aAccessError = Utf8StrFmt (
    600617                tr ("Hard disk '%ls' is being used by another task (%d readers)"),
    601618                toString().raw(), mReaders);
     619            return S_OK;
    602620        }
    603621    }
     
    23102328    ComAssertRCRet (vrc, E_FAIL);
    23112329
    2312     /* go to Busy state to prevent any concurrent modifications
     2330    /* Reference the disk to prevent any concurrent modifications
    23132331     * after releasing the lock below (to unblock getters before
    2314      * a lengthy operation) */
    2315     setBusy();
     2332     * a lengthy operation). */
     2333    addReader();
    23162334
    23172335    alock.leave();
     
    24152433    alock.enter();
    24162434   
    2417     /* remove the busy flag */
    2418     clearBusy();
     2435    /* remove the reference */
     2436    releaseReader();
    24192437   
    24202438    if (FAILED (rc) || VBOX_FAILURE (vrc) || !errMsg.isNull())
     
    39093927    ComAssertRCRet (vrc, E_FAIL);
    39103928
    3911     /* go to Busy state to prevent any concurrent modifications
     3929    /* Reference the disk to prevent any concurrent modifications
    39123930     * after releasing the lock below (to unblock getters before
    3913      * a lengthy operation) */
    3914     setBusy();
     3931     * a lengthy operation). */
     3932    addReader();
    39153933
    39163934    alock.leave();
     
    40204038    alock.enter();
    40214039   
    4022     /* remove the busy flag */
    4023     clearBusy();
     4040    /* remove the reference */
     4041    releaseReader();
    40244042   
    40254043    if (FAILED (rc) || VBOX_FAILURE (vrc) || !errMsg.isNull())
  • trunk/src/VBox/Main/include/HardDiskImpl.h

    r953 r1874  
    129129    ComObjPtr <HardDisk> root() const;
    130130
    131     HRESULT getBaseAccessible (Bstr &aAccessError, bool aCheckBusy = false);
     131    HRESULT getBaseAccessible (Bstr &aAccessError, bool aCheckBusy = false,
     132                               bool aCheckReaders = false);
    132133
    133134    // virtual methods that need to be [re]implemented by every subclass
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