VirtualBox

Changeset 31471 in vbox for trunk/src/VBox/Main/xml


Ignore:
Timestamp:
Aug 9, 2010 9:46:33 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
64553
Message:

Main: settings: bumpSettingsVersionIfNeeded(): optimization (move 1.11 check up)

File:
1 edited

Legend:

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

    r31470 r31471  
    41604160    }
    41614161
     4162    // settings version 1.9 is required if there is not exactly one DVD
     4163    // or more than one floppy drive present or the DVD is not at the secondary
     4164    // master; this check is a bit more complicated
     4165    //
     4166    // settings version 1.10 is required if the host cache should be disabled
     4167    //
     4168    // settings version 1.11 is required for bandwidth limits
     4169    if (m->sv < SettingsVersion_v1_11)
     4170    {
     4171        // count attached DVDs and floppies (only if < v1.9)
     4172        size_t cDVDs = 0;
     4173        size_t cFloppies = 0;
     4174
     4175        // need to run thru all the storage controllers and attached devices to figure this out
     4176        for (StorageControllersList::const_iterator it = storageMachine.llStorageControllers.begin();
     4177             it != storageMachine.llStorageControllers.end();
     4178             ++it)
     4179        {
     4180            const StorageController &sctl = *it;
     4181            for (AttachedDevicesList::const_iterator it2 = sctl.llAttachedDevices.begin();
     4182                 it2 != sctl.llAttachedDevices.end();
     4183                 ++it2)
     4184            {
     4185                const AttachedDevice &att = *it2;
     4186
     4187                // Bandwidth limitations are new in VirtualBox 3.3 (1.11)
     4188                if (    (m->sv < SettingsVersion_v1_11)
     4189                     && (att.ulBandwidthLimit != 0)
     4190                   )
     4191                {
     4192                    m->sv = SettingsVersion_v1_11;
     4193                    break; /* abort the loop -- we will not raise the version further */
     4194                }
     4195
     4196                // disabling the host IO cache requires settings version 1.10
     4197                if (    (m->sv < SettingsVersion_v1_10)
     4198                     && (!sctl.fUseHostIOCache)
     4199                   )
     4200                    m->sv = SettingsVersion_v1_10;
     4201
     4202                // we can only write the StorageController/@Instance attribute with v1.9
     4203                if (    (m->sv < SettingsVersion_v1_9)
     4204                     && (sctl.ulInstance != 0)
     4205                   )
     4206                    m->sv = SettingsVersion_v1_9;
     4207
     4208                if (m->sv < SettingsVersion_v1_9)
     4209                {
     4210                    if (att.deviceType == DeviceType_DVD)
     4211                    {
     4212                         if (    (sctl.storageBus != StorageBus_IDE) // DVD at bus other than DVD?
     4213                              || (att.lPort != 1)                    // DVDs not at secondary master?
     4214                              || (att.lDevice != 0)
     4215                            )
     4216                            m->sv = SettingsVersion_v1_9;
     4217
     4218                        ++cDVDs;
     4219                    }
     4220                    else if (att.deviceType == DeviceType_Floppy)
     4221                        ++cFloppies;
     4222                }
     4223            }
     4224        }
     4225
     4226        // VirtualBox before 3.1 had zero or one floppy and exactly one DVD,
     4227        // so any deviation from that will require settings version 1.9
     4228        if (    (m->sv < SettingsVersion_v1_9)
     4229             && (    (cDVDs != 1)
     4230                  || (cFloppies > 1)
     4231                )
     4232           )
     4233            m->sv = SettingsVersion_v1_9;
     4234    }
     4235
    41624236    // VirtualBox 3.2 adds NAT and boot priority to the NIC config in Main
    41634237    if (m->sv < SettingsVersion_v1_10)
     
    42434317        m->sv = SettingsVersion_v1_9;
    42444318
    4245     // settings version 1.9 is required if there is not exactly one DVD
    4246     // or more than one floppy drive present or the DVD is not at the secondary
    4247     // master; this check is a bit more complicated
    4248     //
    4249     // settings version 1.10 is required if the host cache should be disabled
    4250     //
    4251     // settings version 1.11 is required for bandwidth limits
    4252     if (m->sv < SettingsVersion_v1_11)
    4253     {
    4254         // count attached DVDs and floppies (only if < v1.9)
    4255         size_t cDVDs = 0;
    4256         size_t cFloppies = 0;
    4257 
    4258         // need to run thru all the storage controllers and attached devices to figure this out
    4259         for (StorageControllersList::const_iterator it = storageMachine.llStorageControllers.begin();
    4260              it != storageMachine.llStorageControllers.end();
    4261              ++it)
    4262         {
    4263             const StorageController &sctl = *it;
    4264             for (AttachedDevicesList::const_iterator it2 = sctl.llAttachedDevices.begin();
    4265                  it2 != sctl.llAttachedDevices.end();
    4266                  ++it2)
    4267             {
    4268                 const AttachedDevice &att = *it2;
    4269 
    4270                 // Bandwidth limitations are new in VirtualBox 3.3 (1.11)
    4271                 if (    (m->sv < SettingsVersion_v1_11)
    4272                      && (att.ulBandwidthLimit != 0)
    4273                    )
    4274                 {
    4275                     m->sv = SettingsVersion_v1_11;
    4276                     break; /* abort the loop -- we will not raise the version further */
    4277                 }
    4278 
    4279                 // disabling the host IO cache requires settings version 1.10
    4280                 if (    (m->sv < SettingsVersion_v1_10)
    4281                      && (!sctl.fUseHostIOCache)
    4282                    )
    4283                     m->sv = SettingsVersion_v1_10;
    4284 
    4285                 // we can only write the StorageController/@Instance attribute with v1.9
    4286                 if (    (m->sv < SettingsVersion_v1_9)
    4287                      && (sctl.ulInstance != 0)
    4288                    )
    4289                     m->sv = SettingsVersion_v1_9;
    4290 
    4291                 if (m->sv < SettingsVersion_v1_9)
    4292                 {
    4293                     if (att.deviceType == DeviceType_DVD)
    4294                     {
    4295                          if (    (sctl.storageBus != StorageBus_IDE) // DVD at bus other than DVD?
    4296                               || (att.lPort != 1)                    // DVDs not at secondary master?
    4297                               || (att.lDevice != 0)
    4298                             )
    4299                             m->sv = SettingsVersion_v1_9;
    4300 
    4301                         ++cDVDs;
    4302                     }
    4303                     else if (att.deviceType == DeviceType_Floppy)
    4304                         ++cFloppies;
    4305                 }
    4306             }
    4307         }
    4308 
    4309         // VirtualBox before 3.1 had zero or one floppy and exactly one DVD,
    4310         // so any deviation from that will require settings version 1.9
    4311         if (    (m->sv < SettingsVersion_v1_9)
    4312              && (    (cDVDs != 1)
    4313                   || (cFloppies > 1)
    4314                 )
    4315            )
    4316             m->sv = SettingsVersion_v1_9;
    4317     }
    4318 
    43194319    // "accelerate 2d video" requires settings version 1.8
    43204320    if (    (m->sv < SettingsVersion_v1_8)
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