VirtualBox

Changeset 35082 in vbox


Ignore:
Timestamp:
Dec 14, 2010 1:55:49 PM (14 years ago)
Author:
vboxsync
Message:

Main: prevent attaching MultiAttach/Readonly media to pre-4.0 machines for backwards settings compatibility

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

Legend:

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

    r35040 r35082  
    33963396                        medium->getLocationFull().c_str());
    33973397
     3398    if (!medium.isNull())
     3399    {
     3400        MediumType_T mtype = medium->getType();
     3401        if (    mtype == MediumType_MultiAttach
     3402             || mtype == MediumType_Readonly
     3403           )
     3404        {
     3405            // These two types are new with VirtualBox 4.0 and therefore require settings
     3406            // version 1.11 in the settings backend. Unfortunately it is not enough to do
     3407            // the usual routine in MachineConfigFile::bumpSettingsVersionIfNeeded() for
     3408            // two reasons: The medium type is a property of the media registry tree, which
     3409            // can reside in the global config file (for pre-4.0 media); we would therefore
     3410            // possibly need to bump the global config version. We don't want to do that though
     3411            // because that might make downgrading to pre-4.0 impossible.
     3412            // As a result, we can only use these two new types if the medium is NOT in the
     3413            // global registry:
     3414            const Guid &uuidGlobalRegistry = mParent->getGlobalRegistryId();
     3415            if (    medium->isInRegistry(uuidGlobalRegistry)
     3416                 || !mData->pMachineConfigFile->canHaveOwnMediaRegistry()
     3417               )
     3418                return setError(VBOX_E_INVALID_OBJECT_STATE,
     3419                                tr("Cannot attach medium '%s': the media types 'MultiAttach' and 'Readonly' can only be attached "
     3420                                   "to machines that were created with VirtualBox 4.0 or later"),
     3421                                medium->getLocationFull().c_str());
     3422        }
     3423    }
     3424
    33983425    bool fIndirect = false;
    33993426    if (!medium.isNull())
  • trunk/src/VBox/Main/MediumImpl.cpp

    r35040 r35082  
    17011701        default:
    17021702            AssertFailedReturn(E_FAIL);
     1703    }
     1704
     1705    if (    aType == MediumType_MultiAttach
     1706         || aType == MediumType_Readonly
     1707       )
     1708    {
     1709        // These two types are new with VirtualBox 4.0 and therefore require settings
     1710        // version 1.11 in the settings backend. Unfortunately it is not enough to do
     1711        // the usual routine in MachineConfigFile::bumpSettingsVersionIfNeeded() for
     1712        // two reasons: The medium type is a property of the media registry tree, which
     1713        // can reside in the global config file (for pre-4.0 media); we would therefore
     1714        // possibly need to bump the global config version. We don't want to do that though
     1715        // because that might make downgrading to pre-4.0 impossible.
     1716        // As a result, we can only use these two new types if the medium is NOT in the
     1717        // global registry:
     1718        const Guid &uuidGlobalRegistry = m->pVirtualBox->getGlobalRegistryId();
     1719        if (isInRegistry(uuidGlobalRegistry))
     1720            return setError(VBOX_E_INVALID_OBJECT_STATE,
     1721                            tr("Cannot change type for medium '%s': the media types 'MultiAttach' and 'Readonly' can only be used "
     1722                               "on media registered with a machine that was created with VirtualBox 4.0 or later"),
     1723                            m->strLocationFull.c_str());
    17031724    }
    17041725
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