VirtualBox

Changeset 33307 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Oct 21, 2010 1:05:39 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
66878
Message:

Main/Medium: new MediumType_Readonly, replaces the DeviceType_DVD hacks and later will allow truly readonly floppies and so on.

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

Legend:

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

    r33244 r33307  
    29242924
    29252925            if (    pMedium
    2926                 && (    enmType == DeviceType_DVD
     2926                && (   enmType == DeviceType_DVD
    29272927                    || enmType == DeviceType_Floppy
    29282928            ))
     
    29862986                InsertConfigString(pCfg, "Format", bstr);
    29872987
    2988                 /* DVDs are always readonly, floppies may be readonly */
    2989                 if (enmType == DeviceType_DVD)
     2988                if (mediumType == MediumType_Readonly)
    29902989                {
    29912990                    InsertConfigInteger(pCfg, "ReadOnly", 1);
     
    30053004                 *        make DrvVD undo TempReadOnly.  It gets interesting if we fail after
    30063005                 *        that. Grumble. */
    3007                 else if (   aMachineState == MachineState_TeleportingIn
    3008                          || aMachineState == MachineState_FaultTolerantSyncing)
     3006                if (   enmType == DeviceType_HardDisk
     3007                    && (   aMachineState == MachineState_TeleportingIn
     3008                        || aMachineState == MachineState_FaultTolerantSyncing))
    30093009                {
    30103010                    InsertConfigInteger(pCfg, "TempReadOnly", 1);
  • trunk/src/VBox/Main/MachineImpl.cpp

    r33300 r33307  
    1134911349        {
    1135011350            MediumType_T mediumType = pMedium->getType();
    11351             bool fIsReadOnlyImage =    devType == DeviceType_DVD
    11352                                     || mediumType == MediumType_Shareable;
     11351            bool fIsReadOnlyLock =    mediumType == MediumType_Readonly
     11352                                   || mediumType == MediumType_Shareable;
    1135311353            bool fIsVitalImage = (devType == DeviceType_HardDisk);
    1135411354
    1135511355            mrc = pMedium->createMediumLockList(fIsVitalImage /* fFailIfInaccessible */,
    11356                                                 !fIsReadOnlyImage /* fMediumLockWrite */,
     11356                                                !fIsReadOnlyLock /* fMediumLockWrite */,
    1135711357                                                NULL,
    1135811358                                                *pMediumLockList);
  • trunk/src/VBox/Main/MediumImpl.cpp

    r33250 r33307  
    11921192            m->type = data.hdType;
    11931193    }
     1194    else if (aDeviceType == DeviceType_DVD)
     1195        m->type = MediumType_Readonly;
    11941196    else
    11951197        m->type = MediumType_Writethrough;
     
    12801282    unconst(m->id) = uuid;
    12811283
    1282     m->type = MediumType_Writethrough;
     1284    if (aDeviceType == DeviceType_DVD)
     1285        m->type = MediumType_Readonly;
     1286    else
     1287        m->type = MediumType_Writethrough;
    12831288    m->devType = aDeviceType;
    12841289    m->state = MediumState_Created;
     
    16461651        case MediumType_Writethrough:
    16471652        case MediumType_Shareable:
    1648         {
    1649             /* cannot change to writethrough or shareable if there are children */
     1653        case MediumType_Readonly:
     1654        {
     1655            /* cannot change to writethrough, shareable or readonly
     1656             * if there are children */
    16501657            if (getChildren().size() != 0)
    16511658                return setError(VBOX_E_OBJECT_IN_USE,
     
    24272434                        tr("Medium type of '%s' is Shareable"),
    24282435                        m->strLocationFull.c_str());
     2436    else if (m->type == MediumType_Readonly)
     2437        return setError(VBOX_E_INVALID_OBJECT_STATE,
     2438                        tr("Medium type of '%s' is Readonly"),
     2439                        m->strLocationFull.c_str());
    24292440
    24302441    /* Apply the normal locking logic to the entire chain. */
     
    32443255        case MediumType_Writethrough:
    32453256        case MediumType_Shareable:
     3257        case MediumType_Readonly: /* explicit readonly media has no diffs */
    32463258            return false;
    32473259        default:
     
    37723784     * generate an UUID if it is missing) */
    37733785    if (    (m->hddOpenMode == OpenReadOnly)
     3786         || m->type == MediumType_Readonly
    37743787         || !isImport
    37753788       )
     
    45824595
    45834596        ComAssertThrow(   m->type != MediumType_Writethrough
    4584                        && m->type != MediumType_Shareable, E_FAIL);
     4597                       && m->type != MediumType_Shareable
     4598                       && m->type != MediumType_Readonly, E_FAIL);
    45854599        ComAssertThrow(m->state == MediumState_LockedRead, E_FAIL);
    45864600
  • trunk/src/VBox/Main/SnapshotImpl.cpp

    r33300 r33307  
    21482148            // so do nothing for them
    21492149            if (   type != MediumType_Writethrough
    2150                 && type != MediumType_Shareable)
     2150                && type != MediumType_Shareable
     2151                && type != MediumType_Readonly)
    21512152            {
    21522153                // normal or immutable media need attention
     
    23642365
    23652366            {
    2366                 // writethrough and shareable images are unaffected by
    2367                 // snapshots, skip them
     2367                // writethrough, shareable and readonly images are
     2368                // unaffected by snapshots, skip them
    23682369                AutoReadLock medlock(pHD COMMA_LOCKVAL_SRC_POS);
    23692370                MediumType_T type = pHD->getType();
    23702371                if (   type == MediumType_Writethrough
    2371                     || type == MediumType_Shareable)
     2372                    || type == MediumType_Shareable
     2373                    || type == MediumType_Readonly)
    23722374                    continue;
    23732375            }
     
    28432845    AutoWriteLock alock(aHD COMMA_LOCKVAL_SRC_POS);
    28442846
    2845     // Medium must not be writethrough/shareable at this point
     2847    // Medium must not be writethrough/shareable/readonly at this point
    28462848    MediumType_T type = aHD->getType();
    28472849    AssertReturn(   type != MediumType_Writethrough
    2848                  && type != MediumType_Shareable, E_FAIL);
     2850                 && type != MediumType_Shareable
     2851                 && type != MediumType_Readonly, E_FAIL);
    28492852
    28502853    aMediumLockList = NULL;
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r33301 r33307  
    83938393  <enum
    83948394    name="MediumType"
    8395     uuid="46bf1fd4-ad86-4ded-8c49-28bd2d148e5a"
     8395    uuid="19388a99-8e70-4bd4-9a95-90cbc513ef6d"
    83968396   >
    83978397    <desc>
     
    84228422        Allow using this medium concurrently by several machines.
    84238423        <note>Present since VirtualBox 3.2.0, and accepted since 3.2.8.</note>
     8424      </desc>
     8425    </const>
     8426    <const name="Readonly"          value="4">
     8427      <desc>
     8428        A readonly medium, which can of course be used by several machines.
     8429        <note>Present and accepted since VirtualBox 4.0.</note>
    84248430      </desc>
    84258431    </const>
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