Changeset 92133 in vbox for trunk/src/VBox/Main/xml
- Timestamp:
- Oct 28, 2021 10:43:36 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/xml/Settings.cpp
r91416 r92133 1472 1472 return m->fFileExists; 1473 1473 } 1474 1475 /** 1476 * Returns the settings file version 1477 * 1478 * @returns Settings file version enum. 1479 */ 1480 SettingsVersion_T ConfigFileBase::getSettingsVersion() 1481 { 1482 return m->sv; 1483 } 1484 1474 1485 1475 1486 /** … … 3030 3041 fAliasLog(false), 3031 3042 fAliasProxyOnly(false), 3032 fAliasUseSamePorts(false) 3043 fAliasUseSamePorts(false), 3044 fLocalhostReachable(true) /* Historically this value is true. */ 3033 3045 { 3034 3046 } … … 3061 3073 3062 3074 /** 3075 * Check whether the localhost-reachable setting is the default for the given settings version. 3076 */ 3077 bool NAT::areLocalhostReachableDefaultSettings(SettingsVersion_T sv) const 3078 { 3079 return ( fLocalhostReachable 3080 && sv < SettingsVersion_v1_19) 3081 || ( !fLocalhostReachable 3082 && sv >= SettingsVersion_v1_19); 3083 } 3084 3085 /** 3063 3086 * Check if all settings have default values. 3064 3087 */ 3065 bool NAT::areDefaultSettings() const 3066 { 3088 bool NAT::areDefaultSettings(SettingsVersion_T sv) const 3089 { 3090 /* 3091 * Before settings version 1.19 localhost was reachable by default 3092 * when using NAT which was changed with version 1.19+, see @bugref{9896} 3093 * for more information. 3094 */ 3067 3095 return strNetwork.isEmpty() 3068 3096 && strBindIP.isEmpty() … … 3075 3103 && areAliasDefaultSettings() 3076 3104 && areTFTPDefaultSettings() 3077 && mapRules.size() == 0; 3105 && mapRules.size() == 0 3106 && areLocalhostReachableDefaultSettings(sv); 3078 3107 } 3079 3108 … … 3102 3131 && fAliasProxyOnly == n.fAliasProxyOnly 3103 3132 && fAliasUseSamePorts == n.fAliasUseSamePorts 3133 && fLocalhostReachable == n.fLocalhostReachable 3104 3134 && mapRules == n.mapRules); 3105 3135 } … … 3145 3175 && enmPromiscModePolicy == NetworkAdapterPromiscModePolicy_Deny 3146 3176 && mode == NetworkAttachmentType_Null 3147 && nat.areDefaultSettings( )3177 && nat.areDefaultSettings(sv) 3148 3178 && strBridgedName.isEmpty() 3149 3179 && strInternalNetworkName.isEmpty() … … 3162 3192 * Special check if settings of the non-current attachment type have default values. 3163 3193 */ 3164 bool NetworkAdapter::areDisabledDefaultSettings( ) const3165 { 3166 return (mode != NetworkAttachmentType_NAT ? nat.areDefaultSettings( ) : true)3194 bool NetworkAdapter::areDisabledDefaultSettings(SettingsVersion_T sv) const 3195 { 3196 return (mode != NetworkAttachmentType_NAT ? nat.areDefaultSettings(sv) : true) 3167 3197 && (mode != NetworkAttachmentType_Bridged ? strBridgedName.isEmpty() : true) 3168 3198 && (mode != NetworkAttachmentType_Internal ? strInternalNetworkName.isEmpty() : true) … … 4177 4207 elmMode.getAttributeValue("tcprcv", nic.nat.u32TcpRcv); 4178 4208 elmMode.getAttributeValue("tcpsnd", nic.nat.u32TcpSnd); 4209 elmMode.getAttributeValue("localhost-reachable", nic.nat.fLocalhostReachable); 4179 4210 const xml::ElementNode *pelmDNS; 4180 4211 if ((pelmDNS = elmMode.findChildElement("DNS"))) … … 6863 6894 { 6864 6895 /* m->sv >= SettingsVersion_v1_10 */ 6865 if (!nic.areDisabledDefaultSettings( ))6896 if (!nic.areDisabledDefaultSettings(m->sv)) 6866 6897 { 6867 6898 xml::ElementNode *pelmDisabledNode = pelmAdapter->createChild("DisabledModes"); … … 7251 7282 // For the currently active network attachment type we have to 7252 7283 // generate the tag, otherwise the attachment type is lost. 7253 if (fEnabled || !nic.nat.areDefaultSettings( ))7284 if (fEnabled || !nic.nat.areDefaultSettings(m->sv)) 7254 7285 { 7255 7286 xml::ElementNode *pelmNAT = elmParent.createChild("NAT"); 7256 7287 7257 if (!nic.nat.areDefaultSettings( ))7288 if (!nic.nat.areDefaultSettings(m->sv)) 7258 7289 { 7259 7290 if (nic.nat.strNetwork.length()) … … 7271 7302 if (nic.nat.u32TcpSnd) 7272 7303 pelmNAT->setAttribute("tcpsnd", nic.nat.u32TcpSnd); 7304 if (!nic.nat.areLocalhostReachableDefaultSettings(m->sv)) 7305 pelmNAT->setAttribute("localhost-reachable", nic.nat.fLocalhostReachable); 7273 7306 if (!nic.nat.areDNSDefaultSettings()) 7274 7307 { … … 7962 7995 return; 7963 7996 } 7997 7998 NetworkAdaptersList::const_iterator netit; 7999 for (netit = hardwareMachine.llNetworkAdapters.begin(); 8000 netit != hardwareMachine.llNetworkAdapters.end(); 8001 ++netit) 8002 { 8003 if ( netit->fEnabled 8004 && netit->mode == NetworkAttachmentType_NAT 8005 && !netit->nat.fLocalhostReachable) 8006 { 8007 m->sv = SettingsVersion_v1_19; 8008 break; 8009 } 8010 } 7964 8011 } 7965 8012
Note:
See TracChangeset
for help on using the changeset viewer.