Changeset 61036 in vbox for trunk/src/VBox/Main
- Timestamp:
- May 18, 2016 1:27:34 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 107296
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/xml/Settings.cpp
r61011 r61036 2753 2753 * Check if all Paravirt settings have default values. 2754 2754 */ 2755 bool Hardware::areParavirtDefaultSettings() const 2756 { 2757 // Remember, this is the default for VMs created with 5.0, and older 2755 bool Hardware::areParavirtDefaultSettings(SettingsVersion_T sv) const 2756 { 2757 // 5.0 didn't save the paravirt settings if it is ParavirtProvider_Legacy, 2758 // 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 2758 2759 // VMs will keep ParavirtProvider_Legacy which must be saved. 2759 return paravirtProvider == ParavirtProvider_Default 2760 return ( sv >= SettingsVersion_v1_16 && paravirtProvider == ParavirtProvider_Default 2761 || sv == SettingsVersion_v1_15 && paravirtProvider == ParavirtProvider_Legacy) 2760 2762 && strParavirtDebug.isEmpty(); 2761 2763 } … … 3567 3569 } 3568 3570 3569 // Special default handling: tag presence hints it should be enabled 3570 aa.fEnabled = true; 3571 if (m->sv <= SettingsVersion_v1_14) 3572 { 3573 // Special default handling: tag presence hints it should be enabled 3574 aa.fEnabled = true; 3575 } 3571 3576 elmAudioAdapter.getAttributeValue("enabled", aa.fEnabled); 3572 3577 … … 3698 3703 Hardware &hw) 3699 3704 { 3700 if (m->sv >= SettingsVersion_v1_15) 3705 if (m->sv >= SettingsVersion_v1_16) 3706 { 3707 /* Starting with VirtualBox 5.1 the default is Default, before it was 3708 * Legacy. This needs to matched by areParavirtDefaultSettings(). */ 3701 3709 hw.paravirtProvider = ParavirtProvider_Default; 3710 } 3711 3702 3712 if (!elmHardware.getAttributeValue("version", hw.strVersion)) 3703 3713 { … … 5243 5253 5244 5254 if ( (m->sv >= SettingsVersion_v1_15) 5245 && !hw.areParavirtDefaultSettings( )5255 && !hw.areParavirtDefaultSettings(m->sv) 5246 5256 ) 5247 5257 { … … 5706 5716 xml::ElementNode *pelmDisabledNode = pelmAdapter->createChild("DisabledModes"); 5707 5717 if (nic.mode != NetworkAttachmentType_NAT) 5708 buildNetworkXML(NetworkAttachmentType_NAT, *pelmDisabledNode, nic);5718 buildNetworkXML(NetworkAttachmentType_NAT, false, *pelmDisabledNode, nic); 5709 5719 if (nic.mode != NetworkAttachmentType_Bridged) 5710 buildNetworkXML(NetworkAttachmentType_Bridged, *pelmDisabledNode, nic);5720 buildNetworkXML(NetworkAttachmentType_Bridged, false, *pelmDisabledNode, nic); 5711 5721 if (nic.mode != NetworkAttachmentType_Internal) 5712 buildNetworkXML(NetworkAttachmentType_Internal, *pelmDisabledNode, nic);5722 buildNetworkXML(NetworkAttachmentType_Internal, false, *pelmDisabledNode, nic); 5713 5723 if (nic.mode != NetworkAttachmentType_HostOnly) 5714 buildNetworkXML(NetworkAttachmentType_HostOnly, *pelmDisabledNode, nic);5724 buildNetworkXML(NetworkAttachmentType_HostOnly, false, *pelmDisabledNode, nic); 5715 5725 if (nic.mode != NetworkAttachmentType_Generic) 5716 buildNetworkXML(NetworkAttachmentType_Generic, *pelmDisabledNode, nic);5726 buildNetworkXML(NetworkAttachmentType_Generic, false, *pelmDisabledNode, nic); 5717 5727 if (nic.mode != NetworkAttachmentType_NATNetwork) 5718 buildNetworkXML(NetworkAttachmentType_NATNetwork, *pelmDisabledNode, nic);5728 buildNetworkXML(NetworkAttachmentType_NATNetwork, false, *pelmDisabledNode, nic); 5719 5729 } 5720 buildNetworkXML(nic.mode, *pelmAdapter, nic);5730 buildNetworkXML(nic.mode, true, *pelmAdapter, nic); 5721 5731 } 5722 5732 } … … 6031 6041 * Fill a \<Network\> node. Only relevant for XML version >= v1_10. 6032 6042 * @param mode 6043 * @param fEnabled 6033 6044 * @param elmParent 6034 * @param fEnabled6035 6045 * @param nic 6036 6046 */ 6037 6047 void MachineConfigFile::buildNetworkXML(NetworkAttachmentType_T mode, 6048 bool fEnabled, 6038 6049 xml::ElementNode &elmParent, 6039 6050 const NetworkAdapter &nic) … … 6042 6053 { 6043 6054 case NetworkAttachmentType_NAT: 6044 if (!nic.nat.areDefaultSettings()) 6055 // For the currently active network attachment type we have to 6056 // generate the tag, otherwise the attachment type is lost. 6057 if (fEnabled || !nic.nat.areDefaultSettings()) 6045 6058 { 6046 6059 xml::ElementNode *pelmNAT = elmParent.createChild("NAT"); 6047 6060 6048 if (nic.nat.strNetwork.length()) 6049 pelmNAT->setAttribute("network", nic.nat.strNetwork); 6050 if (nic.nat.strBindIP.length()) 6051 pelmNAT->setAttribute("hostip", nic.nat.strBindIP); 6052 if (nic.nat.u32Mtu) 6053 pelmNAT->setAttribute("mtu", nic.nat.u32Mtu); 6054 if (nic.nat.u32SockRcv) 6055 pelmNAT->setAttribute("sockrcv", nic.nat.u32SockRcv); 6056 if (nic.nat.u32SockSnd) 6057 pelmNAT->setAttribute("socksnd", nic.nat.u32SockSnd); 6058 if (nic.nat.u32TcpRcv) 6059 pelmNAT->setAttribute("tcprcv", nic.nat.u32TcpRcv); 6060 if (nic.nat.u32TcpSnd) 6061 pelmNAT->setAttribute("tcpsnd", nic.nat.u32TcpSnd); 6062 if (!nic.nat.areDNSDefaultSettings()) 6061 if (!nic.nat.areDefaultSettings()) 6063 6062 { 6064 xml::ElementNode *pelmDNS = pelmNAT->createChild("DNS"); 6065 if (!nic.nat.fDNSPassDomain) 6066 pelmDNS->setAttribute("pass-domain", nic.nat.fDNSPassDomain); 6067 if (nic.nat.fDNSProxy) 6068 pelmDNS->setAttribute("use-proxy", nic.nat.fDNSProxy); 6069 if (nic.nat.fDNSUseHostResolver) 6070 pelmDNS->setAttribute("use-host-resolver", nic.nat.fDNSUseHostResolver); 6063 if (nic.nat.strNetwork.length()) 6064 pelmNAT->setAttribute("network", nic.nat.strNetwork); 6065 if (nic.nat.strBindIP.length()) 6066 pelmNAT->setAttribute("hostip", nic.nat.strBindIP); 6067 if (nic.nat.u32Mtu) 6068 pelmNAT->setAttribute("mtu", nic.nat.u32Mtu); 6069 if (nic.nat.u32SockRcv) 6070 pelmNAT->setAttribute("sockrcv", nic.nat.u32SockRcv); 6071 if (nic.nat.u32SockSnd) 6072 pelmNAT->setAttribute("socksnd", nic.nat.u32SockSnd); 6073 if (nic.nat.u32TcpRcv) 6074 pelmNAT->setAttribute("tcprcv", nic.nat.u32TcpRcv); 6075 if (nic.nat.u32TcpSnd) 6076 pelmNAT->setAttribute("tcpsnd", nic.nat.u32TcpSnd); 6077 if (!nic.nat.areDNSDefaultSettings()) 6078 { 6079 xml::ElementNode *pelmDNS = pelmNAT->createChild("DNS"); 6080 if (!nic.nat.fDNSPassDomain) 6081 pelmDNS->setAttribute("pass-domain", nic.nat.fDNSPassDomain); 6082 if (nic.nat.fDNSProxy) 6083 pelmDNS->setAttribute("use-proxy", nic.nat.fDNSProxy); 6084 if (nic.nat.fDNSUseHostResolver) 6085 pelmDNS->setAttribute("use-host-resolver", nic.nat.fDNSUseHostResolver); 6086 } 6087 6088 if (!nic.nat.areAliasDefaultSettings()) 6089 { 6090 xml::ElementNode *pelmAlias = pelmNAT->createChild("Alias"); 6091 if (nic.nat.fAliasLog) 6092 pelmAlias->setAttribute("logging", nic.nat.fAliasLog); 6093 if (nic.nat.fAliasProxyOnly) 6094 pelmAlias->setAttribute("proxy-only", nic.nat.fAliasProxyOnly); 6095 if (nic.nat.fAliasUseSamePorts) 6096 pelmAlias->setAttribute("use-same-ports", nic.nat.fAliasUseSamePorts); 6097 } 6098 6099 if (!nic.nat.areTFTPDefaultSettings()) 6100 { 6101 xml::ElementNode *pelmTFTP; 6102 pelmTFTP = pelmNAT->createChild("TFTP"); 6103 if (nic.nat.strTFTPPrefix.length()) 6104 pelmTFTP->setAttribute("prefix", nic.nat.strTFTPPrefix); 6105 if (nic.nat.strTFTPBootFile.length()) 6106 pelmTFTP->setAttribute("boot-file", nic.nat.strTFTPBootFile); 6107 if (nic.nat.strTFTPNextServer.length()) 6108 pelmTFTP->setAttribute("next-server", nic.nat.strTFTPNextServer); 6109 } 6110 buildNATForwardRulesMap(*pelmNAT, nic.nat.mapRules); 6071 6111 } 6072 6073 if (!nic.nat.areAliasDefaultSettings()) 6112 } 6113 break; 6114 6115 case NetworkAttachmentType_Bridged: 6116 // For the currently active network attachment type we have to 6117 // generate the tag, otherwise the attachment type is lost. 6118 if (fEnabled || !nic.strBridgedName.isEmpty()) 6119 { 6120 xml::ElementNode *pelmMode = elmParent.createChild("BridgedInterface"); 6121 if (!nic.strBridgedName.isEmpty()) 6122 pelmMode->setAttribute("name", nic.strBridgedName); 6123 } 6124 break; 6125 6126 case NetworkAttachmentType_Internal: 6127 // For the currently active network attachment type we have to 6128 // generate the tag, otherwise the attachment type is lost. 6129 if (fEnabled || !nic.strInternalNetworkName.isEmpty()) 6130 { 6131 xml::ElementNode *pelmMode = elmParent.createChild("InternalNetwork"); 6132 if (!nic.strInternalNetworkName.isEmpty()) 6133 pelmMode->setAttribute("name", nic.strInternalNetworkName); 6134 } 6135 break; 6136 6137 case NetworkAttachmentType_HostOnly: 6138 // For the currently active network attachment type we have to 6139 // generate the tag, otherwise the attachment type is lost. 6140 if (fEnabled || !nic.strHostOnlyName.isEmpty()) 6141 { 6142 xml::ElementNode *pelmMode = elmParent.createChild("HostOnlyInterface"); 6143 if (!nic.strHostOnlyName.isEmpty()) 6144 pelmMode->setAttribute("name", nic.strHostOnlyName); 6145 } 6146 break; 6147 6148 case NetworkAttachmentType_Generic: 6149 // For the currently active network attachment type we have to 6150 // generate the tag, otherwise the attachment type is lost. 6151 if (fEnabled || !nic.areGenericDriverDefaultSettings()) 6152 { 6153 xml::ElementNode *pelmMode = elmParent.createChild("GenericInterface"); 6154 if (!nic.areGenericDriverDefaultSettings()) 6074 6155 { 6075 xml::ElementNode *pelmAlias = pelmNAT->createChild("Alias"); 6076 if (nic.nat.fAliasLog) 6077 pelmAlias->setAttribute("logging", nic.nat.fAliasLog); 6078 if (nic.nat.fAliasProxyOnly) 6079 pelmAlias->setAttribute("proxy-only", nic.nat.fAliasProxyOnly); 6080 if (nic.nat.fAliasUseSamePorts) 6081 pelmAlias->setAttribute("use-same-ports", nic.nat.fAliasUseSamePorts); 6156 pelmMode->setAttribute("driver", nic.strGenericDriver); 6157 for (StringsMap::const_iterator it = nic.genericProperties.begin(); 6158 it != nic.genericProperties.end(); 6159 ++it) 6160 { 6161 xml::ElementNode *pelmProp = pelmMode->createChild("Property"); 6162 pelmProp->setAttribute("name", it->first); 6163 pelmProp->setAttribute("value", it->second); 6164 } 6082 6165 } 6083 6084 if (!nic.nat.areTFTPDefaultSettings())6085 {6086 xml::ElementNode *pelmTFTP;6087 pelmTFTP = pelmNAT->createChild("TFTP");6088 if (nic.nat.strTFTPPrefix.length())6089 pelmTFTP->setAttribute("prefix", nic.nat.strTFTPPrefix);6090 if (nic.nat.strTFTPBootFile.length())6091 pelmTFTP->setAttribute("boot-file", nic.nat.strTFTPBootFile);6092 if (nic.nat.strTFTPNextServer.length())6093 pelmTFTP->setAttribute("next-server", nic.nat.strTFTPNextServer);6094 }6095 buildNATForwardRulesMap(*pelmNAT, nic.nat.mapRules);6096 6166 } 6097 6167 break; 6098 6168 6099 case NetworkAttachmentType_Bridged:6100 if (!nic.strBridgedName.isEmpty())6101 elmParent.createChild("BridgedInterface")->setAttribute("name", nic.strBridgedName);6102 break;6103 6104 case NetworkAttachmentType_Internal:6105 if (!nic.strInternalNetworkName.isEmpty())6106 elmParent.createChild("InternalNetwork")->setAttribute("name", nic.strInternalNetworkName);6107 break;6108 6109 case NetworkAttachmentType_HostOnly:6110 if (!nic.strHostOnlyName.isEmpty())6111 elmParent.createChild("HostOnlyInterface")->setAttribute("name", nic.strHostOnlyName);6112 break;6113 6114 case NetworkAttachmentType_Generic:6115 if (!nic.areGenericDriverDefaultSettings())6116 {6117 xml::ElementNode *pelmMode = elmParent.createChild("GenericInterface");6118 pelmMode->setAttribute("driver", nic.strGenericDriver);6119 for (StringsMap::const_iterator it = nic.genericProperties.begin();6120 it != nic.genericProperties.end();6121 ++it)6122 {6123 xml::ElementNode *pelmProp = pelmMode->createChild("Property");6124 pelmProp->setAttribute("name", it->first);6125 pelmProp->setAttribute("value", it->second);6126 }6127 }6128 break;6129 6130 6169 case NetworkAttachmentType_NATNetwork: 6131 if (!nic.strNATNetworkName.isEmpty()) 6132 elmParent.createChild("NATNetwork")->setAttribute("name", nic.strNATNetworkName); 6170 // For the currently active network attachment type we have to 6171 // generate the tag, otherwise the attachment type is lost. 6172 if (fEnabled || !nic.strNATNetworkName.isEmpty()) 6173 { 6174 xml::ElementNode *pelmMode = elmParent.createChild("NATNetwork"); 6175 if (!nic.strNATNetworkName.isEmpty()) 6176 pelmMode->setAttribute("name", nic.strNATNetworkName); 6177 } 6133 6178 break; 6134 6179
Note:
See TracChangeset
for help on using the changeset viewer.