VirtualBox

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


Ignore:
Timestamp:
May 18, 2016 1:27:34 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
107296
Message:

Main/xml/Settings.cpp: fix default for audio adapter enabling, fix handling of network attachment (lost the attachment) and improve paravirt settings default handling

File:
1 edited

Legend:

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

    r61011 r61036  
    27532753 * Check if all Paravirt settings have default values.
    27542754 */
    2755 bool Hardware::areParavirtDefaultSettings() const
    2756 {
    2757     // Remember, this is the default for VMs created with 5.0, and older
     2755bool 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
    27582759    // 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)
    27602762        && strParavirtDebug.isEmpty();
    27612763}
     
    35673569    }
    35683570
    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    }
    35713576    elmAudioAdapter.getAttributeValue("enabled", aa.fEnabled);
    35723577
     
    36983703                                     Hardware &hw)
    36993704{
    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(). */
    37013709        hw.paravirtProvider = ParavirtProvider_Default;
     3710    }
     3711
    37023712    if (!elmHardware.getAttributeValue("version", hw.strVersion))
    37033713    {
     
    52435253
    52445254    if (    (m->sv >= SettingsVersion_v1_15)
    5245         && !hw.areParavirtDefaultSettings()
     5255        && !hw.areParavirtDefaultSettings(m->sv)
    52465256       )
    52475257    {
     
    57065716                        xml::ElementNode *pelmDisabledNode = pelmAdapter->createChild("DisabledModes");
    57075717                        if (nic.mode != NetworkAttachmentType_NAT)
    5708                             buildNetworkXML(NetworkAttachmentType_NAT, *pelmDisabledNode, nic);
     5718                            buildNetworkXML(NetworkAttachmentType_NAT, false, *pelmDisabledNode, nic);
    57095719                        if (nic.mode != NetworkAttachmentType_Bridged)
    5710                             buildNetworkXML(NetworkAttachmentType_Bridged, *pelmDisabledNode, nic);
     5720                            buildNetworkXML(NetworkAttachmentType_Bridged, false, *pelmDisabledNode, nic);
    57115721                        if (nic.mode != NetworkAttachmentType_Internal)
    5712                             buildNetworkXML(NetworkAttachmentType_Internal, *pelmDisabledNode, nic);
     5722                            buildNetworkXML(NetworkAttachmentType_Internal, false, *pelmDisabledNode, nic);
    57135723                        if (nic.mode != NetworkAttachmentType_HostOnly)
    5714                             buildNetworkXML(NetworkAttachmentType_HostOnly, *pelmDisabledNode, nic);
     5724                            buildNetworkXML(NetworkAttachmentType_HostOnly, false, *pelmDisabledNode, nic);
    57155725                        if (nic.mode != NetworkAttachmentType_Generic)
    5716                             buildNetworkXML(NetworkAttachmentType_Generic, *pelmDisabledNode, nic);
     5726                            buildNetworkXML(NetworkAttachmentType_Generic, false, *pelmDisabledNode, nic);
    57175727                        if (nic.mode != NetworkAttachmentType_NATNetwork)
    5718                             buildNetworkXML(NetworkAttachmentType_NATNetwork, *pelmDisabledNode, nic);
     5728                            buildNetworkXML(NetworkAttachmentType_NATNetwork, false, *pelmDisabledNode, nic);
    57195729                    }
    5720                     buildNetworkXML(nic.mode, *pelmAdapter, nic);
     5730                    buildNetworkXML(nic.mode, true, *pelmAdapter, nic);
    57215731                }
    57225732            }
     
    60316041 * Fill a \<Network\> node. Only relevant for XML version >= v1_10.
    60326042 * @param mode
     6043 * @param fEnabled
    60336044 * @param elmParent
    6034  * @param fEnabled
    60356045 * @param nic
    60366046 */
    60376047void MachineConfigFile::buildNetworkXML(NetworkAttachmentType_T mode,
     6048                                        bool fEnabled,
    60386049                                        xml::ElementNode &elmParent,
    60396050                                        const NetworkAdapter &nic)
     
    60426053    {
    60436054        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())
    60456058            {
    60466059                xml::ElementNode *pelmNAT = elmParent.createChild("NAT");
    60476060
    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())
    60636062                {
    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);
    60716111                }
    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())
    60746155                {
    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                    }
    60826165                }
    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);
    60966166            }
    60976167            break;
    60986168
    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 
    61306169        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            }
    61336178            break;
    61346179
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