Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp	(revision 98809)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp	(revision 98810)
@@ -750,4 +750,9 @@
 {
     return uisession()->setDnDMode(enmMode);
+}
+
+bool UIMachine::acquireAmountOfStorageDevices(ulong &cHardDisks, ulong &cOpticalDrives, ulong &cFloppyDrives)
+{
+    return uisession()->acquireAmountOfStorageDevices(cHardDisks, cOpticalDrives, cFloppyDrives);
 }
 
@@ -1834,21 +1839,16 @@
     {
         /* Initialize CD/FD menus: */
-        int iDevicesCountCD = 0;
-        int iDevicesCountFD = 0;
-        foreach (const CMediumAttachment &comAttachment, uisession()->machine().GetMediumAttachments())
-        {
-            if (comAttachment.GetType() == KDeviceType_DVD)
-                ++iDevicesCountCD;
-            if (comAttachment.GetType() == KDeviceType_Floppy)
-                ++iDevicesCountFD;
-        }
+        ulong cHardDisks = 0;
+        ulong iOpticalDevices = 0;
+        ulong cFloppyDevices = 0;
+        acquireAmountOfStorageDevices(cHardDisks, iOpticalDevices, cFloppyDevices);
         QAction *pOpticalDevicesMenu = actionPool()->action(UIActionIndexRT_M_Devices_M_OpticalDevices);
         QAction *pFloppyDevicesMenu = actionPool()->action(UIActionIndexRT_M_Devices_M_FloppyDevices);
-        pOpticalDevicesMenu->setData(iDevicesCountCD);
-        pFloppyDevicesMenu->setData(iDevicesCountFD);
-        if (!iDevicesCountCD)
+        pOpticalDevicesMenu->setData((int)iOpticalDevices);
+        pFloppyDevicesMenu->setData((int)cFloppyDevices);
+        if (!iOpticalDevices)
             restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)
                                     (restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_OpticalDevices);
-        if (!iDevicesCountFD)
+        if (!cFloppyDevices)
             restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)
                                     (restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_FloppyDevices);
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h	(revision 98809)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h	(revision 98810)
@@ -516,4 +516,7 @@
     /** @name Storage stuff.
      ** @{ */
+        /** Enumerates amount of storage devices. */
+        bool acquireAmountOfStorageDevices(ulong &cHardDisks, ulong &cOpticalDrives, ulong &cFloppyDrives);
+
         /** Returns a list of storage devices. */
         bool storageDevices(KDeviceType enmDeviceType, QList<StorageDeviceInfo> &guiStorageDevices);
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp	(revision 98809)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp	(revision 98810)
@@ -555,4 +555,44 @@
     if (!fSuccess)
         UINotificationMessage::cannotAcquireMachineParameter(comMachine);
+    return fSuccess;
+}
+
+bool UISession::acquireAmountOfStorageDevices(ulong &cHardDisks, ulong &cOpticalDrives, ulong &cFloppyDrives)
+{
+    const CMachine comMachine = machine();
+    ulong cActualHardDisks = 0, cActualOpticalDrives = 0, cActualFloppyDrives = 0;
+    const CMediumAttachmentVector comAttachments = comMachine.GetMediumAttachments();
+    bool fSuccess = comMachine.isOk();
+    if (!fSuccess)
+        UINotificationMessage::cannotAcquireMachineParameter(comMachine);
+    else
+    {
+        foreach (const CMediumAttachment &comAttachment, comAttachments)
+        {
+            /* Get device type: */
+            const KDeviceType enmDeviceType = comAttachment.GetType();
+            fSuccess = comAttachment.isOk();
+            if (!fSuccess)
+            {
+                UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
+                break;
+            }
+
+            /* And advance corresponding amount: */
+            switch (enmDeviceType)
+            {
+                case KDeviceType_HardDisk: ++cActualHardDisks; break;
+                case KDeviceType_DVD: ++cActualOpticalDrives; break;
+                case KDeviceType_Floppy: ++cActualFloppyDrives; break;
+                default: break;
+            }
+        }
+    }
+    if (fSuccess)
+    {
+        cHardDisks = cActualHardDisks;
+        cOpticalDrives = cActualOpticalDrives;
+        cFloppyDrives = cActualFloppyDrives;
+    }
     return fSuccess;
 }
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h	(revision 98809)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h	(revision 98810)
@@ -326,4 +326,7 @@
     /** @name Storage stuff.
      ** @{ */
+        /** Enumerates amount of storage devices. */
+        bool acquireAmountOfStorageDevices(ulong &cHardDisks, ulong &cOpticalDrives, ulong &cFloppyDrives);
+
         /** Returns a list of storage devices. */
         bool storageDevices(KDeviceType enmDeviceType, QList<StorageDeviceInfo> &guiStorageDevices);
