Index: /trunk/include/VBox/vmm/pdmdev.h
===================================================================
--- /trunk/include/VBox/vmm/pdmdev.h	(revision 80700)
+++ /trunk/include/VBox/vmm/pdmdev.h	(revision 80701)
@@ -331,6 +331,6 @@
     /** Size of the raw-mode instance data. */
     uint32_t            cbInstanceRC;
-    /** Reserved, must be zero. */
-    uint32_t            uReserved1;
+    /** Max number of PCI devices. */
+    uint32_t            cMaxPciDevices;
     /** The description of the device. The UTF-8 string pointed to shall, like this structure,
      * remain unchanged from registration till VM destruction. */
@@ -411,5 +411,5 @@
 typedef PDMDEVREGR3 const *PCPDMDEVREGR3;
 /** Current DEVREGR3 version number. */
-#define PDM_DEVREGR3_VERSION                    PDM_VERSION_MAKE(0xffff, 3, 0)
+#define PDM_DEVREGR3_VERSION                    PDM_VERSION_MAKE(0xffff, 4, 0)
 
 
@@ -470,4 +470,7 @@
 /** Indicates that the device needs to be notified before the drivers when resetting. */
 #define PDM_DEVREG_FLAGS_FIRST_RESET_NOTIFICATION       UINT32_C(0x00040000)
+
+/** MSI-X support (affects PCI device allocation size). */
+#define PDM_DEVREG_FLAGS_MSI_X                          UINT32_C(0x00100000)
 
 /** This flag is used to indicate that the device has been converted to the
@@ -552,6 +555,6 @@
     /** Size of the raw-mode instance data. */
     uint32_t            cbInstanceRC;
-    /** Reserved, must be zero. */
-    uint32_t            uReserved1;
+    /** Max number of PCI devices. */
+    uint32_t            cMaxPciDevices;
     /** The description of the device. The UTF-8 string pointed to shall, like this structure,
      * remain unchanged from registration till VM destruction. */
@@ -660,6 +663,6 @@
     /** Size of the raw-mode instance data. */
     uint32_t            cbInstanceRC;
-    /** Reserved, must be zero. */
-    uint32_t            uReserved1;
+    /** Max number of PCI devices. */
+    uint32_t            cMaxPciDevices;
     /** The description of the device. The UTF-8 string pointed to shall, like this structure,
      * remain unchanged from registration till VM destruction. */
@@ -6216,5 +6219,5 @@
 }
 
-/*
+/**
  * Registers the device with the default PCI bus.
  *
Index: /trunk/src/VBox/Devices/Audio/DevHDA.cpp
===================================================================
--- /trunk/src/VBox/Devices/Audio/DevHDA.cpp	(revision 80700)
+++ /trunk/src/VBox/Devices/Audio/DevHDA.cpp	(revision 80701)
@@ -5325,5 +5325,5 @@
     /* .cbInstanceCC = */           0,
     /* .cbInstanceRC = */           0,
-    /* .uReserved1 = */             0,
+    /* .cMaxPciDevices = */         1,
     /* .pszDescription = */         "Intel HD Audio Controller",
 #if defined(IN_RING3)
Index: /trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
===================================================================
--- /trunk/src/VBox/Devices/Audio/DevIchAc97.cpp	(revision 80700)
+++ /trunk/src/VBox/Devices/Audio/DevIchAc97.cpp	(revision 80701)
@@ -4555,5 +4555,5 @@
     /* .cbInstanceCC = */           0,
     /* .cbInstanceRC = */           0,
-    /* .uReserved1 = */             0,
+    /* .cMaxPciDevices = */         1,
     /* .pszDescription = */         "ICH AC'97 Audio Controller",
 #if defined(IN_RING3)
Index: /trunk/src/VBox/Devices/Bus/DevPCI.cpp
===================================================================
--- /trunk/src/VBox/Devices/Bus/DevPCI.cpp	(revision 80700)
+++ /trunk/src/VBox/Devices/Bus/DevPCI.cpp	(revision 80701)
@@ -1411,5 +1411,5 @@
     /* .cbInstanceCC = */           0,
     /* .cbInstanceRC = */           0,
-    /* .uReserved1 = */             0,
+    /* .cMaxPciDevices = */         2,
     /* .pszDescription = */         "i440FX PCI bridge and PIIX3 ISA bridge.",
 #if defined(IN_RING3)
@@ -1754,5 +1754,5 @@
     /* .cbInstanceCC = */           0,
     /* .cbInstanceRC = */           0,
-    /* .uReserved1 = */             0,
+    /* .cMaxPciDevices = */         1,
     /* .pszDescription = */         "82801 Mobile PCI to PCI bridge",
 #if defined(IN_RING3)
Index: /trunk/src/VBox/Devices/Bus/DevPciIch9.cpp
===================================================================
--- /trunk/src/VBox/Devices/Bus/DevPciIch9.cpp	(revision 80700)
+++ /trunk/src/VBox/Devices/Bus/DevPciIch9.cpp	(revision 80701)
@@ -3605,5 +3605,5 @@
     /* .cbInstanceCC = */           0,
     /* .cbInstanceRC = */           0,
-    /* .uReserved1 = */             0,
+    /* .cMaxPciDevices = */         1,
     /* .pszDescription = */         "ICH9 PCI bridge",
 #if defined(IN_RING3)
Index: /trunk/src/VBox/Devices/Graphics/DevVGA.cpp
===================================================================
--- /trunk/src/VBox/Devices/Graphics/DevVGA.cpp	(revision 80700)
+++ /trunk/src/VBox/Devices/Graphics/DevVGA.cpp	(revision 80701)
@@ -7280,5 +7280,5 @@
     /* .cbInstanceCC = */           0,
     /* .cbInstanceRC = */           0,
-    /* .uReserved1 = */             0,
+    /* .cMaxPciDevices = */         1,
     /* .pszDescription = */         "VGA Adaptor with VESA extensions.",
 #if defined(IN_RING3)
Index: /trunk/src/VBox/Devices/Network/DevE1000.cpp
===================================================================
--- /trunk/src/VBox/Devices/Network/DevE1000.cpp	(revision 80700)
+++ /trunk/src/VBox/Devices/Network/DevE1000.cpp	(revision 80701)
@@ -8103,5 +8103,5 @@
     /* .uReserved0 = */             0,
     /* .szName = */                 "e1000",
-    /* .fFlags = */                 PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RC | PDM_DEVREG_FLAGS_R0,
+    /* .fFlags = */                 PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RC | PDM_DEVREG_FLAGS_R0 | PDM_DEVREG_FLAGS_MSI_X,
     /* .fClass = */                 PDM_DEVREG_CLASS_NETWORK,
     /* .cMaxInstances = */          ~0U,
@@ -8110,5 +8110,5 @@
     /* .cbInstanceCC = */           0,
     /* .cbInstanceRC = */           0,
-    /* .uReserved1 = */             0,
+    /* .cMaxPciDevices = */         1,
     /* .pszDescription = */         "Intel PRO/1000 MT Desktop Ethernet.",
 #if defined(IN_RING3)
Index: /trunk/src/VBox/Devices/Network/DevPCNet.cpp
===================================================================
--- /trunk/src/VBox/Devices/Network/DevPCNet.cpp	(revision 80700)
+++ /trunk/src/VBox/Devices/Network/DevPCNet.cpp	(revision 80701)
@@ -5553,5 +5553,5 @@
     /* .cbInstanceCC = */           0,
     /* .cbInstanceRC = */           0,
-    /* .uReserved1 = */             0,
+    /* .cMaxPciDevices = */         1,
     /* .pszDescription = */         "AMD PCnet Ethernet controller.\n",
 #if defined(IN_RING3)
Index: /trunk/src/VBox/Devices/Network/DevVirtioNet.cpp
===================================================================
--- /trunk/src/VBox/Devices/Network/DevVirtioNet.cpp	(revision 80700)
+++ /trunk/src/VBox/Devices/Network/DevVirtioNet.cpp	(revision 80701)
@@ -2364,5 +2364,5 @@
     /* .cbInstanceCC = */           0,
     /* .cbInstanceRC = */           0,
-    /* .uReserved1 = */             0,
+    /* .cMaxPciDevices = */         1,
     /* .pszDescription = */         "Virtio Ethernet.\n",
 #if defined(IN_RING3)
Index: /trunk/src/VBox/Devices/PC/DevACPI.cpp
===================================================================
--- /trunk/src/VBox/Devices/PC/DevACPI.cpp	(revision 80700)
+++ /trunk/src/VBox/Devices/PC/DevACPI.cpp	(revision 80701)
@@ -4195,5 +4195,5 @@
     /* .cbInstanceCC = */           0,
     /* .cbInstanceRC = */           0,
-    /* .uReserved1 = */             0,
+    /* .cMaxPciDevices = */         1,
     /* .pszDescription = */         "Advanced Configuration and Power Interface",
 #if defined(IN_RING3)
Index: /trunk/src/VBox/Devices/PC/DevLpc-new.cpp
===================================================================
--- /trunk/src/VBox/Devices/PC/DevLpc-new.cpp	(revision 80700)
+++ /trunk/src/VBox/Devices/PC/DevLpc-new.cpp	(revision 80701)
@@ -399,5 +399,5 @@
     /* .cbInstanceCC = */           0,
     /* .cbInstanceRC = */           0,
-    /* .uReserved1 = */             0,
+    /* .cMaxPciDevices = */         1,
     /* .pszDescription = */         "Low Pin Count (LPC) Bus",
 #if defined(IN_RING3)
Index: /trunk/src/VBox/Devices/Samples/DevPlayground.cpp
===================================================================
--- /trunk/src/VBox/Devices/Samples/DevPlayground.cpp	(revision 80700)
+++ /trunk/src/VBox/Devices/Samples/DevPlayground.cpp	(revision 80701)
@@ -351,5 +351,5 @@
     /* .cbInstanceCC = */           0,
     /* .cbInstanceRC = */           0,
-    /* .uReserved1 = */             0,
+    /* .cMaxPciDevices = */         1,
     /* .pszDescription = */         "VBox Playground Device.",
 #if defined(IN_RING3)
Index: /trunk/src/VBox/Devices/Serial/DevOxPcie958.cpp
===================================================================
--- /trunk/src/VBox/Devices/Serial/DevOxPcie958.cpp	(revision 80700)
+++ /trunk/src/VBox/Devices/Serial/DevOxPcie958.cpp	(revision 80701)
@@ -632,5 +632,5 @@
     /* .uReserved0 = */             0,
     /* .szName = */                 "oxpcie958uart",
-    /* .fFlags = */                 PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RC | PDM_DEVREG_FLAGS_R0,
+    /* .fFlags = */                 PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RC | PDM_DEVREG_FLAGS_R0 | PDM_DEVREG_FLAGS_MSI_X,
     /* .fClass = */                 PDM_DEVREG_CLASS_SERIAL,
     /* .cMaxInstances = */          ~0U,
@@ -639,5 +639,5 @@
     /* .cbInstanceCC = */           0,
     /* .cbInstanceRC = */           0,
-    /* .uReserved1 = */             0,
+    /* .cMaxPciDevices = */         1,
     /* .pszDescription = */         "OXPCIe958 based UART controller.\n",
 #if defined(IN_RING3)
Index: /trunk/src/VBox/Devices/Storage/DevAHCI.cpp
===================================================================
--- /trunk/src/VBox/Devices/Storage/DevAHCI.cpp	(revision 80700)
+++ /trunk/src/VBox/Devices/Storage/DevAHCI.cpp	(revision 80701)
@@ -6243,5 +6243,5 @@
     /* .cbInstanceCC = */           0,
     /* .cbInstanceRC = */           0,
-    /* .uReserved1 = */             0,
+    /* .cMaxPciDevices = */         1,
     /* .pszDescription = */         "Intel AHCI controller.\n",
 #if defined(IN_RING3)
Index: /trunk/src/VBox/Devices/Storage/DevATA.cpp
===================================================================
--- /trunk/src/VBox/Devices/Storage/DevATA.cpp	(revision 80700)
+++ /trunk/src/VBox/Devices/Storage/DevATA.cpp	(revision 80701)
@@ -8069,5 +8069,5 @@
     /* .cbInstanceCC = */           0,
     /* .cbInstanceRC = */           0,
-    /* .uReserved1 = */             0,
+    /* .cMaxPciDevices = */         1,
     /* .pszDescription = */         "Intel PIIX3 ATA controller.\n"
                                     "  LUN #0 is primary master.\n"
Index: /trunk/src/VBox/Devices/Storage/DevBusLogic.cpp
===================================================================
--- /trunk/src/VBox/Devices/Storage/DevBusLogic.cpp	(revision 80700)
+++ /trunk/src/VBox/Devices/Storage/DevBusLogic.cpp	(revision 80701)
@@ -4504,5 +4504,5 @@
     /* .cbInstanceCC = */           0,
     /* .cbInstanceRC = */           0,
-    /* .uReserved1 = */             0,
+    /* .cMaxPciDevices = */         1,
     /* .pszDescription = */         "BusLogic BT-958 SCSI host adapter.\n",
 #if defined(IN_RING3)
Index: /trunk/src/VBox/Devices/Storage/DevLsiLogicSCSI.cpp
===================================================================
--- /trunk/src/VBox/Devices/Storage/DevLsiLogicSCSI.cpp	(revision 80700)
+++ /trunk/src/VBox/Devices/Storage/DevLsiLogicSCSI.cpp	(revision 80701)
@@ -5751,5 +5751,5 @@
     /* .cbInstanceCC = */           0,
     /* .cbInstanceRC = */           0,
-    /* .uReserved1 = */             0,
+    /* .cMaxPciDevices = */         1,
     /* .pszDescription = */         "LSI Logic 53c1030 SCSI controller.\n",
 #if defined(IN_RING3)
Index: /trunk/src/VBox/Devices/Storage/DevVirtioSCSI.cpp
===================================================================
--- /trunk/src/VBox/Devices/Storage/DevVirtioSCSI.cpp	(revision 80700)
+++ /trunk/src/VBox/Devices/Storage/DevVirtioSCSI.cpp	(revision 80701)
@@ -2381,5 +2381,5 @@
     /* .cbInstanceCC = */           0,
     /* .cbInstanceRC = */           0,
-    /* .uReserved1 = */             0,
+    /* .cMaxPciDevices = */         1,
     /* .pszDescription = */         "Virtio Host SCSI.\n",
 #if defined(IN_RING3)
Index: /trunk/src/VBox/Devices/USB/DevOHCI.cpp
===================================================================
--- /trunk/src/VBox/Devices/USB/DevOHCI.cpp	(revision 80700)
+++ /trunk/src/VBox/Devices/USB/DevOHCI.cpp	(revision 80701)
@@ -6159,5 +6159,5 @@
     /* .cbInstanceCC = */           0,
     /* .cbInstanceRC = */           0,
-    /* .uReserved1 = */             0,
+    /* .cMaxPciDevices = */         1,
     /* .pszDescription = */         "OHCI USB controller.\n",
 #if defined(IN_RING3)
Index: /trunk/src/VBox/Devices/VMMDev/VMMDev.cpp
===================================================================
--- /trunk/src/VBox/Devices/VMMDev/VMMDev.cpp	(revision 80700)
+++ /trunk/src/VBox/Devices/VMMDev/VMMDev.cpp	(revision 80701)
@@ -4752,5 +4752,5 @@
     /* .cbInstanceCC = */           0,
     /* .cbInstanceRC = */           0,
-    /* .uReserved1 = */             0,
+    /* .cMaxPciDevices = */         1,
     /* .pszDescription = */         "VirtualBox VMM Device\n",
 #if defined(IN_RING3)
Index: /trunk/src/VBox/VMM/VMMR0/PDMR0Device.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR0/PDMR0Device.cpp	(revision 80700)
+++ /trunk/src/VBox/VMM/VMMR0/PDMR0Device.cpp	(revision 80701)
@@ -1808,9 +1808,9 @@
                               ("pDevReg->u32Version=%#x vs %#x\n", pModReg->u32Version, PDM_DEVREGR0_VERSION), VERR_VERSION_MISMATCH);
         AssertLogRelMsgReturn(RT_VALID_PTR(pDevReg->pszDescription), ("[%u]: %p\n", i, pDevReg->pszDescription), VERR_INVALID_POINTER);
-        AssertLogRelMsgReturn(pDevReg->uReserved0   == 0, ("[%u]: %#x\n", i, pDevReg->uReserved0),    VERR_INVALID_PARAMETER);
-        AssertLogRelMsgReturn(pDevReg->uReserved1   == 0, ("[%u]: %#x\n", i, pDevReg->uReserved1),    VERR_INVALID_PARAMETER);
-        AssertLogRelMsgReturn(pDevReg->fClass       != 0, ("[%u]: %#x\n", i, pDevReg->fClass),        VERR_INVALID_PARAMETER);
-        AssertLogRelMsgReturn(pDevReg->fFlags       != 0, ("[%u]: %#x\n", i, pDevReg->fFlags),        VERR_INVALID_PARAMETER);
-        AssertLogRelMsgReturn(pDevReg->cMaxInstances > 0, ("[%u]: %#x\n", i, pDevReg->cMaxInstances), VERR_INVALID_PARAMETER);
+        AssertLogRelMsgReturn(pDevReg->uReserved0     == 0, ("[%u]: %#x\n", i, pDevReg->uReserved0),     VERR_INVALID_PARAMETER);
+        AssertLogRelMsgReturn(pDevReg->fClass         != 0, ("[%u]: %#x\n", i, pDevReg->fClass),         VERR_INVALID_PARAMETER);
+        AssertLogRelMsgReturn(pDevReg->fFlags         != 0, ("[%u]: %#x\n", i, pDevReg->fFlags),         VERR_INVALID_PARAMETER);
+        AssertLogRelMsgReturn(pDevReg->cMaxInstances   > 0, ("[%u]: %#x\n", i, pDevReg->cMaxInstances),  VERR_INVALID_PARAMETER);
+        AssertLogRelMsgReturn(pDevReg->cMaxPciDevices <= 8, ("[%u]: %#x\n", i, pDevReg->cMaxPciDevices), VERR_INVALID_PARAMETER);
 
         /* The name must be printable ascii and correctly terminated. */
Index: /trunk/src/VBox/VMM/VMMR3/PDMDevHlp.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR3/PDMDevHlp.cpp	(revision 80700)
+++ /trunk/src/VBox/VMM/VMMR3/PDMDevHlp.cpp	(revision 80701)
@@ -1656,4 +1656,7 @@
      * Validate input.
      */
+    AssertLogRelMsgReturn(pDevIns->pReg->cMaxPciDevices > 0,
+                          ("'%s'/%d: cMaxPciDevices is 0\n", pDevIns->pReg->szName, pDevIns->iInstance),
+                          VERR_WRONG_ORDER);
     AssertLogRelMsgReturn(RT_VALID_PTR(pPciDev),
                           ("'%s'/%d: Invalid pPciDev value: %p\n", pDevIns->pReg->szName, pDevIns->iInstance, pPciDev),
@@ -1921,4 +1924,12 @@
     LogFlow(("pdmR3DevHlp_PCIRegisterMsi: caller='%s'/%d: pPciDev=%p:{%#x} pMsgReg=%p:{cMsiVectors=%d, cMsixVectors=%d}\n",
              pDevIns->pReg->szName, pDevIns->iInstance, pPciDev, pPciDev->uDevFn, pMsiReg, pMsiReg->cMsiVectors, pMsiReg->cMsixVectors));
+
+    AssertLogRelMsgReturn(pDevIns->pReg->cMaxPciDevices > 0,
+                          ("'%s'/%d: cMaxPciDevices is 0\n", pDevIns->pReg->szName, pDevIns->iInstance),
+                          VERR_WRONG_ORDER);
+    AssertLogRelMsgReturn((pDevIns->pReg->fFlags & PDM_DEVREG_FLAGS_MSI_X) || pMsiReg->cMsixVectors == 0,
+                          ("'%s'/%d: PDM_DEVREG_FLAGS_MSI_X not set and cMsixVectors=%u\n",
+                           pDevIns->pReg->szName, pDevIns->iInstance, pMsiReg->cMsixVectors),
+                          VERR_INVALID_FLAGS);
 
     PPDMPCIBUS pBus = pPciDev->Int.s.pPdmBusR3; Assert(pBus);
Index: /trunk/src/VBox/VMM/VMMR3/PDMDevice.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR3/PDMDevice.cpp	(revision 80700)
+++ /trunk/src/VBox/VMM/VMMR3/PDMDevice.cpp	(revision 80701)
@@ -760,4 +760,6 @@
                     ("u32VersionEnd=%#x, expected %#x. (szName=%s)\n",
                      pReg->u32VersionEnd, PDM_DEVREG_VERSION, pReg->szName));
+    AssertLogRelMsgReturn(pReg->cMaxPciDevices <= 8, ("%#x (szName=%s)\n", pReg->cMaxPciDevices, pReg->szName),
+                          VERR_PDM_INVALID_DEVICE_REGISTRATION);
 
     /*
