Changeset 92133 in vbox for trunk/src/VBox
- Timestamp:
- Oct 28, 2021 10:43:36 AM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 147952
- Location:
- trunk/src/VBox
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp
r91416 r92133 153 153 MODIFYVM_NATDNSPROXY, 154 154 MODIFYVM_NATDNSHOSTRESOLVER, 155 MODIFYVM_NATLOCALHOSTREACHABLE, 155 156 MODIFYVM_MACADDRESS, 156 157 MODIFYVM_HIDPTR, … … 359 360 { "--natdnsproxy", MODIFYVM_NATDNSPROXY, RTGETOPT_REQ_BOOL_ONOFF | RTGETOPT_FLAG_INDEX }, 360 361 { "--natdnshostresolver", MODIFYVM_NATDNSHOSTRESOLVER, RTGETOPT_REQ_BOOL_ONOFF | RTGETOPT_FLAG_INDEX }, 362 { "--natlocalhostreachable", MODIFYVM_NATLOCALHOSTREACHABLE, RTGETOPT_REQ_BOOL_ONOFF | RTGETOPT_FLAG_INDEX }, 361 363 { "--macaddress", MODIFYVM_MACADDRESS, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX }, 362 364 { "--mouse", MODIFYVM_HIDPTR, RTGETOPT_REQ_STRING }, … … 2128 2130 break; 2129 2131 } 2132 2133 case MODIFYVM_NATLOCALHOSTREACHABLE: 2134 { 2135 if (!parseNum(GetOptState.uIndex, NetworkAdapterCount, "NIC")) 2136 break; 2137 2138 ComPtr<INetworkAdapter> nic; 2139 CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam())); 2140 ASSERT(nic); 2141 2142 ComPtr<INATEngine> engine; 2143 CHECK_ERROR(nic, COMGETTER(NATEngine)(engine.asOutParam())); 2144 2145 CHECK_ERROR(engine, COMSETTER(LocalhostReachable)(ValueUnion.f)); 2146 break; 2147 } 2148 2130 2149 case MODIFYVM_MACADDRESS: 2131 2150 { -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r92056 r92133 24307 24307 <interface 24308 24308 name="INATEngine" extends="$unknown" 24309 uuid=" 8faef61e-6e15-4f71-a6a5-94e707fafbcc"24309 uuid="a06253a7-dcd2-44e3-8689-9c9c4b6b6234" 24310 24310 wsmap="managed" 24311 24311 reservedMethods="4" reservedAttributes="8" … … 24354 24354 <desc>Array of NAT port-forwarding rules in string representation, in the following 24355 24355 format: "name,protocol id,host ip,host port,guest ip,guest port".</desc> 24356 </attribute> 24357 <attribute name="LocalhostReachable" type="boolean"> 24358 <desc>Whether traffic from the guest directed to 10.0.2.2 will reach the 24359 host's loopback interface, i.e. localhost or 127.0.0.1.</desc> 24356 24360 </attribute> 24357 24361 <method name="setNetworkSettings"> -
trunk/src/VBox/Main/include/MachineImpl.h
r91743 r92133 548 548 Utf8Str i_getDefaultNVRAMFilename(); 549 549 Utf8Str i_getSnapshotNVRAMFilename(); 550 SettingsVersion_T i_getSettingsVersion(void); 550 551 551 552 void i_composeSavedStateFilename(Utf8Str &strStateFilePath); -
trunk/src/VBox/Main/include/NATEngineImpl.h
r90828 r92133 63 63 HRESULT setHostIP(const com::Utf8Str &aHostIP); 64 64 HRESULT getHostIP(com::Utf8Str &aBindIP); 65 HRESULT setLocalhostReachable(BOOL fLocalhostReachable); 66 HRESULT getLocalhostReachable(BOOL *pfLocalhostReachable); 65 67 /* TFTP properties */ 66 68 HRESULT setTFTPPrefix(const com::Utf8Str &aTFTPPrefix); -
trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
r91503 r92133 5514 5514 hrc = natEngine->COMGETTER(AliasMode)(&aliasMode); H(); 5515 5515 InsertConfigInteger(pCfg, "AliasMode", aliasMode); 5516 5517 BOOL fLocalhostReachable; 5518 hrc = natEngine->COMGETTER(LocalhostReachable)(&fLocalhostReachable); H(); 5519 InsertConfigInteger(pCfg, "LocalhostReachable", fLocalhostReachable); 5516 5520 5517 5521 /* port-forwarding */ -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r92040 r92133 7311 7311 7312 7312 return strNVRAMFilePath; 7313 } 7314 7315 /** 7316 * Returns the version of the settings file. 7317 */ 7318 SettingsVersion_T Machine::i_getSettingsVersion(void) 7319 { 7320 AutoCaller autoCaller(this); 7321 AssertComRCReturn(autoCaller.rc(), SettingsVersion_Null); 7322 7323 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 7324 7325 return mData->pMachineConfigFile->getSettingsVersion(); 7313 7326 } 7314 7327 -
trunk/src/VBox/Main/src-server/NATEngineImpl.cpp
r85309 r92133 188 188 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 189 189 190 /* so far nothing to do*/190 mData->m->fLocalhostReachable = false; /* Applies to new VMs only, see @bugref{9896} */ 191 191 } 192 192 … … 199 199 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 200 200 201 return mData->m->areDefaultSettings( );201 return mData->m->areDefaultSettings(mParent->i_getSettingsVersion()); 202 202 } 203 203 … … 434 434 } 435 435 436 HRESULT NATEngine::setLocalhostReachable(BOOL fLocalhostReachable) 437 { 438 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 439 440 if (mData->m->fLocalhostReachable != RT_BOOL(fLocalhostReachable)) 441 { 442 mData->m.backup(); 443 mData->m->fLocalhostReachable = RT_BOOL(fLocalhostReachable); 444 mParent->i_setModified(Machine::IsModified_NetworkAdapters); 445 } 446 return S_OK; 447 } 448 449 HRESULT NATEngine::getLocalhostReachable(BOOL *pfLocalhostReachable) 450 { 451 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 452 *pfLocalhostReachable = mData->m->fLocalhostReachable; 453 return S_OK; 454 } 455 436 456 HRESULT NATEngine::setTFTPPrefix(const com::Utf8Str &aTFTPPrefix) 437 457 { -
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.