Index: /trunk/src/VBox/Main/include/ConsoleImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/ConsoleImpl.h	(revision 37812)
+++ /trunk/src/VBox/Main/include/ConsoleImpl.h	(revision 37813)
@@ -551,4 +551,6 @@
                                                    IMediumAttachment *aMediumAtt,
                                                    bool fForce);
+
+    HRESULT attachRawPciDevices(PVM pVM, BusAssignmentManager *BusMgr, PCFGMNODE pDevices);
     void attachStatusDriver(PCFGMNODE pCtlInst, PPDMLED *papLeds,
                             uint64_t uFirst, uint64_t uLast,
Index: /trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp	(revision 37812)
+++ /trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp	(revision 37813)
@@ -457,7 +457,7 @@
 
 #ifdef VBOX_WITH_PCI_PASSTHROUGH
-static HRESULT attachRawPciDevices(BusAssignmentManager* BusMgr,
-                                   PCFGMNODE             pDevices,
-                                   Console*              pConsole)
+HRESULT Console::attachRawPciDevices(PVM pVM,
+                                     BusAssignmentManager *BusMgr,
+                                     PCFGMNODE            pDevices)
 {
     HRESULT hrc = S_OK;
@@ -465,9 +465,30 @@
 
     SafeIfaceArray<IPciDeviceAttachment> assignments;
-    ComPtr<IMachine> aMachine =  pConsole->machine();
+    ComPtr<IMachine> aMachine = machine();
 
     hrc = aMachine->COMGETTER(PciDeviceAssignments)(ComSafeArrayAsOutParam(assignments));
     if (hrc != S_OK)
         return hrc;
+
+    /*
+     * PCI passthrough is only available if the proper ExtPack is installed.
+     *
+     * Note. Configuring PCI passthrough here and providing messages about
+     * the missing extpack isn't exactly clean, but it is a necessary evil
+     * to patch over legacy compatability issues introduced by the new
+     * distribution model.
+     */
+# ifdef VBOX_WITH_EXTPACK
+    static const char *s_pszPciRawExtPackName = "Oracle VM VirtualBox Extension Pack";
+    if (!mptrExtPackManager->isExtPackUsable(s_pszPciRawExtPackName))
+    {
+        /* Always fatal! */
+        return VMSetError(pVM, VERR_NOT_FOUND, RT_SRC_POS,
+                N_("Implementation of the PCI passthrough framework not found!\n"
+                   "The VM cannot be started. To fix this problem, either "
+                   "install the '%s' or disable PCI passthrough via VBoxManage"),
+                s_pszPciRawExtPackName);
+    }
+# endif
 
     PCFGMNODE pBridges = CFGMR3GetChild(pDevices, "ich9pcibridge");
@@ -569,5 +590,5 @@
         InsertConfigString(pLunL1,     "Driver", "MainPciRaw");
         InsertConfigNode(pLunL1,       "Config", &pCfg);
-        PciRawDev* pMainDev = new PciRawDev(pConsole);
+        PciRawDev* pMainDev = new PciRawDev(this);
         InsertConfigInteger(pCfg,      "Object", (uintptr_t)pMainDev);
     }
@@ -670,16 +691,16 @@
      */
     ComPtr<IVirtualBox> virtualBox;
-    hrc = pMachine->COMGETTER(Parent)(virtualBox.asOutParam());                         H();
+    hrc = pMachine->COMGETTER(Parent)(virtualBox.asOutParam());                             H();
 
     ComPtr<IHost> host;
-    hrc = virtualBox->COMGETTER(Host)(host.asOutParam());                               H();
+    hrc = virtualBox->COMGETTER(Host)(host.asOutParam());                                   H();
 
     ComPtr<ISystemProperties> systemProperties;
-    hrc = virtualBox->COMGETTER(SystemProperties)(systemProperties.asOutParam());       H();
+    hrc = virtualBox->COMGETTER(SystemProperties)(systemProperties.asOutParam());           H();
 
     ComPtr<IBIOSSettings> biosSettings;
-    hrc = pMachine->COMGETTER(BIOSSettings)(biosSettings.asOutParam());                 H();
-
-    hrc = pMachine->COMGETTER(HardwareUUID)(bstr.asOutParam());                         H();
+    hrc = pMachine->COMGETTER(BIOSSettings)(biosSettings.asOutParam());                     H();
+
+    hrc = pMachine->COMGETTER(HardwareUUID)(bstr.asOutParam());                             H();
     RTUUID HardwareUuid;
     rc = RTUuidFromUtf16(&HardwareUuid, bstr.raw());
@@ -687,5 +708,5 @@
 
     ULONG cRamMBs;
-    hrc = pMachine->COMGETTER(MemorySize)(&cRamMBs);                                    H();
+    hrc = pMachine->COMGETTER(MemorySize)(&cRamMBs);                                        H();
 #if 0 /* enable to play with lots of memory. */
     if (RTEnvExist("VBOX_RAM_SIZE"))
@@ -698,5 +719,5 @@
 
     ChipsetType_T chipsetType;
-    hrc = pMachine->COMGETTER(ChipsetType)(&chipsetType);                               H();
+    hrc = pMachine->COMGETTER(ChipsetType)(&chipsetType);                                   H();
     if (chipsetType == ChipsetType_ICH9)
     {
@@ -711,20 +732,20 @@
 
     ULONG cCpus = 1;
-    hrc = pMachine->COMGETTER(CPUCount)(&cCpus);                                        H();
+    hrc = pMachine->COMGETTER(CPUCount)(&cCpus);                                            H();
 
     ULONG ulCpuExecutionCap = 100;
-    hrc = pMachine->COMGETTER(CPUExecutionCap)(&ulCpuExecutionCap);                     H();
+    hrc = pMachine->COMGETTER(CPUExecutionCap)(&ulCpuExecutionCap);                         H();
 
     Bstr osTypeId;
-    hrc = pMachine->COMGETTER(OSTypeId)(osTypeId.asOutParam());                         H();
+    hrc = pMachine->COMGETTER(OSTypeId)(osTypeId.asOutParam());                             H();
 
     BOOL fIOAPIC;
-    hrc = biosSettings->COMGETTER(IOAPICEnabled)(&fIOAPIC);                             H();
+    hrc = biosSettings->COMGETTER(IOAPICEnabled)(&fIOAPIC);                                 H();
 
     ComPtr<IGuestOSType> guestOSType;
-    hrc = virtualBox->GetGuestOSType(osTypeId.raw(), guestOSType.asOutParam());         H();
+    hrc = virtualBox->GetGuestOSType(osTypeId.raw(), guestOSType.asOutParam());             H();
 
     Bstr guestTypeFamilyId;
-    hrc = guestOSType->COMGETTER(FamilyId)(guestTypeFamilyId.asOutParam());             H();
+    hrc = guestOSType->COMGETTER(FamilyId)(guestTypeFamilyId.asOutParam());                 H();
     BOOL fOsXGuest = guestTypeFamilyId == Bstr("MacOS");
 
@@ -1074,13 +1095,13 @@
             InsertConfigNode(pDev,     "0", &pInst);
             InsertConfigInteger(pInst, "Trusted",              1); /* boolean */
-            hrc = BusMgr->assignPciDevice("ich9pcibridge", pInst);                               H();
+            hrc = BusMgr->assignPciDevice("ich9pcibridge", pInst);                          H();
 
             InsertConfigNode(pDev,     "1", &pInst);
             InsertConfigInteger(pInst, "Trusted",              1); /* boolean */
-            hrc = BusMgr->assignPciDevice("ich9pcibridge", pInst);                               H();
+            hrc = BusMgr->assignPciDevice("ich9pcibridge", pInst);                          H();
 
 #ifdef VBOX_WITH_PCI_PASSTHROUGH
             /* Add PCI passthrough devices */
-            hrc = attachRawPciDevices(BusMgr, pDevices, this);                                   H();
+            hrc = attachRawPciDevices(pVM, BusMgr, pDevices);                               H();
 #endif
         }
@@ -1138,5 +1159,5 @@
             InsertConfigNode(pDevices, "lpc", &pDev);
             InsertConfigNode(pDev,     "0", &pInst);
-            hrc = BusMgr->assignPciDevice("lpc", pInst);                               H();
+            hrc = BusMgr->assignPciDevice("lpc", pInst);                                    H();
             InsertConfigInteger(pInst, "Trusted",   1); /* boolean */
         }
@@ -1234,5 +1255,5 @@
         InsertConfigInteger(pInst, "Trusted",              1); /* boolean */
 
-        hrc = BusMgr->assignPciDevice("vga", pInst);                               H();
+        hrc = BusMgr->assignPciDevice("vga", pInst);                                        H();
         InsertConfigNode(pInst,    "Config", &pCfg);
         ULONG cVRamMBs;
@@ -1505,5 +1526,5 @@
                 case StorageControllerType_LsiLogic:
                 {
-                    hrc = BusMgr->assignPciDevice("lsilogic", pCtlInst);                               H();
+                    hrc = BusMgr->assignPciDevice("lsilogic", pCtlInst);                    H();
 
                     InsertConfigInteger(pCfg, "Bootable",  fBootable);
@@ -1511,5 +1532,6 @@
                     /* Attach the status driver */
                     Assert(cLedScsi >= 16);
-                    attachStatusDriver(pCtlInst, &mapStorageLeds[iLedScsi], 0, 15, &mapMediumAttachments, pszCtrlDev, ulInstance);
+                    attachStatusDriver(pCtlInst, &mapStorageLeds[iLedScsi], 0, 15,
+                                       &mapMediumAttachments, pszCtrlDev, ulInstance);
                     paLedDevType = &maStorageDevType[iLedScsi];
                     break;
@@ -1518,5 +1540,5 @@
                 case StorageControllerType_BusLogic:
                 {
-                    hrc = BusMgr->assignPciDevice("buslogic", pCtlInst);                               H();
+                    hrc = BusMgr->assignPciDevice("buslogic", pCtlInst);                    H();
 
                     InsertConfigInteger(pCfg, "Bootable",  fBootable);
@@ -1524,5 +1546,6 @@
                     /* Attach the status driver */
                     Assert(cLedScsi >= 16);
-                    attachStatusDriver(pCtlInst, &mapStorageLeds[iLedScsi], 0, 15, &mapMediumAttachments, pszCtrlDev, ulInstance);
+                    attachStatusDriver(pCtlInst, &mapStorageLeds[iLedScsi], 0, 15,
+                                       &mapMediumAttachments, pszCtrlDev, ulInstance);
                     paLedDevType = &maStorageDevType[iLedScsi];
                     break;
@@ -1531,5 +1554,5 @@
                 case StorageControllerType_IntelAhci:
                 {
-                    hrc = BusMgr->assignPciDevice("ahci", pCtlInst);                               H();
+                    hrc = BusMgr->assignPciDevice("ahci", pCtlInst);                        H();
 
                     ULONG cPorts = 0;
@@ -1554,5 +1577,5 @@
 
                             LONG lPortNumber = -1;
-                            hrc = ctrls[i]->GetIDEEmulationPort(j, &lPortNumber);               H();
+                            hrc = ctrls[i]->GetIDEEmulationPort(j, &lPortNumber);           H();
                             InsertConfigInteger(pCfg, s_apszConfig[j], lPortNumber);
                             if (pBiosCfg)
@@ -1563,5 +1586,6 @@
                     /* Attach the status driver */
                     AssertRelease(cPorts <= cLedSata);
-                    attachStatusDriver(pCtlInst, &mapStorageLeds[iLedSata], 0, cPorts - 1, &mapMediumAttachments, pszCtrlDev, ulInstance);
+                    attachStatusDriver(pCtlInst, &mapStorageLeds[iLedSata], 0, cPorts - 1,
+                                       &mapMediumAttachments, pszCtrlDev, ulInstance);
                     paLedDevType = &maStorageDevType[iLedSata];
                     break;
@@ -1575,9 +1599,10 @@
                      * IDE (update this when the main interface changes)
                      */
-                    hrc = BusMgr->assignPciDevice("piix3ide", pCtlInst);                               H();
+                    hrc = BusMgr->assignPciDevice("piix3ide", pCtlInst);                    H();
                     InsertConfigString(pCfg,   "Type", controllerString(enmCtrlType));
                     /* Attach the status driver */
                     Assert(cLedIde >= 4);
-                    attachStatusDriver(pCtlInst, &mapStorageLeds[iLedIde], 0, 3, &mapMediumAttachments, pszCtrlDev, ulInstance);
+                    attachStatusDriver(pCtlInst, &mapStorageLeds[iLedIde], 0, 3,
+                                       &mapMediumAttachments, pszCtrlDev, ulInstance);
                     paLedDevType = &maStorageDevType[iLedIde];
 
@@ -1602,5 +1627,6 @@
                     /* Attach the status driver */
                     Assert(cLedFloppy >= 2);
-                    attachStatusDriver(pCtlInst, &mapStorageLeds[iLedFloppy], 0, 1, &mapMediumAttachments, pszCtrlDev, ulInstance);
+                    attachStatusDriver(pCtlInst, &mapStorageLeds[iLedFloppy], 0, 1,
+                                       &mapMediumAttachments, pszCtrlDev, ulInstance);
                     paLedDevType = &maStorageDevType[iLedFloppy];
                     break;
@@ -1609,5 +1635,5 @@
                 case StorageControllerType_LsiLogicSas:
                 {
-                    hrc = BusMgr->assignPciDevice("lsilogicsas", pCtlInst);                               H();
+                    hrc = BusMgr->assignPciDevice("lsilogicsas", pCtlInst);                 H();
 
                     InsertConfigString(pCfg,  "ControllerType", "SAS1068");
@@ -1616,5 +1642,6 @@
                     /* Attach the status driver */
                     Assert(cLedSas >= 8);
-                    attachStatusDriver(pCtlInst, &mapStorageLeds[iLedSas], 0, 7, &mapMediumAttachments, pszCtrlDev, ulInstance);
+                    attachStatusDriver(pCtlInst, &mapStorageLeds[iLedSas], 0, 7,
+                                       &mapMediumAttachments, pszCtrlDev, ulInstance);
                     paLedDevType = &maStorageDevType[iLedSas];
                     break;
@@ -1628,9 +1655,9 @@
             com::SafeIfaceArray<IMediumAttachment> atts;
             hrc = pMachine->GetMediumAttachmentsOfController(controllerName.raw(),
-                                                            ComSafeArrayAsOutParam(atts)); H();
+                                                            ComSafeArrayAsOutParam(atts));  H();
 
             /* Builtin I/O cache - per device setting. */
             BOOL fBuiltinIoCache = true;
-            hrc = pMachine->COMGETTER(IoCacheEnabled)(&fBuiltinIoCache);                                  H();
+            hrc = pMachine->COMGETTER(IoCacheEnabled)(&fBuiltinIoCache);                    H();
 
 
@@ -1757,5 +1784,5 @@
 #endif
             PciBusAddress PciAddr = PciBusAddress(0, iPciDeviceNo, 0);
-            hrc = BusMgr->assignPciDevice(pszAdapterName, pInst, PciAddr);                               H();
+            hrc = BusMgr->assignPciDevice(pszAdapterName, pInst, PciAddr);                  H();
 
             InsertConfigNode(pInst, "Config", &pCfg);
@@ -1990,5 +2017,5 @@
         InsertConfigNode(pInst,    "Config", &pCfg);
         InsertConfigInteger(pInst, "Trusted",              1); /* boolean */
-        hrc = BusMgr->assignPciDevice("VMMDev", pInst);                               H();
+        hrc = BusMgr->assignPciDevice("VMMDev", pInst);                                     H();
 
         Bstr hwVersion;
@@ -1998,5 +2025,5 @@
             InsertConfigInteger(pCfg, "HeapEnabled", 0);
         Bstr snapshotFolder;
-        hrc = pMachine->COMGETTER(SnapshotFolder)(snapshotFolder.asOutParam());            H();
+        hrc = pMachine->COMGETTER(SnapshotFolder)(snapshotFolder.asOutParam());             H();
         InsertConfigString(pCfg, "GuestCoreDumpDir", snapshotFolder);
 
@@ -2047,5 +2074,5 @@
                     InsertConfigNode(pDev,     "0", &pInst);
                     InsertConfigInteger(pInst, "Trusted",          1); /* boolean */
-                    hrc = BusMgr->assignPciDevice("ichac97", pInst);                               H();
+                    hrc = BusMgr->assignPciDevice("ichac97", pInst);                        H();
                     InsertConfigNode(pInst,    "Config", &pCfg);
                     break;
@@ -2071,5 +2098,5 @@
                     InsertConfigNode(pDev,     "0", &pInst);
                     InsertConfigInteger(pInst, "Trusted",          1); /* boolean */
-                    hrc = BusMgr->assignPciDevice("hda", pInst);                               H();
+                    hrc = BusMgr->assignPciDevice("hda", pInst);                            H();
                     InsertConfigNode(pInst,    "Config", &pCfg);
                 }
@@ -3224,9 +3251,9 @@
                 // would be to discard the VM state...
                 MediumState_T mediumState;
-                hrc = pMedium->RefreshState(&mediumState);                              H();
+                hrc = pMedium->RefreshState(&mediumState);                                  H();
                 if (mediumState == MediumState_Inaccessible)
                 {
                     Bstr loc;
-                    hrc = pMedium->COMGETTER(Location)(loc.asOutParam());               H();
+                    hrc = pMedium->COMGETTER(Location)(loc.asOutParam());                   H();
                     setVMRuntimeErrorCallbackF(VMR3GetVM(mpUVM),
                                                this,
@@ -3390,5 +3417,5 @@
                     hrc = pMedium->GetProperties(NULL,
                                                 ComSafeArrayAsOutParam(aNames),
-                                                ComSafeArrayAsOutParam(aValues));          H();
+                                                ComSafeArrayAsOutParam(aValues));           H();
 
                     if (aNames.size() != 0)
@@ -3488,14 +3515,14 @@
 
         ComPtr<IVirtualBox> virtualBox;
-        hrc = pMachine->COMGETTER(Parent)(virtualBox.asOutParam());                 H();
+        hrc = pMachine->COMGETTER(Parent)(virtualBox.asOutParam());                         H();
 
         ComPtr<IHost> host;
-        hrc = virtualBox->COMGETTER(Host)(host.asOutParam());                       H();
+        hrc = virtualBox->COMGETTER(Host)(host.asOutParam());                               H();
 
         BOOL fSniffer;
-        hrc = aNetworkAdapter->COMGETTER(TraceEnabled)(&fSniffer);                  H();
+        hrc = aNetworkAdapter->COMGETTER(TraceEnabled)(&fSniffer);                          H();
 
         NetworkAdapterPromiscModePolicy_T enmPromiscModePolicy;
-        hrc = aNetworkAdapter->COMGETTER(PromiscModePolicy)(&enmPromiscModePolicy); H();
+        hrc = aNetworkAdapter->COMGETTER(PromiscModePolicy)(&enmPromiscModePolicy);         H();
         const char *pszPromiscuousGuestPolicy;
         switch (enmPromiscModePolicy)
@@ -3797,5 +3824,5 @@
 //                     * the attachment), calling Detach here will cause a deadlock.
 //                     * See #4750.
-//                     * hrc = aNetworkAdapter->Detach();                        H();
+//                     * hrc = aNetworkAdapter->Detach();                                   H();
 //                     */
 //                     return VMSetError(pVM, VERR_INTERNAL_ERROR, RT_SRC_POS,
