Index: trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-client/ConsoleImpl.cpp	(revision 39242)
+++ trunk/src/VBox/Main/src-client/ConsoleImpl.cpp	(revision 39248)
@@ -69,6 +69,4 @@
 #include "BusAssignmentManager.h"
 
-// generated header
-#include "SchemaDefs.h"
 #include "VBoxEvents.h"
 #include "AutoCaller.h"
@@ -379,6 +377,4 @@
     , mMachineState(MachineState_PoweredOff)
 {
-    for (ULONG slot = 0; slot < SchemaDefs::NetworkAdapterCount; ++slot)
-        meAttachmentType[slot] = NetworkAttachmentType_Null;
 }
 
@@ -395,5 +391,5 @@
     memset(&mapSharedFolderLed, 0, sizeof(mapSharedFolderLed));
 
-    for (unsigned i = 0; i < RT_ELEMENTS(maStorageDevType); ++ i)
+    for (unsigned i = 0; i < RT_ELEMENTS(maStorageDevType); ++i)
         maStorageDevType[i] = DeviceType_Null;
 
@@ -501,4 +497,21 @@
     mcGuestCredentialsProvided = false;
 
+    /* Figure out size of meAttachmentType vector */
+    ComPtr<IVirtualBox> pVirtualBox;
+    rc = aMachine->COMGETTER(Parent)(pVirtualBox.asOutParam());
+    AssertComRC(rc);
+    ComPtr<ISystemProperties> pSystemProperties;
+    if (pVirtualBox)
+        pVirtualBox->COMGETTER(SystemProperties)(pSystemProperties.asOutParam());
+    ChipsetType_T chipsetType = ChipsetType_PIIX3;
+    aMachine->COMGETTER(ChipsetType)(&chipsetType);
+    ULONG maxNetworkAdapters = 0;
+    if (pSystemProperties)
+        pSystemProperties->GetMaxNetworkAdapters(chipsetType, &maxNetworkAdapters);
+    meAttachmentType.resize(maxNetworkAdapters);
+    for (ULONG slot = 0; slot < SchemaDefs::NetworkAdapterCount; ++slot)
+        meAttachmentType[slot] = NetworkAttachmentType_Null;
+
+
     // VirtualBox 4.0: We no longer initialize the VMMDev instance here,
     // which starts the HGCM thread. Instead, this is now done in the
@@ -518,8 +531,4 @@
     /* VirtualBox events registration. */
     {
-        ComPtr<IVirtualBox> pVirtualBox;
-        rc = aMachine->COMGETTER(Parent)(pVirtualBox.asOutParam());
-        AssertComRC(rc);
-
         ComPtr<IEventSource> pES;
         rc = pVirtualBox->COMGETTER(EventSource)(pES.asOutParam());
@@ -1329,5 +1338,5 @@
     for (SharedFolderMap::const_iterator it = that->m_mapSharedFolders.begin();
          it != that->m_mapSharedFolders.end();
-         ++ it)
+         ++it)
     {
         SharedFolder *pSF = (*it).second;
@@ -1409,5 +1418,5 @@
     AssertRCReturn(vrc, vrc);
 
-    for (uint32_t i = 0; i < size; ++ i)
+    for (uint32_t i = 0; i < size; ++i)
     {
         Utf8Str strName;
@@ -2846,5 +2855,5 @@
             break;
         }
-        ++ it;
+        ++it;
     }
 
@@ -4469,14 +4478,24 @@
     AssertReturn(pThis, VERR_INVALID_PARAMETER);
 
+    AutoCaller autoCaller(pThis);
+    AssertComRCReturn(autoCaller.rc(), VERR_ACCESS_DENIED);
+
+    ComPtr<IVirtualBox> pVirtualBox;
+    pThis->mMachine->COMGETTER(Parent)(pVirtualBox.asOutParam());
+    ComPtr<ISystemProperties> pSystemProperties;
+    if (pVirtualBox)
+        pVirtualBox->COMGETTER(SystemProperties)(pSystemProperties.asOutParam());
+    ChipsetType_T chipsetType = ChipsetType_PIIX3;
+    pThis->mMachine->COMGETTER(ChipsetType)(&chipsetType);
+    ULONG maxNetworkAdapters = 0;
+    if (pSystemProperties)
+        pSystemProperties->GetMaxNetworkAdapters(chipsetType, &maxNetworkAdapters);
     AssertMsg(   (   !strcmp(pszDevice, "pcnet")
                   || !strcmp(pszDevice, "e1000")
                   || !strcmp(pszDevice, "virtio-net"))
               && uLun == 0
-              && uInstance < SchemaDefs::NetworkAdapterCount,
+              && uInstance < maxNetworkAdapters,
               ("pszDevice=%s uLun=%d uInstance=%d\n", pszDevice, uLun, uInstance));
     Log(("pszDevice=%s uLun=%d uInstance=%d\n", pszDevice, uLun, uInstance));
-
-    AutoCaller autoCaller(pThis);
-    AssertComRCReturn(autoCaller.rc(), VERR_ACCESS_DENIED);
 
     /*
@@ -4994,5 +5013,5 @@
             break;
         }
-        ++ it;
+        ++it;
     }
 
@@ -6004,5 +6023,5 @@
             Utf8Str oldName, newName;
 
-            for (unsigned int j = 0; j < RT_ELEMENTS(files); ++ j)
+            for (unsigned int j = 0; j < RT_ELEMENTS(files); ++j)
             {
                 if (i > 0)
@@ -6231,5 +6250,5 @@
         /* the network cards will undergo a quick consistency check */
         for (ULONG slot = 0;
-             slot < SchemaDefs::NetworkAdapterCount;
+             slot < maxNetworkAdapters;
              ++slot)
         {
@@ -6671,5 +6690,5 @@
     /* advance percent count */
     if (aProgress)
-        aProgress->SetCurrentOperationProgress(99 * (++ step) / StepCount );
+        aProgress->SetCurrentOperationProgress(99 * (++step) / StepCount );
 
 
@@ -6701,5 +6720,5 @@
     /* advance percent count */
     if (aProgress)
-        aProgress->SetCurrentOperationProgress(99 * (++ step) / StepCount );
+        aProgress->SetCurrentOperationProgress(99 * (++step) / StepCount );
 
     vrc = VINF_SUCCESS;
@@ -6726,5 +6745,5 @@
     /* advance percent count */
     if (aProgress)
-        aProgress->SetCurrentOperationProgress(99 * (++ step) / StepCount );
+        aProgress->SetCurrentOperationProgress(99 * (++step) / StepCount );
 
 #ifdef VBOX_WITH_HGCM
@@ -6744,5 +6763,5 @@
     /* advance percent count */
     if (aProgress)
-        aProgress->SetCurrentOperationProgress(99 * (++ step) / StepCount );
+        aProgress->SetCurrentOperationProgress(99 * (++step) / StepCount);
 
 #endif /* VBOX_WITH_HGCM */
@@ -6790,5 +6809,5 @@
         /* advance percent count */
         if (aProgress)
-            aProgress->SetCurrentOperationProgress(99 * (++ step) / StepCount );
+            aProgress->SetCurrentOperationProgress(99 * (++step) / StepCount);
 
         if (RT_SUCCESS(vrc))
@@ -6820,5 +6839,5 @@
         /* advance percent count */
         if (aProgress)
-            aProgress->SetCurrentOperationProgress(99 * (++ step) / StepCount );
+            aProgress->SetCurrentOperationProgress(99 * (++step) / StepCount);
     }
     else
@@ -7047,5 +7066,5 @@
             {
                 for (SharedFolderDataMap::const_iterator it = oldFolders.begin();
-                     it != oldFolders.end(); ++ it)
+                     it != oldFolders.end(); ++it)
                 {
                     if (m_mapSharedFolders.find(it->first) != m_mapSharedFolders.end())
@@ -8086,6 +8105,17 @@
      * host interface termination handling
      */
-    HRESULT rc;
-    for (ULONG slot = 0; slot < SchemaDefs::NetworkAdapterCount; slot ++)
+    HRESULT rc = S_OK;
+    ComPtr<IVirtualBox> pVirtualBox;
+    mMachine->COMGETTER(Parent)(pVirtualBox.asOutParam());
+    ComPtr<ISystemProperties> pSystemProperties;
+    if (pVirtualBox)
+        pVirtualBox->COMGETTER(SystemProperties)(pSystemProperties.asOutParam());
+    ChipsetType_T chipsetType = ChipsetType_PIIX3;
+    mMachine->COMGETTER(ChipsetType)(&chipsetType);
+    ULONG maxNetworkAdapters = 0;
+    if (pSystemProperties)
+        pSystemProperties->GetMaxNetworkAdapters(chipsetType, &maxNetworkAdapters);
+
+    for (ULONG slot = 0; slot < maxNetworkAdapters; slot++)
     {
         ComPtr<INetworkAdapter> pNetworkAdapter;
@@ -8393,5 +8423,5 @@
             }
 
-            ++ it;
+            ++it;
         }
 
@@ -8498,5 +8528,5 @@
         for (VMPowerUpTask::ProgressList::const_iterator
              it = task->hardDiskProgresses.begin();
-             it != task->hardDiskProgresses.end(); ++ it)
+             it != task->hardDiskProgresses.end(); ++it)
         {
             HRESULT rc2 = (*it)->WaitForCompletion(-1);
Index: trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
===================================================================
--- trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp	(revision 39242)
+++ trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp	(revision 39248)
@@ -756,4 +756,6 @@
     BOOL fOsXGuest = guestTypeFamilyId == Bstr("MacOS");
 
+    ULONG maxNetworkAdapters;
+    hrc = systemProperties->GetMaxNetworkAdapters(chipsetType, &maxNetworkAdapters);        H();
     /*
      * Get root node first.
@@ -1710,5 +1712,5 @@
 #endif /* VBOX_WITH_VIRTIO */
         std::list<BootNic> llBootNics;
-        for (ULONG ulInstance = 0; ulInstance < SchemaDefs::NetworkAdapterCount; ++ulInstance)
+        for (ULONG ulInstance = 0; ulInstance < maxNetworkAdapters; ++ulInstance)
         {
             ComPtr<INetworkAdapter> networkAdapter;
Index: trunk/src/VBox/Main/src-client/GuestImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-client/GuestImpl.cpp	(revision 39242)
+++ trunk/src/VBox/Main/src-client/GuestImpl.cpp	(revision 39248)
@@ -141,5 +141,5 @@
 /////////////////////////////////////////////////////////////////////////////
 
-STDMETHODIMP Guest::COMGETTER(OSTypeId) (BSTR *aOSTypeId)
+STDMETHODIMP Guest::COMGETTER(OSTypeId)(BSTR *aOSTypeId)
 {
     CheckComArgOutPointerValid(aOSTypeId);
@@ -602,5 +602,5 @@
      * its real status when using new(er) Guest Additions.
      */
-    mData.mOSTypeId = Global::OSTypeId (aOsType);
+    mData.mOSTypeId = Global::OSTypeId(aOsType);
 }
 
