Index: /trunk/src/VBox/Main/include/ConsoleImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/ConsoleImpl.h	(revision 98085)
+++ /trunk/src/VBox/Main/include/ConsoleImpl.h	(revision 98086)
@@ -810,8 +810,7 @@
     typedef struct LEDSET *PLEDSET;
     PPDMLED *i_getLedSet(uint32_t iLedSet);
-    uint32_t i_allocateDriverLeds(uint32_t cLeds, DeviceType_T enmType, DeviceType_T **ppSubTypes);
-    void i_attachStatusDriver(PCFGMNODE pCtlInst, DeviceType_T enmType,
-                              uint32_t uFirst, uint32_t uLast,
-                              DeviceType_T **ppaSubTypes,
+    uint32_t i_allocateDriverLeds(uint32_t cLeds, uint32_t fTypes, DeviceType_T **ppSubTypes);
+    void i_attachStatusDriver(PCFGMNODE pCtlInst, DeviceType_T enmType);
+    void i_attachStatusDriver(PCFGMNODE pCtlInst, uint32_t fTypes, uint32_t cLeds, DeviceType_T **ppaSubTypes,
                               Console::MediumAttachmentMap *pmapMediumAttachments,
                               const char *pcszDevice, unsigned uInstance);
@@ -1074,8 +1073,8 @@
     struct LEDSET
     {
-        PPDMLED      *papLeds;
-        uint32_t      cLeds;
-        DeviceType_T  enmType;
-        DeviceType_T *paSubTypes; /**< Optionally, device types for each individual LED. Runs parallel to papLeds. */
+        PPDMLED        *papLeds;
+        uint32_t        cLeds;
+        uint32_t        fTypes;     /**< Bitmask of possible DeviceType_T values (e.g. RT_BIT_32(DeviceType_Network)). */
+        DeviceType_T   *paSubTypes; /**< Optionally, device types for each individual LED. Runs parallel to papLeds. */
     }                 maLedSets[32];
     /** @} */
Index: /trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/ConsoleImpl.cpp	(revision 98085)
+++ /trunk/src/VBox/Main/src-client/ConsoleImpl.cpp	(revision 98086)
@@ -2857,34 +2857,31 @@
     PDMLEDCORE aLEDs[DeviceType_End] = { {0} };
     Assert(aLEDs[1].u32 == 0 && aLEDs[DeviceType_End / 2].u32 == 0 && aLEDs[DeviceType_End - 1].u32 == 0); /* paranoia */
-    for (uint32_t idxSet = 0; idxSet < mcLedSets; ++idxSet)
-    {
-        /* Look inside this driver's set of LEDs */
+    uint32_t idxSet = mcLedSets;
+    while (idxSet-- > 0)
+    {
+        /* Look inside this driver's set of LEDs and check if the types mask overlap with the request: */
         PLEDSET pLS = &maLedSets[idxSet];
-
-        /* Multi-type drivers (e.g. SCSI) have a subtype array which must be matched. */
-        if (pLS->paSubTypes)
-        {
-/** @todo r=bird: This needs optimizing as it hurts to scan all units of all
- * storage controllers when getting the activitiy of one or more non-storage
- * devices.
- *
- * Perhaps add a type summary bitmap to the entry, or may just reuse the
- * enmType for these. */
-            for (uint32_t inSet = 0; inSet < pLS->cLeds; ++inSet)
+        if (pLS->fTypes & fWanted)
+        {
+            uint32_t const        cLeds      = pLS->cLeds;
+            PPDMLED const * const papSrcLeds = pLS->papLeds;
+
+            /* Multi-type drivers (e.g. SCSI) have a subtype array which must be matched. */
+            DeviceType_T const *paSubTypes = pLS->paSubTypes;
+            if (paSubTypes)
+                for (uint32_t idxLed = 0; idxLed < cLeds; idxLed++)
+                {
+                    DeviceType_T const enmType = paSubTypes[idxLed];
+                    Assert((unsigned)enmType < (unsigned)DeviceType_End);
+                    if (fWanted & RT_BIT_32((unsigned)enmType))
+                        aLEDs[enmType].u32 |= readAndClearLed(papSrcLeds[idxLed]);
+                }
+            /* Single-type drivers (e.g. floppy) have the type in ->enmType */
+            else
             {
-                DeviceType_T const enmType = pLS->paSubTypes[inSet];
-                Assert((unsigned)enmType < (unsigned)DeviceType_End);
-                if (fWanted & RT_BIT_32((unsigned)enmType))
-                    aLEDs[enmType].u32 |= readAndClearLed(pLS->papLeds[inSet]);
+                uint32_t const idxType = ASMBitFirstSetU32(pLS->fTypes) - 1;
+                for (uint32_t idxLed = 0; idxLed < cLeds; idxLed++)
+                    aLEDs[idxType].u32 |= readAndClearLed(papSrcLeds[idxLed]);
             }
-        }
-        /* Single-type drivers (e.g. floppy) have the type in ->enmType */
-        else
-        {
-            DeviceType_T const enmType = pLS->enmType;
-            Assert((unsigned)enmType < (unsigned)DeviceType_End);
-            if (fWanted & RT_BIT_32((unsigned)enmType))
-                for (uint32_t inSet = 0; inSet < pLS->cLeds; ++inSet)
-                    aLEDs[enmType].u32 |= readAndClearLed(pLS->papLeds[inSet]);
         }
     }
Index: /trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp	(revision 98085)
+++ /trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp	(revision 98086)
@@ -662,14 +662,15 @@
  *
  * @returns Index into maLedSets.
- * @param   cLeds        The number of LEDs in the set.
- * @param   enmType      The device type.
- * @param   ppaSubTypes  When not NULL, subtypes for each LED and return the
- *                       array pointer here.
+ * @param   cLeds       The number of LEDs in the set.
+ * @param   fTypes      Bitmask of DeviceType_T values, e.g.
+ *                      RT_BIT_32(DeviceType_Network).
+ * @param   ppaSubTypes When not NULL, subtypes for each LED and return the
+ *                      array pointer here.
  */
-uint32_t Console::i_allocateDriverLeds(uint32_t cLeds, DeviceType_T enmType, DeviceType_T **ppaSubTypes)
+uint32_t Console::i_allocateDriverLeds(uint32_t cLeds, uint32_t fTypes, DeviceType_T **ppaSubTypes)
 {
     Assert(cLeds > 0);
     Assert(cLeds < 1024);  /* Adjust if any driver supports >=1024 units! */
-    Assert(enmType > DeviceType_Null && enmType < DeviceType_End);
+    Assert(!(fTypes & (RT_BIT_32(DeviceType_Null) | ~(RT_BIT_32(DeviceType_End) - 1))));
 
     /* Grab a LED set entry before we start allocating anything so the destructor can do the cleanups. */
@@ -682,13 +683,12 @@
     AssertStmt(pLS->papLeds, throw E_OUTOFMEMORY);
     pLS->cLeds = cLeds;
-    pLS->enmType = enmType;
+    pLS->fTypes = fTypes;
     pLS->paSubTypes = NULL;
 
     if (ppaSubTypes)
     {
-        *ppaSubTypes = pLS->paSubTypes = (DeviceType_T *)RTMemAlloc(sizeof(DeviceType_T) * cLeds);
+        AssertCompile((unsigned)DeviceType_Null == 0);
+        *ppaSubTypes = pLS->paSubTypes = (DeviceType_T *)RTMemAllocZ(sizeof(DeviceType_T) * cLeds);
         AssertStmt(pLS->paSubTypes, throw E_OUTOFMEMORY);
-        for (size_t idxSub = 0; idxSub < cLeds; ++idxSub)
-            pLS->paSubTypes[idxSub] = DeviceType_Null;
     }
 
@@ -698,12 +698,8 @@
 
 
-/** @todo r=bird: Drop uFirst as it's always zero? Then s/uLast/cLeds/g. */
-void Console::i_attachStatusDriver(PCFGMNODE pCtlInst, DeviceType_T enmType,
-                                   uint32_t uFirst, uint32_t uLast,
-                                   DeviceType_T **ppaSubTypes,
+void Console::i_attachStatusDriver(PCFGMNODE pCtlInst, uint32_t fTypes, uint32_t cLeds, DeviceType_T **ppaSubTypes,
                                    Console::MediumAttachmentMap *pmapMediumAttachments,
                                    const char *pcszDevice, unsigned uInstance)
 {
-    Assert(uFirst <= uLast);
     PCFGMNODE pLunL0;
     InsertConfigNode(pCtlInst,  "LUN#999", &pLunL0);
@@ -711,5 +707,5 @@
     PCFGMNODE pCfg;
     InsertConfigNode(pLunL0,    "Config", &pCfg);
-    uint32_t const iLedSet = i_allocateDriverLeds(uLast - uFirst + 1, enmType, ppaSubTypes);
+    uint32_t const iLedSet = i_allocateDriverLeds(cLeds, fTypes, ppaSubTypes);
     InsertConfigInteger(pCfg,   "iLedSet", iLedSet);
 
@@ -721,6 +717,13 @@
         InsertConfigString(pCfg,    "DeviceInstance", deviceInstance.c_str());
     }
-    InsertConfigInteger(pCfg,   "First",    uFirst);
-    InsertConfigInteger(pCfg,   "Last",     uLast);
+    InsertConfigInteger(pCfg,   "First",    0);
+    InsertConfigInteger(pCfg,   "Last",     cLeds - 1);
+}
+
+
+void Console::i_attachStatusDriver(PCFGMNODE pCtlInst, DeviceType_T enmType)
+{
+    Assert(enmType > DeviceType_Null && enmType < DeviceType_End);
+    i_attachStatusDriver(pCtlInst, RT_BIT_32(enmType), 1, NULL, NULL, NULL, 0);
 }
 
@@ -2125,5 +2128,5 @@
                      * Attach the status driver.
                      */
-                    i_attachStatusDriver(pInst, DeviceType_USB, 0, 0, NULL, NULL, NULL, 0);
+                    i_attachStatusDriver(pInst, DeviceType_USB);
                 }
 #ifdef VBOX_WITH_EHCI
@@ -2143,5 +2146,5 @@
                      * Attach the status driver.
                      */
-                    i_attachStatusDriver(pInst, DeviceType_USB, 0, 0, NULL, NULL, NULL, 0);
+                    i_attachStatusDriver(pInst, DeviceType_USB);
                 }
 #endif
@@ -2165,5 +2168,5 @@
                      * Attach the status driver.
                      */
-                    i_attachStatusDriver(pInst, DeviceType_USB, 0, 1, NULL, NULL, NULL, 0);
+                    i_attachStatusDriver(pInst, RT_BIT_32(DeviceType_USB), 2, NULL, NULL, NULL, 0);
                 }
             } /* for every USB controller. */
@@ -2358,6 +2361,6 @@
 
                     /* Attach the status driver */
-                    i_attachStatusDriver(pCtlInst, DeviceType_HardDisk, 0, 15, &paLedDevType,
-                                         &mapMediumAttachments, pszCtrlDev, ulInstance);
+                    i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk) | RT_BIT_32(DeviceType_DVD),
+                                         16, &paLedDevType, &mapMediumAttachments, pszCtrlDev, ulInstance);
                     break;
                 }
@@ -2380,6 +2383,6 @@
 
                     /* Attach the status driver */
-                    i_attachStatusDriver(pCtlInst, DeviceType_HardDisk, 0, 15, &paLedDevType,
-                                         &mapMediumAttachments, pszCtrlDev, ulInstance);
+                    i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk) | RT_BIT_32(DeviceType_DVD),
+                                         16, &paLedDevType, &mapMediumAttachments, pszCtrlDev, ulInstance);
                     break;
                 }
@@ -2428,6 +2431,6 @@
 
                     /* Attach the status driver */
-                    i_attachStatusDriver(pCtlInst, DeviceType_HardDisk, 0, cPorts - 1, &paLedDevType,
-                                         &mapMediumAttachments, pszCtrlDev, ulInstance);
+                    i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk) | RT_BIT_32(DeviceType_DVD),
+                                         cPorts, &paLedDevType, &mapMediumAttachments, pszCtrlDev, ulInstance);
                     break;
                 }
@@ -2442,7 +2445,8 @@
                     hrc = pBusMgr->assignPCIDevice("piix3ide", pCtlInst);                   H();
                     InsertConfigString(pCfg,   "Type", controllerString(enmCtrlType));
+
                     /* Attach the status driver */
-                    i_attachStatusDriver(pCtlInst, DeviceType_HardDisk, 0, 3, &paLedDevType,
-                                         &mapMediumAttachments, pszCtrlDev, ulInstance);
+                    i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk) | RT_BIT_32(DeviceType_DVD),
+                                         4, &paLedDevType, &mapMediumAttachments, pszCtrlDev, ulInstance);
 
                     /* IDE flavors */
@@ -2465,5 +2469,5 @@
 
                     /* Attach the status driver */
-                    i_attachStatusDriver(pCtlInst, DeviceType_Floppy, 0, 1, NULL,
+                    i_attachStatusDriver(pCtlInst, DeviceType_Floppy, 2, NULL,
                                          &mapMediumAttachments, pszCtrlDev, ulInstance);
                     break;
@@ -2492,6 +2496,6 @@
 
                     /* Attach the status driver */
-                    i_attachStatusDriver(pCtlInst, DeviceType_HardDisk, 0, 7, &paLedDevType,
-                                         &mapMediumAttachments, pszCtrlDev, ulInstance);
+                    i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk) | RT_BIT_32(DeviceType_DVD) /*?*/,
+                                         8, &paLedDevType, &mapMediumAttachments, pszCtrlDev, ulInstance);
                     break;
                 }
@@ -2526,6 +2530,6 @@
 
                     /* Attach the status driver */
-                    i_attachStatusDriver(pCtlInst, DeviceType_HardDisk, 0, cPorts - 1, NULL,
-                                         &mapMediumAttachments, pszCtrlDev, ulInstance);
+                    i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk),
+                                         cPorts, NULL, &mapMediumAttachments, pszCtrlDev, ulInstance);
                     break;
                 }
@@ -2541,6 +2545,6 @@
 
                     /* Attach the status driver */
-                    i_attachStatusDriver(pCtlInst, DeviceType_HardDisk, 0, cPorts - 1, &paLedDevType,
-                                         &mapMediumAttachments, pszCtrlDev, ulInstance);
+                    i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk) | RT_BIT_32(DeviceType_DVD) /*?*/,
+                                         cPorts, &paLedDevType, &mapMediumAttachments, pszCtrlDev, ulInstance);
                     break;
                 }
@@ -2828,5 +2832,5 @@
              * Attach the status driver.
              */
-            i_attachStatusDriver(pInst, DeviceType_Network, 0, 0, NULL, NULL, NULL, 0);
+            i_attachStatusDriver(pInst, DeviceType_Network);
 
             /*
@@ -3004,5 +3008,5 @@
          * Attach the status driver.
          */
-        i_attachStatusDriver(pInst, DeviceType_SharedFolder, 0, 0, NULL, NULL, NULL, 0);
+        i_attachStatusDriver(pInst, DeviceType_SharedFolder);
 
         /*
@@ -4292,5 +4296,5 @@
         InsertConfigInteger(pCfg,  "3DEnabled",            f3DEnabled);
 
-        i_attachStatusDriver(pInst, DeviceType_Graphics3D, 0, 0, NULL, NULL, NULL, 0);
+        i_attachStatusDriver(pInst, DeviceType_Graphics3D);
 
 #ifdef VBOX_WITH_VMSVGA
@@ -4914,22 +4918,21 @@
             if (!fHotplug && !fAttachDetach)
             {
-                char aszUuid[RTUUID_STR_LENGTH + 1];
                 USBStorageDevice UsbMsd = USBStorageDevice();
 
-                memset(aszUuid, 0, sizeof(aszUuid));
+                UsbMsd.iPort = uInstance;
                 vrc = RTUuidCreate(&UsbMsd.mUuid);
                 AssertRCReturn(vrc, vrc);
-                vrc = RTUuidToStr(&UsbMsd.mUuid, aszUuid, sizeof(aszUuid));
+
+                char szUuid[RTUUID_STR_LENGTH + 1];
+                vrc = RTUuidToStr(&UsbMsd.mUuid, szUuid, sizeof(szUuid));
                 AssertRCReturn(vrc, vrc);
-
-                UsbMsd.iPort = uInstance;
-
-                InsertConfigString(pCtlInst, "UUID", aszUuid);
+                InsertConfigString(pCtlInst, "UUID", szUuid);
+
                 mUSBStorageDevices.push_back(UsbMsd);
 
                 /** @todo No LED after hotplugging. */
                 /* Attach the status driver */
-                i_attachStatusDriver(pCtlInst, DeviceType_HardDisk, 0, 7, &paLedDevType,
-                                     &mapMediumAttachments, pcszDevice, 0);
+                i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk),
+                                     8, &paLedDevType, &mapMediumAttachments, pcszDevice, 0);
             }
         }
