VirtualBox

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


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

Main: settings: bumpSettingsVersionIfNeeded(): optimizations

File:
1 edited

Legend:

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

    r31468 r31469  
    42304230    }
    42314231
    4232     // settings version 1.9 is required if there is not exactly one DVD
    4233     // or more than one floppy drive present or the DVD is not at the secondary
    4234     // master; this check is a bit more complicated
    4235     //
    4236     // settings version 1.10 is required if the host cache should be disabled
    4237     if (m->sv < SettingsVersion_v1_10)
    4238     {
    4239         size_t cDVDs = 0;
    4240         size_t cFloppies = 0;
    4241 
    4242         // need to run thru all the storage controllers to figure this out
    4243         for (StorageControllersList::const_iterator it = storageMachine.llStorageControllers.begin();
    4244              it != storageMachine.llStorageControllers.end();
    4245              ++it)
    4246         {
    4247             const StorageController &sctl = *it;
    4248             for (AttachedDevicesList::const_iterator it2 = sctl.llAttachedDevices.begin();
    4249                  it2 != sctl.llAttachedDevices.end();
    4250                  ++it2)
    4251             {
    4252                 // we can only write the StorageController/@Instance attribute with v1.9
    4253                 if (sctl.ulInstance != 0)
    4254                 {
    4255                     if (m->sv < SettingsVersion_v1_9)
    4256                         m->sv = SettingsVersion_v1_9;
    4257                 }
    4258 
    4259                 const AttachedDevice &att = *it2;
    4260                 if (att.deviceType == DeviceType_DVD)
    4261                 {
    4262                     if (    (sctl.storageBus != StorageBus_IDE) // DVD at bus other than DVD?
    4263                          || (att.lPort != 1)                    // DVDs not at secondary master?
    4264                          || (att.lDevice != 0)
    4265                        )
    4266                     {
    4267                         if (m->sv < SettingsVersion_v1_9)
    4268                             m->sv = SettingsVersion_v1_9;
    4269                     }
    4270 
    4271                     ++cDVDs;
    4272                 }
    4273                 else if (att.deviceType == DeviceType_Floppy)
    4274                     ++cFloppies;
    4275 
    4276                 // Disabling the host IO cache requires settings version 1.10
    4277                 if (!sctl.fUseHostIOCache)
    4278                 {
    4279                     m->sv = SettingsVersion_v1_10;
    4280                     break; /* abort the loop -- we will not raise the version further */
    4281                 }
    4282 
    4283                 /* Bandwidth limitations are new in VirtualBox 3.3 (1.11) */
    4284                 if (att.ulBandwidthLimit != 0)
    4285                 {
    4286                     m->sv = SettingsVersion_v1_11;
    4287                     break; /* abort the loop -- we will not raise the version further */
    4288                 }
    4289             }
    4290         }
    4291 
    4292         // VirtualBox before 3.1 had zero or one floppy and exactly one DVD,
    4293         // so any deviation from that will require settings version 1.9
    4294         if (    (m->sv < SettingsVersion_v1_9)
    4295              && (    (cDVDs != 1)
    4296                   || (cFloppies > 1)
    4297                 )
    4298            )
    4299             m->sv = SettingsVersion_v1_9;
    4300     }
    4301 
    43024232    // all the following require settings version 1.9
    43034233    if (    (m->sv < SettingsVersion_v1_9)
     
    43134243        m->sv = SettingsVersion_v1_9;
    43144244
     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    if (m->sv < SettingsVersion_v1_10)
     4251    {
     4252        size_t cDVDs = 0;
     4253        size_t cFloppies = 0;
     4254
     4255        // need to run thru all the storage controllers to figure this out
     4256        for (StorageControllersList::const_iterator it = storageMachine.llStorageControllers.begin();
     4257             it != storageMachine.llStorageControllers.end();
     4258             ++it)
     4259        {
     4260            const StorageController &sctl = *it;
     4261            for (AttachedDevicesList::const_iterator it2 = sctl.llAttachedDevices.begin();
     4262                 it2 != sctl.llAttachedDevices.end();
     4263                 ++it2)
     4264            {
     4265                // we can only write the StorageController/@Instance attribute with v1.9
     4266                if (sctl.ulInstance != 0)
     4267                {
     4268                    if (m->sv < SettingsVersion_v1_9)
     4269                        m->sv = SettingsVersion_v1_9;
     4270                }
     4271
     4272                const AttachedDevice &att = *it2;
     4273                if (att.deviceType == DeviceType_DVD)
     4274                {
     4275                    if (    (sctl.storageBus != StorageBus_IDE) // DVD at bus other than DVD?
     4276                         || (att.lPort != 1)                    // DVDs not at secondary master?
     4277                         || (att.lDevice != 0)
     4278                       )
     4279                    {
     4280                        if (m->sv < SettingsVersion_v1_9)
     4281                            m->sv = SettingsVersion_v1_9;
     4282                    }
     4283
     4284                    ++cDVDs;
     4285                }
     4286                else if (att.deviceType == DeviceType_Floppy)
     4287                    ++cFloppies;
     4288
     4289                // Disabling the host IO cache requires settings version 1.10
     4290                if (!sctl.fUseHostIOCache)
     4291                {
     4292                    m->sv = SettingsVersion_v1_10;
     4293                    break; /* abort the loop -- we will not raise the version further */
     4294                }
     4295
     4296                /* Bandwidth limitations are new in VirtualBox 3.3 (1.11) */
     4297                if (att.ulBandwidthLimit != 0)
     4298                {
     4299                    m->sv = SettingsVersion_v1_11;
     4300                    break; /* abort the loop -- we will not raise the version further */
     4301                }
     4302            }
     4303        }
     4304
     4305        // VirtualBox before 3.1 had zero or one floppy and exactly one DVD,
     4306        // so any deviation from that will require settings version 1.9
     4307        if (    (m->sv < SettingsVersion_v1_9)
     4308             && (    (cDVDs != 1)
     4309                  || (cFloppies > 1)
     4310                )
     4311           )
     4312            m->sv = SettingsVersion_v1_9;
     4313    }
     4314
    43154315    // "accelerate 2d video" requires settings version 1.8
    43164316    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