VirtualBox

Changeset 61138 in vbox


Ignore:
Timestamp:
May 23, 2016 6:32:40 PM (9 years ago)
Author:
vboxsync
Message:

Main/Settings: fix default handling for fCableConnected with old settings version, otherwise we end up with VMs which have the network disconnected in 5.0

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/settings.h

    r61042 r61138  
    541541
    542542    bool areGenericDriverDefaultSettings() const;
    543     bool areDefaultSettings() const;
     543    bool areDefaultSettings(SettingsVersion_T sv) const;
    544544    bool areDisabledDefaultSettings() const;
    545545
     
    878878    bool areDisplayDefaultSettings() const;
    879879    bool areVideoCaptureDefaultSettings() const;
    880     bool areAllNetworkAdaptersDefaultSettings() const;
     880    bool areAllNetworkAdaptersDefaultSettings(SettingsVersion_T sv) const;
    881881
    882882    bool operator==(const Hardware&) const;
  • trunk/src/VBox/Main/xml/Settings.cpp

    r61115 r61138  
    23352335    type(NetworkAdapterType_Am79C973),
    23362336    fEnabled(false),
    2337     fCableConnected(true),
     2337    fCableConnected(false), // default for old VMs, for new ones it's true
    23382338    ulLineSpeed(0),
    23392339    enmPromiscModePolicy(NetworkAdapterPromiscModePolicy_Deny),
     
    23562356 * Check if all settings have default values.
    23572357 */
    2358 bool NetworkAdapter::areDefaultSettings() const
    2359 {
     2358bool NetworkAdapter::areDefaultSettings(SettingsVersion_T sv) const
     2359{
     2360    // 5.0 and earlier had a default of fCableConnected=false, which doesn't
     2361    // make a lot of sense (but it's a fact). Later versions don't save the
     2362    // setting if it's at the default value and thus must get it right.
    23602363    return !fEnabled
    23612364        && strMACAddress.isEmpty()
    2362         && fCableConnected
     2365        && (   (sv >= SettingsVersion_v1_16 && fCableConnected)
     2366            || (sv < SettingsVersion_v1_16 && !fCableConnected))
    23632367        && ulLineSpeed == 0
    23642368        && enmPromiscModePolicy == NetworkAdapterPromiscModePolicy_Deny
     
    27622766{
    27632767    // 5.0 didn't save the paravirt settings if it is ParavirtProvider_Legacy,
    2764     // so this default must be kept. Later versions don't savethis release. Newer versionsRemember, this is the default for VMs created with 5.0, and older
    2765     // VMs will keep ParavirtProvider_Legacy which must be saved.
     2768    // so this default must be kept. Later versions don't save the setting if
     2769    // it's at the default value.
    27662770    return (   (sv >= SettingsVersion_v1_16 && paravirtProvider == ParavirtProvider_Default)
    2767             || (sv == SettingsVersion_v1_15 && paravirtProvider == ParavirtProvider_Legacy))
     2771            || (sv < SettingsVersion_v1_16 && paravirtProvider == ParavirtProvider_Legacy))
    27682772        && strParavirtDebug.isEmpty();
    27692773}
     
    28172821 * Check if all Network Adapter settings have default values.
    28182822 */
    2819 bool Hardware::areAllNetworkAdaptersDefaultSettings() const
     2823bool Hardware::areAllNetworkAdaptersDefaultSettings(SettingsVersion_T sv) const
    28202824{
    28212825    for (NetworkAdaptersList::const_iterator it = llNetworkAdapters.begin();
     
    28232827         ++it)
    28242828    {
    2825         if (!it->areDefaultSettings())
     2829        if (!it->areDefaultSettings(sv))
    28262830            return false;
    28272831    }
     
    32803284        NetworkAdapter nic;
    32813285
     3286        if (m->sv >= SettingsVersion_v1_16)
     3287        {
     3288            /* Starting with VirtualBox 5.1 the default is true, before it was
     3289             * false. This needs to matched by NetworkAdapter.areDefaultSettings(). */
     3290            nic.fCableConnected = true;
     3291        }
     3292
    32823293        if (!pelmAdapter->getAttributeValue("slot", nic.ulSlot))
    32833294            throw ConfigFileError(this, pelmAdapter, N_("Required Adapter/@slot attribute is missing"));
     
    56845695
    56855696    if (   hw.llNetworkAdapters.size()
    5686         && !hw.areAllNetworkAdaptersDefaultSettings())
     5697        && !hw.areAllNetworkAdaptersDefaultSettings(m->sv))
    56875698    {
    56885699        xml::ElementNode *pelmNetwork = pelmHardware->createChild("Network");
     
    56935704            const NetworkAdapter &nic = *it;
    56945705
    5695             if (!nic.areDefaultSettings())
     5706            if (!nic.areDefaultSettings(m->sv))
    56965707            {
    56975708                xml::ElementNode *pelmAdapter = pelmNetwork->createChild("Adapter");
     
    57015712                if (!nic.strMACAddress.isEmpty())
    57025713                    pelmAdapter->setAttribute("MACAddress", nic.strMACAddress);
    5703                 if (!nic.fCableConnected)
     5714                if (   (m->sv >= SettingsVersion_v1_16 && !nic.fCableConnected)
     5715                    || (m->sv < SettingsVersion_v1_16 && nic.fCableConnected))
    57045716                    pelmAdapter->setAttribute("cable", nic.fCableConnected);
    57055717                if (nic.ulLineSpeed)
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