VirtualBox

Ignore:
Timestamp:
Sep 25, 2009 2:37:09 PM (15 years ago)
Author:
vboxsync
Message:

Main: be stricter with bumping settings version to 1.9 when incompatible floppy or DVD settings are detected

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/xml/Settings.cpp

    r23304 r23334  
    27612761
    27622762/**
    2763  * Called from Main code to write a machine config file to disk. This builds a DOM tree from
    2764  * the member variables and then writes the XML file; it throws xml::Error instances on errors,
    2765  * in particular if the file cannot be written.
    2766  */
    2767 void MachineConfigFile::write(const com::Utf8Str &strFilename)
    2768 {
    2769     // createStubDocument() sets the settings version to at least 1.7; however,
    2770     // we might need to enfore a later settings version if incompatible settings
    2771     // are present:
     2763 * Called from write() before calling ConfigFileBase::createStubDocument().
     2764 * This adjusts the settings version in m->sv if incompatible settings require
     2765 * a settings bump, whereas otherwise we try to preserve the settings version
     2766 * to avoid breaking compatibility with older versions.
     2767 */
     2768void MachineConfigFile::bumpSettingsVersionIfNeeded()
     2769{
    27722770    if (m->sv < SettingsVersion_v1_8)
    27732771    {
     
    27982796                if (att.deviceType == DeviceType_DVD)
    27992797                {
    2800                     if (    (cDVDs)                             // more than one DVD?
    2801                          || (sctl.storageBus != StorageBus_IDE) // DVD at bus other than DVD?
    2802                          || (att.lPort != 1)                    // DVDs not at primary master?
     2798                    if (    (sctl.storageBus != StorageBus_IDE) // DVD at bus other than DVD?
     2799                         || (att.lPort != 1)                    // DVDs not at secondary master?
    28032800                         || (att.lDevice != 0)
    28042801                       )
     
    28112808                }
    28122809                else if (att.deviceType == DeviceType_Floppy)
    2813                 {
    2814                     if (cFloppies)
    2815                         // more than one floppy: new settings format
    2816                         m->sv = SettingsVersion_v1_9;
    2817 
    28182810                    ++cFloppies;
    2819                 }
    2820             }
    2821         }
     2811            }
     2812        }
     2813
     2814        // VirtualBox before 3.1 had exactly one floppy and exactly one DVD,
     2815        // so any deviation from that will require settings version 1.9
     2816        if (    (m->sv < SettingsVersion_v1_9)
     2817             && (    (cDVDs != 1)
     2818                  || (cFloppies > 1)
     2819                )
     2820           )
     2821            m->sv = SettingsVersion_v1_9;
    28222822    }
    28232823
     
    28282828        m->sv = SettingsVersion_v1_9;
    28292829    }
    2830 
     2830}
     2831
     2832/**
     2833 * Called from Main code to write a machine config file to disk. This builds a DOM tree from
     2834 * the member variables and then writes the XML file; it throws xml::Error instances on errors,
     2835 * in particular if the file cannot be written.
     2836 */
     2837void MachineConfigFile::write(const com::Utf8Str &strFilename)
     2838{
    28312839    try
    28322840    {
     2841        // createStubDocument() sets the settings version to at least 1.7; however,
     2842        // we might need to enfore a later settings version if incompatible settings
     2843        // are present:
     2844        bumpSettingsVersionIfNeeded();
     2845
    28332846        m->strFilename = strFilename;
    28342847        createStubDocument();
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