Index: /trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp	(revision 66613)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp	(revision 66614)
@@ -57,4 +57,6 @@
 
 /* COM includes: */
+# include "CNATNetwork.h"
+# include "CDHCPServer.h"
 # include "CAudioAdapter.h"
 # include "CNATEngine.h"
@@ -1095,4 +1097,39 @@
           tr("Cannot save language settings."),
           formatErrorInfo(comProperties));
+}
+
+void UIMessageCenter::cannotLoadNetworkSettings(const CVirtualBox &comVBox, QWidget *pParent /* = 0 */)
+{
+    error(pParent, MessageType_Error,
+          tr("Cannot load network settings."),
+          formatErrorInfo(comVBox));
+}
+
+void UIMessageCenter::cannotLoadNetworkSettings(const CHost &comHost, QWidget *pParent /* = 0 */)
+{
+    error(pParent, MessageType_Error,
+          tr("Cannot load network settings."),
+          formatErrorInfo(comHost));
+}
+
+void UIMessageCenter::cannotSaveNetworkNatSettings(const CNATNetwork &comNetwork, QWidget *pParent /* = 0 */)
+{
+    error(pParent, MessageType_Error,
+          tr("Cannot save NAT network settings."),
+          formatErrorInfo(comNetwork));
+}
+
+void UIMessageCenter::cannotSaveNetworkHostSettings(const CHostNetworkInterface &comInterface, QWidget *pParent /* = 0 */)
+{
+    error(pParent, MessageType_Error,
+          tr("Cannot save host-only network settings."),
+          formatErrorInfo(comInterface));
+}
+
+void UIMessageCenter::cannotSaveDHCPServerSettings(const CDHCPServer &comServer, QWidget *pParent /* = 0 */)
+{
+    error(pParent, MessageType_Error,
+          tr("Cannot save DHCP server settings."),
+          formatErrorInfo(comServer));
 }
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h	(revision 66613)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h	(revision 66614)
@@ -233,4 +233,9 @@
     void cannotSaveInputSettings(const CSystemProperties &comProperties, QWidget *pParent = 0);
     void cannotSaveLanguageSettings(const CSystemProperties &comProperties, QWidget *pParent = 0);
+    void cannotLoadNetworkSettings(const CVirtualBox &comVBox, QWidget *pParent = 0);
+    void cannotLoadNetworkSettings(const CHost &comHost, QWidget *pParent = 0);
+    void cannotSaveNetworkNatSettings(const CNATNetwork &comNetwork, QWidget *pParent = 0);
+    void cannotSaveNetworkHostSettings(const CHostNetworkInterface &comInterface, QWidget *pParent = 0);
+    void cannotSaveDHCPServerSettings(const CDHCPServer &comServer, QWidget *pParent = 0);
     void cannotSaveProxySettings(const CSystemProperties &comProperties, QWidget *pParent = 0);
     void cannotSaveUpdateSettings(const CSystemProperties &comProperties, QWidget *pParent = 0);
Index: /trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetwork.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetwork.cpp	(revision 66613)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetwork.cpp	(revision 66614)
@@ -49,27 +49,10 @@
 {
     /** Constructs data. */
-    UIDataSettingsGlobalNetwork()
-        : m_networksNAT(QList<UIDataSettingsGlobalNetworkNAT>())
-        , m_networksHost(QList<UIDataSettingsGlobalNetworkHost>())
-    {}
+    UIDataSettingsGlobalNetwork() {}
 
     /** Returns whether the @a other passed data is equal to this one. */
-    bool equal(const UIDataSettingsGlobalNetwork &other) const
-    {
-        return true
-               && (m_networksNAT == other.m_networksNAT)
-               && (m_networksHost == other.m_networksHost)
-               ;
-    }
-
-    /** Returns whether the @a other passed data is equal to this one. */
-    bool operator==(const UIDataSettingsGlobalNetwork &other) const { return equal(other); }
+    bool operator==(const UIDataSettingsGlobalNetwork & /* other */) const { return true; }
     /** Returns whether the @a other passed data is different from this one. */
-    bool operator!=(const UIDataSettingsGlobalNetwork &other) const { return !equal(other); }
-
-    /** Holds the NAT network data. */
-    QList<UIDataSettingsGlobalNetworkNAT> m_networksNAT;
-    /** Holds the host network data. */
-    QList<UIDataSettingsGlobalNetworkHost> m_networksHost;
+    bool operator!=(const UIDataSettingsGlobalNetwork & /* other */) const { return false; }
 };
 
@@ -416,16 +399,8 @@
     /* Gather old network data: */
     foreach (const CNATNetwork &network, vboxGlobal().virtualBox().GetNATNetworks())
-    {
-        UIDataSettingsGlobalNetworkNAT data;
-        loadDataNetworkNAT(network, data);
-        oldNetworkData.m_networksNAT << data;
-    }
+        loadToCacheFromNetworkNAT(network, m_pCache->child1(network.GetNetworkName()));
     foreach (const CHostNetworkInterface &iface, vboxGlobal().host().GetNetworkInterfaces())
         if (iface.GetInterfaceType() == KHostNetworkInterfaceType_HostOnly)
-        {
-            UIDataSettingsGlobalNetworkHost data;
-            loadDataNetworkHost(iface, data);
-            oldNetworkData.m_networksHost << data;
-        }
+            loadToCacheFromNetworkHost(iface, m_pCache->child2(iface.GetName()));
 
     /* Cache old network data: */
@@ -438,15 +413,12 @@
 void UIGlobalSettingsNetwork::getFromCache()
 {
-    /* Get old network data from the cache: */
-    const UIDataSettingsGlobalNetwork &oldNetworkData = m_pCache->base();
-
     /* Load old network data from the cache: */
-    foreach (const UIDataSettingsGlobalNetworkNAT &network, oldNetworkData.m_networksNAT)
-        createTreeWidgetItemForNetworkNAT(network);
+    for (int i = 0; i < m_pCache->childCount1(); ++i)
+        createTreeWidgetItemForNetworkNAT(m_pCache->child1(i).base());
     m_pTreeNetworkNAT->sortByColumn(1, Qt::AscendingOrder);
     m_pTreeNetworkNAT->setCurrentItem(m_pTreeNetworkNAT->topLevelItem(0));
     sltHandleCurrentItemChangeNetworkNAT();
-    foreach (const UIDataSettingsGlobalNetworkHost &network, oldNetworkData.m_networksHost)
-        createTreeWidgetItemForNetworkHost(network);
+    for (int i = 0; i < m_pCache->childCount2(); ++i)
+        createTreeWidgetItemForNetworkHost(m_pCache->child2(i).base());
     m_pTreeNetworkHost->sortByColumn(0, Qt::AscendingOrder);
     m_pTreeNetworkHost->setCurrentItem(m_pTreeNetworkHost->topLevelItem(0));
@@ -460,18 +432,16 @@
 {
     /* Prepare new network data: */
-    UIDataSettingsGlobalNetwork newNetworkData = m_pCache->base();
+    UIDataSettingsGlobalNetwork newNetworkData;
 
     /* Gather new network data: */
-    newNetworkData.m_networksNAT.clear();
-    for (int iNetworkIndex = 0; iNetworkIndex < m_pTreeNetworkNAT->topLevelItemCount(); ++iNetworkIndex)
-    {
-        const UIItemNetworkNAT *pItem = static_cast<UIItemNetworkNAT*>(m_pTreeNetworkNAT->topLevelItem(iNetworkIndex));
-        newNetworkData.m_networksNAT << *pItem;
-    }
-    newNetworkData.m_networksHost.clear();
-    for (int iNetworkIndex = 0; iNetworkIndex < m_pTreeNetworkHost->topLevelItemCount(); ++iNetworkIndex)
-    {
-        const UIItemNetworkHost *pItem = static_cast<UIItemNetworkHost*>(m_pTreeNetworkHost->topLevelItem(iNetworkIndex));
-        newNetworkData.m_networksHost << *pItem;
+    for (int i = 0; i < m_pTreeNetworkNAT->topLevelItemCount(); ++i)
+    {
+        const UIItemNetworkNAT *pItem = static_cast<UIItemNetworkNAT*>(m_pTreeNetworkNAT->topLevelItem(i));
+        m_pCache->child1(pItem->m_strName).cacheCurrentData(*pItem);
+    }
+    for (int i = 0; i < m_pTreeNetworkHost->topLevelItemCount(); ++i)
+    {
+        const UIItemNetworkHost *pItem = static_cast<UIItemNetworkHost*>(m_pTreeNetworkHost->topLevelItem(i));
+        m_pCache->child2(pItem->m_interface.m_strName).cacheCurrentData(*pItem);
     }
 
@@ -485,15 +455,6 @@
     UISettingsPageGlobal::fetchData(data);
 
-    /* Make sure network data was changed: */
-    if (m_pCache->wasChanged())
-    {
-        /* Save new network data from the cache: */
-        if (m_pCache->data().m_networksNAT != m_pCache->base().m_networksNAT)
-            foreach (const UIDataSettingsGlobalNetworkNAT &data, m_pCache->data().m_networksNAT)
-                saveDataNetworkNAT(data);
-        if (m_pCache->data().m_networksHost != m_pCache->base().m_networksHost)
-            foreach (const UIDataSettingsGlobalNetworkHost &data, m_pCache->data().m_networksHost)
-                saveDataNetworkHost(data);
-    }
+    /* Update network data and failing state: */
+    setFailed(!saveNetworkData());
 
     /* Upload properties to data: */
@@ -513,7 +474,7 @@
 
         /* Validate items first: */
-        for (int iNetworkIndex = 0; iNetworkIndex < m_pTreeNetworkNAT->topLevelItemCount(); ++iNetworkIndex)
-        {
-            UIItemNetworkNAT *pItem = static_cast<UIItemNetworkNAT*>(m_pTreeNetworkNAT->topLevelItem(iNetworkIndex));
+        for (int i = 0; i < m_pTreeNetworkNAT->topLevelItemCount(); ++i)
+        {
+            UIItemNetworkNAT *pItem = static_cast<UIItemNetworkNAT*>(m_pTreeNetworkNAT->topLevelItem(i));
             if (!pItem->validate(message))
                 fPass = false;
@@ -550,7 +511,7 @@
 
         /* Validate items only: */
-        for (int iNetworkIndex = 0; iNetworkIndex < m_pTreeNetworkHost->topLevelItemCount(); ++iNetworkIndex)
-        {
-            UIItemNetworkHost *pItem = static_cast<UIItemNetworkHost*>(m_pTreeNetworkHost->topLevelItem(iNetworkIndex));
+        for (int i = 0; i < m_pTreeNetworkHost->topLevelItemCount(); ++i)
+        {
+            UIItemNetworkHost *pItem = static_cast<UIItemNetworkHost*>(m_pTreeNetworkHost->topLevelItem(i));
             if (!pItem->validate(message))
                 fPass = false;
@@ -647,7 +608,7 @@
 
     /* Update tree: */
-    UIDataSettingsGlobalNetworkNAT data;
-    loadDataNetworkNAT(network, data);
-    createTreeWidgetItemForNetworkNAT(data, true);
+    const QString strCacheKey = network.GetNetworkName();
+    loadToCacheFromNetworkNAT(network, m_pCache->child1(strCacheKey));
+    createTreeWidgetItemForNetworkNAT(m_pCache->child1(strCacheKey).base(), true);
     m_pTreeNetworkNAT->sortByColumn(1, Qt::AscendingOrder);
 }
@@ -764,7 +725,7 @@
 
     /* Update tree: */
-    UIDataSettingsGlobalNetworkHost data;
-    loadDataNetworkHost(iface, data);
-    createTreeWidgetItemForNetworkHost(data, true);
+    const QString strCacheKey = iface.GetName();
+    loadToCacheFromNetworkHost(iface, m_pCache->child2(strCacheKey));
+    createTreeWidgetItemForNetworkHost(m_pCache->child2(strCacheKey).base(), true);
     m_pTreeNetworkHost->sortByColumn(0, Qt::AscendingOrder);
 }
@@ -1027,14 +988,42 @@
 }
 
-void UIGlobalSettingsNetwork::loadDataNetworkNAT(const CNATNetwork &network, UIDataSettingsGlobalNetworkNAT &data)
-{
+bool UIGlobalSettingsNetwork::saveNetworkData()
+{
+    /* Prepare result: */
+    bool fSuccess = true;
+    /* Save network settings from the cache: */
+    if (fSuccess && m_pCache->wasChanged())
+    {
+        /* Save new network data from the cache: */
+        for (int i = 0; fSuccess && i < m_pCache->childCount1(); ++i)
+        {
+            const UISettingsCacheGlobalNetworkNAT &cache = m_pCache->child1(i);
+            if (cache.wasUpdated())
+                fSuccess = saveDataNetworkNAT(cache);
+        }
+        for (int i = 0; fSuccess && i < m_pCache->childCount2(); ++i)
+        {
+            const UISettingsCacheGlobalNetworkHost &cache = m_pCache->child2(i);
+            if (cache.wasUpdated())
+                fSuccess = saveDataNetworkHost(m_pCache->child2(i));
+        }
+    }
+    /* Return result: */
+    return fSuccess;
+}
+
+void UIGlobalSettingsNetwork::loadToCacheFromNetworkNAT(const CNATNetwork &network, UISettingsCacheGlobalNetworkNAT &cache)
+{
+    /* Prepare old NAT data: */
+    UIDataSettingsGlobalNetworkNAT oldNATData;
+
     /* Load NAT network settings: */
-    data.m_fEnabled = network.GetEnabled();
-    data.m_strName = network.GetNetworkName();
-    data.m_strNewName = data.m_strName;
-    data.m_strCIDR = network.GetNetwork();
-    data.m_fSupportsDHCP = network.GetNeedDhcpServer();
-    data.m_fSupportsIPv6 = network.GetIPv6Enabled();
-    data.m_fAdvertiseDefaultIPv6Route = network.GetAdvertiseDefaultIPv6RouteEnabled();
+    oldNATData.m_fEnabled = network.GetEnabled();
+    oldNATData.m_strName = network.GetNetworkName();
+    oldNATData.m_strNewName = oldNATData.m_strName;
+    oldNATData.m_strCIDR = network.GetNetwork();
+    oldNATData.m_fSupportsDHCP = network.GetNeedDhcpServer();
+    oldNATData.m_fSupportsIPv6 = network.GetIPv6Enabled();
+    oldNATData.m_fAdvertiseDefaultIPv6Route = network.GetAdvertiseDefaultIPv6RouteEnabled();
 
     /* Load IPv4 rules: */
@@ -1048,10 +1037,10 @@
         if (rules.size() != 6)
             continue;
-        data.m_ipv4rules << UIDataPortForwardingRule(rules[0],
-                                                     gpConverter->fromInternalString<KNATProtocol>(rules[1]),
-                                                     QString(rules[2]).remove('[').remove(']'),
-                                                     rules[3].toUInt(),
-                                                     QString(rules[4]).remove('[').remove(']'),
-                                                     rules[5].toUInt());
+        oldNATData.m_ipv4rules << UIDataPortForwardingRule(rules[0],
+                                                           gpConverter->fromInternalString<KNATProtocol>(rules[1]),
+                                                           QString(rules[2]).remove('[').remove(']'),
+                                                           rules[3].toUInt(),
+                                                           QString(rules[4]).remove('[').remove(']'),
+                                                           rules[5].toUInt());
     }
 
@@ -1076,45 +1065,140 @@
         if (rules.size() != 6)
             continue;
-        data.m_ipv6rules << UIDataPortForwardingRule(rules[0],
-                                                     gpConverter->fromInternalString<KNATProtocol>(rules[1]),
-                                                     QString(rules[2]).remove('[').remove(']'),
-                                                     rules[3].toUInt(),
-                                                     QString(rules[4]).remove('[').remove(']'),
-                                                     rules[5].toUInt());
-    }
-}
-
-void UIGlobalSettingsNetwork::saveDataNetworkNAT(const UIDataSettingsGlobalNetworkNAT &data)
-{
-    /* Make sure corresponding NAT network exists: */
-    CVirtualBox vbox = vboxGlobal().virtualBox();
-    CNATNetwork network = vbox.FindNATNetworkByName(data.m_strName);
-    AssertReturnVoid(vbox.isOk() && !network.isNull());
-
-    /* Save NAT network options: */
-    network.SetEnabled(data.m_fEnabled);
-    network.SetNetworkName(data.m_strNewName);
-    network.SetNetwork(data.m_strCIDR);
-    network.SetNeedDhcpServer(data.m_fSupportsDHCP);
-    network.SetIPv6Enabled(data.m_fSupportsIPv6);
-    network.SetAdvertiseDefaultIPv6RouteEnabled(data.m_fAdvertiseDefaultIPv6Route);
-
-    /* Rewrite IPv4 rules: */
-    foreach (const QString &strRule, network.GetPortForwardRules4())
-        network.RemovePortForwardRule(false, strRule.section(':', 0, 0));
-    foreach (const UIDataPortForwardingRule &newRule, data.m_ipv4rules)
-        network.AddPortForwardRule(false,
-                                   newRule.name, newRule.protocol,
-                                   newRule.hostIp, newRule.hostPort.value(),
-                                   newRule.guestIp, newRule.guestPort.value());
-
-    /* Rewrite IPv6 rules: */
-    foreach (const QString &strRule, network.GetPortForwardRules6())
-        network.RemovePortForwardRule(true, strRule.section(':', 0, 0));
-    foreach (const UIDataPortForwardingRule &newRule, data.m_ipv6rules)
-        network.AddPortForwardRule(true,
-                                   newRule.name, newRule.protocol,
-                                   newRule.hostIp, newRule.hostPort.value(),
-                                   newRule.guestIp, newRule.guestPort.value());
+        oldNATData.m_ipv6rules << UIDataPortForwardingRule(rules[0],
+                                                           gpConverter->fromInternalString<KNATProtocol>(rules[1]),
+                                                           QString(rules[2]).remove('[').remove(']'),
+                                                           rules[3].toUInt(),
+                                                           QString(rules[4]).remove('[').remove(']'),
+                                                           rules[5].toUInt());
+    }
+
+    /* Cache old NAT data: */
+    cache.cacheInitialData(oldNATData);
+}
+
+bool UIGlobalSettingsNetwork::saveDataNetworkNAT(const UISettingsCacheGlobalNetworkNAT &cache)
+{
+    /* Prepare result: */
+    bool fSuccess = true;
+    /* Save NAT settings from the cache: */
+    if (fSuccess)
+    {
+        /* Get old NAT data from the cache: */
+        const UIDataSettingsGlobalNetworkNAT &oldNatData = cache.base();
+        /* Get new NAT data from the cache: */
+        const UIDataSettingsGlobalNetworkNAT &newNatData = cache.data();
+
+        /* Get VBox for further activities: */
+        CVirtualBox comVBox = vboxGlobal().virtualBox();
+        /* Search for a NAT network with the same name: */
+        CNATNetwork comNetwork = comVBox.FindNATNetworkByName(newNatData.m_strName);
+        fSuccess = comVBox.isOk() && comNetwork.isNotNull();
+
+        /* Show error message if necessary: */
+        if (!fSuccess)
+            msgCenter().cannotLoadNetworkSettings(comVBox, this);
+        else
+        {
+            /* Save whether NAT network is enabled: */
+            if (fSuccess && newNatData.m_fEnabled != oldNatData.m_fEnabled)
+            {
+                comNetwork.SetEnabled(newNatData.m_fEnabled);
+                fSuccess = comNetwork.isOk();
+            }
+            /* Save NAT network name: */
+            if (fSuccess && newNatData.m_strNewName != oldNatData.m_strNewName)
+            {
+                comNetwork.SetNetworkName(newNatData.m_strNewName);
+                fSuccess = comNetwork.isOk();
+            }
+            /* Save NAT network CIDR: */
+            if (fSuccess && newNatData.m_strCIDR != oldNatData.m_strCIDR)
+            {
+                comNetwork.SetNetwork(newNatData.m_strCIDR);
+                fSuccess = comNetwork.isOk();
+            }
+            /* Save whether NAT network needs DHCP server: */
+            if (fSuccess && newNatData.m_fSupportsDHCP != oldNatData.m_fSupportsDHCP)
+            {
+                comNetwork.SetNeedDhcpServer(newNatData.m_fSupportsDHCP);
+                fSuccess = comNetwork.isOk();
+            }
+            /* Save whether NAT network supports IPv6: */
+            if (fSuccess && newNatData.m_fSupportsIPv6 != oldNatData.m_fSupportsIPv6)
+            {
+                comNetwork.SetIPv6Enabled(newNatData.m_fSupportsIPv6);
+                fSuccess = comNetwork.isOk();
+            }
+            /* Save whether NAT network should advertise default IPv6 route: */
+            if (fSuccess && newNatData.m_fAdvertiseDefaultIPv6Route != oldNatData.m_fAdvertiseDefaultIPv6Route)
+            {
+                comNetwork.SetAdvertiseDefaultIPv6RouteEnabled(newNatData.m_fAdvertiseDefaultIPv6Route);
+                fSuccess = comNetwork.isOk();
+            }
+
+            /* Get IPv4 port forwarding rules for further activities: */
+            QVector<QString> ipv4rules;
+            if (fSuccess)
+            {
+                ipv4rules = comNetwork.GetPortForwardRules4();
+                fSuccess = comNetwork.isOk();
+            }
+            /* Get IPv6 port forwarding rules for further activities: */
+            QVector<QString> ipv6rules;
+            if (fSuccess)
+            {
+                ipv6rules = comNetwork.GetPortForwardRules6();
+                fSuccess = comNetwork.isOk();
+            }
+
+            /* Save IPv4 forwarding rules: */
+            if (fSuccess && newNatData.m_ipv4rules != oldNatData.m_ipv4rules)
+            {
+                for (int i = 0; fSuccess && i < ipv4rules.size(); ++i)
+                {
+                    const QString &strOldRule = ipv4rules.at(i);
+                    comNetwork.RemovePortForwardRule(false,
+                                                     strOldRule.section(':', 0, 0));
+                    fSuccess = comNetwork.isOk();
+                }
+                for (int i = 0; fSuccess && i < newNatData.m_ipv4rules.size(); ++i)
+                {
+                    const UIDataPortForwardingRule &newRule = newNatData.m_ipv4rules.at(i);
+                    comNetwork.AddPortForwardRule(false,
+                                                  newRule.name, newRule.protocol,
+                                                  newRule.hostIp, newRule.hostPort.value(),
+                                                  newRule.guestIp, newRule.guestPort.value());
+                    fSuccess = comNetwork.isOk();
+                }
+            }
+
+            /* Save IPv6 forwarding rules: */
+            if (fSuccess && newNatData.m_ipv6rules != oldNatData.m_ipv6rules)
+            {
+                for (int i = 0; fSuccess && i < ipv6rules.size(); ++i)
+                {
+                    const QString &strOldRule = ipv6rules.at(i);
+                    comNetwork.RemovePortForwardRule(true,
+                                                     strOldRule.section(':', 0, 0));
+                    fSuccess = comNetwork.isOk();
+                }
+                for (int i = 0; fSuccess && i < newNatData.m_ipv6rules.size(); ++i)
+                {
+                    const UIDataPortForwardingRule &newRule = newNatData.m_ipv6rules.at(i);
+                    comNetwork.AddPortForwardRule(true,
+                                                  newRule.name, newRule.protocol,
+                                                  newRule.hostIp, newRule.hostPort.value(),
+                                                  newRule.guestIp, newRule.guestPort.value());
+                    fSuccess = comNetwork.isOk();
+                }
+            }
+
+            /* Show error message if necessary: */
+            if (!fSuccess)
+                msgCenter().cannotSaveNetworkNatSettings(comNetwork, this);
+        }
+    }
+    /* Return result: */
+    return fSuccess;
 }
 
@@ -1137,6 +1221,9 @@
 }
 
-void UIGlobalSettingsNetwork::loadDataNetworkHost(const CHostNetworkInterface &iface, UIDataSettingsGlobalNetworkHost &data)
-{
+void UIGlobalSettingsNetwork::loadToCacheFromNetworkHost(const CHostNetworkInterface &iface, UISettingsCacheGlobalNetworkHost &cache)
+{
+    /* Prepare old NAT data: */
+    UIDataSettingsGlobalNetworkHost oldHostData;
+
     /* Get DHCP server (create if necessary): */
     CDHCPServer dhcp = vboxGlobal().virtualBox().FindDHCPServerByNetworkName(iface.GetNetworkName());
@@ -1157,90 +1244,134 @@
 
     /* Host interface settings: */
-    data.m_interface.m_strName = iface.GetName();
-    data.m_interface.m_fDhcpClientEnabled = iface.GetDHCPEnabled();
-    data.m_interface.m_strInterfaceAddress = iface.GetIPAddress();
-    data.m_interface.m_strInterfaceMask = iface.GetNetworkMask();
-    data.m_interface.m_fIpv6Supported = iface.GetIPV6Supported();
-    data.m_interface.m_strInterfaceAddress6 = iface.GetIPV6Address();
-    data.m_interface.m_strInterfaceMaskLength6 = QString::number(iface.GetIPV6NetworkMaskPrefixLength());
+    oldHostData.m_interface.m_strName = iface.GetName();
+    oldHostData.m_interface.m_fDhcpClientEnabled = iface.GetDHCPEnabled();
+    oldHostData.m_interface.m_strInterfaceAddress = iface.GetIPAddress();
+    oldHostData.m_interface.m_strInterfaceMask = iface.GetNetworkMask();
+    oldHostData.m_interface.m_fIpv6Supported = iface.GetIPV6Supported();
+    oldHostData.m_interface.m_strInterfaceAddress6 = iface.GetIPV6Address();
+    oldHostData.m_interface.m_strInterfaceMaskLength6 = QString::number(iface.GetIPV6NetworkMaskPrefixLength());
 
     /* DHCP server settings: */
-    data.m_dhcpserver.m_fDhcpServerEnabled = dhcp.GetEnabled();
-    data.m_dhcpserver.m_strDhcpServerAddress = dhcp.GetIPAddress();
-    data.m_dhcpserver.m_strDhcpServerMask = dhcp.GetNetworkMask();
-    data.m_dhcpserver.m_strDhcpLowerAddress = dhcp.GetLowerIP();
-    data.m_dhcpserver.m_strDhcpUpperAddress = dhcp.GetUpperIP();
-}
-
-void UIGlobalSettingsNetwork::saveDataNetworkHost(const UIDataSettingsGlobalNetworkHost &data)
-{
-    /* Make sure corresponding Host interface exists: */
-    CHost host = vboxGlobal().host();
-    CHostNetworkInterface iface = host.FindHostNetworkInterfaceByName(data.m_interface.m_strName);
-    AssertReturnVoid(host.isOk() && !iface.isNull());
-
-    /* Automatic host interface configuration: */
-    if (data.m_interface.m_fDhcpClientEnabled)
-    {
-        iface.EnableDynamicIPConfig();
-    }
-    /* Manual host interface configuration: */
-    else
-    {
-        AssertMsg(data.m_interface.m_strInterfaceAddress.trimmed().isEmpty() ||
-                  RTNetIsIPv4AddrStr(data.m_interface.m_strInterfaceAddress.toUtf8().constData()),
-                  ("Interface IPv4 address must be empty or IPv4-valid!\n"));
-        AssertMsg(data.m_interface.m_strInterfaceMask.trimmed().isEmpty() ||
-                  RTNetIsIPv4AddrStr(data.m_interface.m_strInterfaceMask.toUtf8().constData()),
-                  ("Interface IPv4 network mask must be empty or IPv4-valid!\n"));
-        if (   (   data.m_interface.m_strInterfaceAddress.trimmed().isEmpty()
-                || RTNetIsIPv4AddrStr(data.m_interface.m_strInterfaceAddress.toUtf8().constData()))
-            && (   data.m_interface.m_strInterfaceMask.trimmed().isEmpty()
-                || RTNetIsIPv4AddrStr(data.m_interface.m_strInterfaceMask.toUtf8().constData())))
-            iface.EnableStaticIPConfig(data.m_interface.m_strInterfaceAddress, data.m_interface.m_strInterfaceMask);
-        if (iface.GetIPV6Supported())
-        {
-            AssertMsg(data.m_interface.m_strInterfaceAddress6.trimmed().isEmpty() ||
-                      RTNetIsIPv6AddrStr(data.m_interface.m_strInterfaceAddress6.toUtf8().constData()),
-                      ("Interface IPv6 address must be empty or IPv6-valid!\n"));
-            bool fIsMaskPrefixLengthNumber = false;
-            const int iMaskPrefixLength = data.m_interface.m_strInterfaceMaskLength6.trimmed().toInt(&fIsMaskPrefixLengthNumber);
-            AssertMsg(fIsMaskPrefixLengthNumber && iMaskPrefixLength >= 0 && iMaskPrefixLength <= 128,
-                      ("Interface IPv6 network mask prefix length must be empty or IPv6-valid!\n"));
-            if (   (   data.m_interface.m_strInterfaceAddress6.trimmed().isEmpty()
-                    || RTNetIsIPv6AddrStr(data.m_interface.m_strInterfaceAddress6.toUtf8().constData()))
-                && (   fIsMaskPrefixLengthNumber
-                    && iMaskPrefixLength >= 0
-                    && iMaskPrefixLength <= 128))
-                iface.EnableStaticIPConfigV6(data.m_interface.m_strInterfaceAddress6, data.m_interface.m_strInterfaceMaskLength6.toULong());
-        }
-    }
-
-    /* Make sure corresponding DHCP server exists: */
-    CVirtualBox vbox = vboxGlobal().virtualBox();
-    CDHCPServer dhcp = vbox.FindDHCPServerByNetworkName(iface.GetNetworkName());
-    AssertReturnVoid(vbox.isOk() && !dhcp.isNull());
-
-    /* Save DHCP server configuration: */
-    dhcp.SetEnabled(data.m_dhcpserver.m_fDhcpServerEnabled);
-    if (data.m_dhcpserver.m_fDhcpServerEnabled)
-    {
-        AssertMsg(RTNetIsIPv4AddrStr(data.m_dhcpserver.m_strDhcpServerAddress.toUtf8().constData()),
-                  ("DHCP server IPv4 address must be IPv4-valid!\n"));
-        AssertMsg(RTNetIsIPv4AddrStr(data.m_dhcpserver.m_strDhcpServerMask.toUtf8().constData()),
-                  ("DHCP server IPv4 network mask must be IPv4-valid!\n"));
-        AssertMsg(RTNetIsIPv4AddrStr(data.m_dhcpserver.m_strDhcpLowerAddress.toUtf8().constData()),
-                  ("DHCP server IPv4 lower bound must be IPv4-valid!\n"));
-        AssertMsg(RTNetIsIPv4AddrStr(data.m_dhcpserver.m_strDhcpUpperAddress.toUtf8().constData()),
-                  ("DHCP server IPv4 upper bound must be IPv4-valid!\n"));
-        if (RTNetIsIPv4AddrStr(data.m_dhcpserver.m_strDhcpServerAddress.toUtf8().constData()) &&
-            RTNetIsIPv4AddrStr(data.m_dhcpserver.m_strDhcpServerMask.toUtf8().constData()) &&
-            RTNetIsIPv4AddrStr(data.m_dhcpserver.m_strDhcpLowerAddress.toUtf8().constData()) &&
-            RTNetIsIPv4AddrStr(data.m_dhcpserver.m_strDhcpUpperAddress.toUtf8().constData()))
-            dhcp.SetConfiguration(data.m_dhcpserver.m_strDhcpServerAddress, data.m_dhcpserver.m_strDhcpServerMask,
-                                  data.m_dhcpserver.m_strDhcpLowerAddress, data.m_dhcpserver.m_strDhcpUpperAddress);
-    }
-    if (!dhcp.isOk())
-        emit sigOperationProgressError(UIMessageCenter::formatErrorInfo(dhcp));
+    oldHostData.m_dhcpserver.m_fDhcpServerEnabled = dhcp.GetEnabled();
+    oldHostData.m_dhcpserver.m_strDhcpServerAddress = dhcp.GetIPAddress();
+    oldHostData.m_dhcpserver.m_strDhcpServerMask = dhcp.GetNetworkMask();
+    oldHostData.m_dhcpserver.m_strDhcpLowerAddress = dhcp.GetLowerIP();
+    oldHostData.m_dhcpserver.m_strDhcpUpperAddress = dhcp.GetUpperIP();
+
+    /* Cache old NAT data: */
+    cache.cacheInitialData(oldHostData);
+}
+
+bool UIGlobalSettingsNetwork::saveDataNetworkHost(const UISettingsCacheGlobalNetworkHost &cache)
+{
+    /* Prepare result: */
+    bool fSuccess = true;
+    /* Save host-only settings from the cache: */
+    if (fSuccess)
+    {
+        /* Get old host-only data from the cache: */
+        const UIDataSettingsGlobalNetworkHost &oldHostOnlyData = cache.base();
+        /* Get new host-only data from the cache: */
+        const UIDataSettingsGlobalNetworkHost &newHostOnlyData = cache.data();
+
+        /* Get VBox for further activities: */
+        CHost comHost = vboxGlobal().host();
+        /* Search for a host-only interface with the same name: */
+        CHostNetworkInterface comInterface = comHost.FindHostNetworkInterfaceByName(newHostOnlyData.m_interface.m_strName);
+        fSuccess = comHost.isOk() && comInterface.isNotNull();
+
+        /* Show error message if necessary: */
+        if (!fSuccess)
+            msgCenter().cannotLoadNetworkSettings(comHost, this);
+        else
+        {
+            /* Automatic host interface configuration: */
+            if (   fSuccess
+                && newHostOnlyData.m_interface.m_fDhcpClientEnabled
+                && newHostOnlyData.m_interface.m_fDhcpClientEnabled != oldHostOnlyData.m_interface.m_fDhcpClientEnabled)
+            {
+                comInterface.EnableDynamicIPConfig();
+                fSuccess = comInterface.isOk();
+            }
+
+            else
+
+            /* Manual host interface configuration: */
+            if (   fSuccess
+                && !newHostOnlyData.m_interface.m_fDhcpClientEnabled)
+            {
+                if (   fSuccess
+                    && (   newHostOnlyData.m_interface.m_fDhcpClientEnabled != oldHostOnlyData.m_interface.m_fDhcpClientEnabled
+                        || newHostOnlyData.m_interface.m_strInterfaceAddress != oldHostOnlyData.m_interface.m_strInterfaceAddress
+                        || newHostOnlyData.m_interface.m_strInterfaceMask != oldHostOnlyData.m_interface.m_strInterfaceMask))
+                {
+                    comInterface.EnableStaticIPConfig(newHostOnlyData.m_interface.m_strInterfaceAddress, newHostOnlyData.m_interface.m_strInterfaceMask);
+                    fSuccess = comInterface.isOk();
+                }
+
+                if (   fSuccess
+                    && newHostOnlyData.m_interface.m_fIpv6Supported
+                    && (   newHostOnlyData.m_interface.m_fDhcpClientEnabled != oldHostOnlyData.m_interface.m_fDhcpClientEnabled
+                        || newHostOnlyData.m_interface.m_strInterfaceAddress6 != oldHostOnlyData.m_interface.m_strInterfaceAddress6
+                        || newHostOnlyData.m_interface.m_strInterfaceMaskLength6 != oldHostOnlyData.m_interface.m_strInterfaceMaskLength6))
+                {
+                    comInterface.EnableStaticIPConfigV6(newHostOnlyData.m_interface.m_strInterfaceAddress6, newHostOnlyData.m_interface.m_strInterfaceMaskLength6.toULong());
+                    fSuccess = comInterface.isOk();
+                }
+            }
+
+            /* Get network name for further activities: */
+            QString strNetworkName;
+            if (fSuccess)
+            {
+                strNetworkName = comInterface.GetNetworkName();
+                fSuccess = comInterface.isOk();
+            }
+
+            /* Show error message if necessary: */
+            if (!fSuccess)
+                msgCenter().cannotSaveNetworkHostSettings(comInterface, this);
+            else
+            {
+                /* Get VBox for further activities: */
+                CVirtualBox comVBox = vboxGlobal().virtualBox();
+                /* Search for a DHCP server with the same name: */
+                CDHCPServer comServer = comVBox.FindDHCPServerByNetworkName(strNetworkName);
+                fSuccess = comVBox.isOk() && comServer.isNotNull();
+
+                /* Show error message if necessary: */
+                if (!fSuccess)
+                    msgCenter().cannotLoadNetworkSettings(comVBox, this);
+                else
+                {
+                    /* Save whether DHCP server is enabled: */
+                    if (fSuccess && newHostOnlyData.m_dhcpserver.m_fDhcpServerEnabled != oldHostOnlyData.m_dhcpserver.m_fDhcpServerEnabled)
+                    {
+                        comServer.SetEnabled(newHostOnlyData.m_dhcpserver.m_fDhcpServerEnabled);
+                        fSuccess = comServer.isOk();
+                    }
+                    if (   fSuccess
+                        && newHostOnlyData.m_dhcpserver.m_fDhcpServerEnabled
+                        && (   newHostOnlyData.m_dhcpserver.m_strDhcpServerAddress != oldHostOnlyData.m_dhcpserver.m_strDhcpServerAddress
+                            || newHostOnlyData.m_dhcpserver.m_strDhcpServerMask != oldHostOnlyData.m_dhcpserver.m_strDhcpServerMask
+                            || newHostOnlyData.m_dhcpserver.m_strDhcpLowerAddress != oldHostOnlyData.m_dhcpserver.m_strDhcpLowerAddress
+                            || newHostOnlyData.m_dhcpserver.m_strDhcpUpperAddress != oldHostOnlyData.m_dhcpserver.m_strDhcpUpperAddress))
+                    {
+                        comServer.SetConfiguration(newHostOnlyData.m_dhcpserver.m_strDhcpServerAddress, newHostOnlyData.m_dhcpserver.m_strDhcpServerMask,
+                                                   newHostOnlyData.m_dhcpserver.m_strDhcpLowerAddress, newHostOnlyData.m_dhcpserver.m_strDhcpUpperAddress);
+                        fSuccess = comServer.isOk();
+                    }
+
+                    /* Show error message if necessary: */
+                    if (!fSuccess)
+                        msgCenter().cannotSaveDHCPServerSettings(comServer, this);
+                    // if (!comServer.isOk())
+                    //    emit sigOperationProgressError(UIMessageCenter::formatErrorInfo(comServer));
+                }
+            }
+        }
+    }
+    /* Return result: */
+    return fSuccess;
 }
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetwork.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetwork.h	(revision 66613)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetwork.h	(revision 66614)
@@ -29,5 +29,7 @@
 struct UIDataSettingsGlobalNetworkNAT;
 struct UIDataSettingsGlobalNetworkHost;
-typedef UISettingsCache<UIDataSettingsGlobalNetwork> UISettingsCacheGlobalNetwork;
+typedef UISettingsCache<UIDataSettingsGlobalNetworkNAT> UISettingsCacheGlobalNetworkNAT;
+typedef UISettingsCache<UIDataSettingsGlobalNetworkHost> UISettingsCacheGlobalNetworkHost;
+typedef UISettingsCachePoolOfTwo<UIDataSettingsGlobalNetwork, UISettingsCacheGlobalNetworkNAT, UISettingsCacheGlobalNetworkHost> UISettingsCacheGlobalNetwork;
 
 
@@ -109,8 +111,11 @@
     void cleanup();
 
+    /** Saves existing network data from the cache. */
+    bool saveNetworkData();
+
     /** Uploads NAT @a network data into passed @a data storage unit. */
-    void loadDataNetworkNAT(const CNATNetwork &network, UIDataSettingsGlobalNetworkNAT &data);
+    void loadToCacheFromNetworkNAT(const CNATNetwork &network, UISettingsCacheGlobalNetworkNAT &cache);
     /** Saves @a data to corresponding NAT network. */
-    void saveDataNetworkNAT(const UIDataSettingsGlobalNetworkNAT &data);
+    bool saveDataNetworkNAT(const UISettingsCacheGlobalNetworkNAT &cache);
     /** Creates a new item in the NAT network tree on the basis of passed @a data, @a fChooseItem if requested. */
     void createTreeWidgetItemForNetworkNAT(const UIDataSettingsGlobalNetworkNAT &data, bool fChooseItem = false);
@@ -119,7 +124,7 @@
 
     /** Uploads host @a network data into passed @a data storage unit. */
-    void loadDataNetworkHost(const CHostNetworkInterface &iface, UIDataSettingsGlobalNetworkHost &data);
+    void loadToCacheFromNetworkHost(const CHostNetworkInterface &iface, UISettingsCacheGlobalNetworkHost &cache);
     /** Saves @a data to corresponding host network. */
-    void saveDataNetworkHost(const UIDataSettingsGlobalNetworkHost &data);
+    bool saveDataNetworkHost(const UISettingsCacheGlobalNetworkHost &cache);
     /** Creates a new item in the host network tree on the basis of passed @a data, @a fChooseItem if requested. */
     void createTreeWidgetItemForNetworkHost(const UIDataSettingsGlobalNetworkHost &data, bool fChooseItem = false);
