Index: /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp	(revision 50863)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp	(revision 50864)
@@ -1926,4 +1926,274 @@
         return m_pMediumEnumerator->mediumIDs();
     return QList<QString>();
+}
+
+void VBoxGlobal::prepareStorageMenu(QMenu &menu,
+                                    QObject *pListener, const char *pszSlotName,
+                                    const CMachine &machine, const QString &strControllerName, const StorageSlot &storageSlot)
+{
+    /* Current attachment attributes: */
+    const CMediumAttachment currentAttachment = machine.GetMediumAttachment(strControllerName, storageSlot.port, storageSlot.device);
+    const CMedium currentMedium = currentAttachment.GetMedium();
+    const QString strCurrentID = currentMedium.isNull() ? QString() : currentMedium.GetId();
+    const QString strCurrentLocation = currentMedium.isNull() ? QString() : currentMedium.GetLocation();
+
+    /* Other medium-attachments of same machine: */
+    const CMediumAttachmentVector attachments = machine.GetMediumAttachments();
+
+    /* Determine device & medium types: */
+    const KDeviceType deviceType = currentAttachment.GetType();
+    const UIMediumType mediumType = deviceType == KDeviceType_DVD    ? UIMediumType_DVD :
+                                    deviceType == KDeviceType_Floppy ? UIMediumType_Floppy :
+                                                                       UIMediumType_Invalid;
+    AssertMsgReturnVoid(deviceType != KDeviceType_Null, ("Incorrect storage device type!\n"));
+    AssertMsgReturnVoid(mediumType != UIMediumType_Invalid, ("Incorrect storage medium type!\n"));
+
+
+    /* Prepare open-existing-medium action: */
+    QAction *pActionOpenExistingMedium = menu.addAction(QIcon(":/select_file_16px.png"), QString(), pListener, pszSlotName);
+    pActionOpenExistingMedium->setData(QVariant::fromValue(UIMediumTarget(strControllerName, currentAttachment.GetPort(),
+                                                                          currentAttachment.GetDevice(), mediumType)));
+
+
+    /* Insert separator: */
+    menu.addSeparator();
+
+
+    /* Get existing-host-drive vector: */
+    CMediumVector mediums;
+    switch (mediumType)
+    {
+        case UIMediumType_DVD: mediums = vboxGlobal().host().GetDVDDrives(); break;
+        case UIMediumType_Floppy: mediums = vboxGlobal().host().GetFloppyDrives(); break;
+        default: break;
+    }
+    /* Prepare choose-existing-host-drive actions: */
+    foreach (const CMedium &medium, mediums)
+    {
+        /* Make sure host-drive usage is unique: */
+        bool fIsHostDriveUsed = false;
+        foreach (const CMediumAttachment &otherAttachment, attachments)
+        {
+            if (otherAttachment != currentAttachment)
+            {
+                const CMedium &otherMedium = otherAttachment.GetMedium();
+                if (!otherMedium.isNull() && otherMedium.GetId() == medium.GetId())
+                {
+                    fIsHostDriveUsed = true;
+                    break;
+                }
+            }
+        }
+        /* If host-drives usage is unique: */
+        if (!fIsHostDriveUsed)
+        {
+            QAction *pActionChooseHostDrive = menu.addAction(UIMedium(medium, mediumType).name(), pListener, pszSlotName);
+            pActionChooseHostDrive->setCheckable(true);
+            pActionChooseHostDrive->setChecked(!currentMedium.isNull() && medium.GetId() == strCurrentID);
+            pActionChooseHostDrive->setData(QVariant::fromValue(UIMediumTarget(strControllerName, currentAttachment.GetPort(),
+                                                                               currentAttachment.GetDevice(), medium.GetId())));
+        }
+    }
+
+
+    /* Get recent-medium list: */
+    QString strRecentMediumAddress;
+    switch (mediumType)
+    {
+        case UIMediumType_DVD: strRecentMediumAddress = GUI_RecentListCD; break;
+        case UIMediumType_Floppy: strRecentMediumAddress = GUI_RecentListFD; break;
+        default: break;
+    }
+    const QStringList recentMediumList = vboxGlobal().virtualBox().GetExtraData(strRecentMediumAddress).split(';');
+    /* Prepare choose-recent-medium actions: */
+    foreach (const QString &strRecentMediumLocationBase, recentMediumList)
+    {
+        /* Convert separators to native: */
+        const QString strRecentMediumLocation = QDir::toNativeSeparators(strRecentMediumLocationBase);
+        /* Confirm medium presence: */
+        if (!QFile::exists(strRecentMediumLocation))
+            continue;
+        /* Make sure recent-medium usage is unique: */
+        bool fIsRecentMediumUsed = false;
+        foreach (const CMediumAttachment &otherAttachment, attachments)
+        {
+            if (otherAttachment != currentAttachment)
+            {
+                const CMedium &otherMedium = otherAttachment.GetMedium();
+                if (!otherMedium.isNull() && otherMedium.GetLocation() == strRecentMediumLocation)
+                {
+                    fIsRecentMediumUsed = true;
+                    break;
+                }
+            }
+        }
+        /* If recent-medium usage is unique: */
+        if (!fIsRecentMediumUsed)
+        {
+            QAction *pActionChooseRecentMedium = menu.addAction(QFileInfo(strRecentMediumLocation).fileName(), pListener, pszSlotName);
+            pActionChooseRecentMedium->setCheckable(true);
+            pActionChooseRecentMedium->setChecked(!currentMedium.isNull() && strRecentMediumLocation == strCurrentLocation);
+            pActionChooseRecentMedium->setData(QVariant::fromValue(UIMediumTarget(strControllerName, currentAttachment.GetPort(),
+                                                                                  currentAttachment.GetDevice(), mediumType,
+                                                                                  strRecentMediumLocation)));
+            pActionChooseRecentMedium->setToolTip(strRecentMediumLocation);
+        }
+    }
+
+
+    /* Insert separator: */
+    menu.addSeparator();
+
+
+    /* Prepare unmount-current-medium action: */
+    QAction *pActionUnmountMedium = menu.addAction(QString(), pListener, pszSlotName);
+    pActionUnmountMedium->setEnabled(!currentMedium.isNull());
+    pActionUnmountMedium->setData(QVariant::fromValue(UIMediumTarget(strControllerName,
+                                                                     currentAttachment.GetPort(), currentAttachment.GetDevice())));
+
+
+    /* Switch CD/FD names/icons: */
+    switch (mediumType)
+    {
+        case UIMediumType_DVD:
+            pActionOpenExistingMedium->setText(QApplication::translate("UIMachineSettingsStorage", "Choose a virtual CD/DVD disk file..."));
+            pActionUnmountMedium->setText(QApplication::translate("UIMachineSettingsStorage", "Remove disk from virtual drive"));
+            pActionUnmountMedium->setIcon(UIIconPool::iconSet(":/cd_unmount_16px.png", ":/cd_unmount_dis_16px.png"));
+            break;
+        case UIMediumType_Floppy:
+            pActionOpenExistingMedium->setText(QApplication::translate("UIMachineSettingsStorage", "Choose a virtual floppy disk file..."));
+            pActionUnmountMedium->setText(QApplication::translate("UIMachineSettingsStorage", "Remove disk from virtual drive"));
+            pActionUnmountMedium->setIcon(UIIconPool::iconSet(":/fd_unmount_16px.png", ":/fd_unmount_dis_16px.png"));
+            break;
+        default:
+            break;
+    }
+}
+
+void VBoxGlobal::updateMachineStorage(const CMachine &constMachine, const UIMediumTarget &target)
+{
+    /* Mount (by default): */
+    bool fMount = true;
+    /* Null medium (by default): */
+    CMedium cmedium;
+    /* With null ID (by default): */
+    QString strActualID;
+
+    /* Current mount-target attributes: */
+    const CMediumAttachment currentAttachment = constMachine.GetMediumAttachment(target.name, target.port, target.device);
+    const CMedium currentMedium = currentAttachment.GetMedium();
+    const QString strCurrentID = currentMedium.isNull() ? QString() : currentMedium.GetId();
+
+    /* Which additional info do we have? */
+    switch (target.type)
+    {
+        /* Do we have an exact ID? */
+        case UIMediumTarget::UIMediumTargetType_WithID:
+        {
+            /* New mount-target attributes: */
+            QString strNewID;
+            const bool fSelectWithMediaManager = target.mediumType != UIMediumType_Invalid;
+
+            /* Invoke file-open dialog to choose medium ID: */
+            if (fSelectWithMediaManager)
+            {
+                /* Keyboard can be captured by machine-view.
+                 * So we should clear machine-view focus to let file-open dialog get it.
+                 * That way the keyboard will be released too.. */
+                QWidget *pLastFocusedWidget = 0;
+                if (QApplication::focusWidget())
+                {
+                    pLastFocusedWidget = QApplication::focusWidget();
+                    pLastFocusedWidget->clearFocus();
+                }
+                /* Call for file-open dialog: */
+                const QString strMachineFolder(QFileInfo(constMachine.GetSettingsFilePath()).absolutePath());
+                const QString strMediumID = vboxGlobal().openMediumWithFileOpenDialog(target.mediumType, activeMachineWindow(),
+                                                                                      strMachineFolder);
+                /* Return focus back: */
+                if (pLastFocusedWidget)
+                    pLastFocusedWidget->setFocus();
+                /* Accept new medium ID: */
+                if (!strMediumID.isNull())
+                    strNewID = strMediumID;
+                /* Else just exit: */
+                else return;
+            }
+            /* Use medium ID which was passed: */
+            else if (!target.data.isNull() && target.data != strCurrentID)
+                strNewID = target.data;
+
+            /* Should we mount or unmount? */
+            fMount = !strNewID.isEmpty();
+
+            /* Prepare target medium: */
+            const UIMedium uimedium = vboxGlobal().medium(strNewID);
+            cmedium = uimedium.medium();
+            strActualID = fMount ? strNewID : strCurrentID;
+            break;
+        }
+        /* Do we have a resent location? */
+        case UIMediumTarget::UIMediumTargetType_WithLocation:
+        {
+            /* Open medium by location and get new medium ID if any: */
+            const QString strNewID = vboxGlobal().openMedium(target.mediumType, target.data);
+            /* Else just exit: */
+            if (strNewID.isEmpty())
+                return;
+
+            /* Should we mount or unmount? */
+            fMount = strNewID != strCurrentID;
+
+            /* Prepare target medium: */
+            const UIMedium uimedium = fMount ? vboxGlobal().medium(strNewID) : UIMedium();
+            cmedium = fMount ? uimedium.medium() : CMedium();
+            strActualID = fMount ? strNewID : strCurrentID;
+            break;
+        }
+    }
+
+    /* Get editable machine: */
+    CSession session;
+    CMachine machine = constMachine;
+    KSessionState sessionState = machine.GetSessionState();
+    if (sessionState == KSessionState_Unlocked)
+    {
+        session = openSession(machine.GetId());
+        AssertReturnVoid(!session.isNull());
+        machine = session.GetMachine();
+    }
+
+    /* Remount medium to the predefined port/device: */
+    bool fWasMounted = false;
+    machine.MountMedium(target.name, target.port, target.device, cmedium, false /* force? */);
+    if (machine.isOk())
+        fWasMounted = true;
+    else
+    {
+        /* Ask for force remounting: */
+        if (msgCenter().cannotRemountMedium(machine, vboxGlobal().medium(strActualID),
+                                            fMount, true /* retry? */, activeMachineWindow()))
+        {
+            /* Force remount medium to the predefined port/device: */
+            machine.MountMedium(target.name, target.port, target.device, cmedium, true /* force? */);
+            if (machine.isOk())
+                fWasMounted = true;
+            else
+                msgCenter().cannotRemountMedium(machine, vboxGlobal().medium(strActualID),
+                                                fMount, false /* retry? */, activeMachineWindow());
+        }
+    }
+
+    /* Save settings: */
+    if (fWasMounted)
+    {
+        machine.SaveSettings();
+        if (!machine.isOk())
+            msgCenter().cannotSaveMachineSettings(machine, activeMachineWindow());
+    }
+
+    /* Close session to editable machine if necessary: */
+    if (!session.isNull())
+        session.UnlockMachine();
 }
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h	(revision 50863)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h	(revision 50864)
@@ -265,4 +265,17 @@
     UIMedium medium(const QString &strMediumID) const;
     QList<QString> mediumIDs() const;
+
+    /** Prepares storage menu according passed parameters.
+      * @param menu              QMenu being prepared.
+      * @param pListener         Listener QObject, this menu being prepared for.
+      * @param pszSlotName       SLOT in the @a pListener above, this menu will be handled with.
+      * @param machine           CMachine object, this menu being prepared for.
+      * @param strControllerName The name of the CStorageController in the @a machine above.
+      * @param storageSlot       The StorageSlot of the CStorageController called @a strControllerName above. */
+    void prepareStorageMenu(QMenu &menu,
+                            QObject *pListener, const char *pszSlotName,
+                            const CMachine &machine, const QString &strControllerName, const StorageSlot &storageSlot);
+    /** Updates @a constMachine storage with data described by @a target. */
+    void updateMachineStorage(const CMachine &constMachine, const UIMediumTarget &target);
 
     /* various helpers */
Index: /trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumDefs.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumDefs.h	(revision 50863)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumDefs.h	(revision 50864)
@@ -1,10 +1,8 @@
 /** @file
- *
- * VBox frontends: Qt GUI ("VirtualBox"):
- * UIMedium related declarations
+ * VBox Qt GUI - UIMedium related declarations.
  */
 
 /*
- * Copyright (C) 2006-2012 Oracle Corporation
+ * Copyright (C) 2006-2014 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -17,14 +15,14 @@
  */
 
-#ifndef __UIMediumDefs_h__
-#define __UIMediumDefs_h__
+#ifndef ___UIMediumDefs_h___
+#define ___UIMediumDefs_h___
 
 /* COM includes: */
 #include "COMEnums.h"
 
-/* UIMediumDefs namespace: */
+/** UIMediumDefs namespace. */
 namespace UIMediumDefs
 {
-    /* UIMedium types: */
+    /** UIMedium types. */
     enum UIMediumType
     {
@@ -36,17 +34,74 @@
     };
 
-    /* Convert global medium type (KDeviceType) to local (UIMediumType): */
+    /** Converts global medium type (KDeviceType) to local (UIMediumType). */
     UIMediumType mediumTypeToLocal(KDeviceType globalType);
 
-    /* Convert local medium type (UIMediumType) to global (KDeviceType): */
+    /** Convert local medium type (UIMediumType) to global (KDeviceType). */
     KDeviceType mediumTypeToGlobal(UIMediumType localType);
 }
-
 /* Using this namespace globally: */
 using namespace UIMediumDefs;
 
-/* Let QMetaType know about UIMediumType: */
+/** Medium-target. */
+struct UIMediumTarget
+{
+    /** Medium-target types. */
+    enum UIMediumTargetType { UIMediumTargetType_WithID, UIMediumTargetType_WithLocation };
+
+    /** Default medium-target constructor. */
+    UIMediumTarget()
+        : type(UIMediumTargetType_WithID)
+        , name(QString()), port(0), device(0), mediumType(UIMediumType_Invalid)
+        , data(QString())
+    {}
+
+    /** Unmount medium-target constructor. */
+    UIMediumTarget(const QString &strName, LONG iPort, LONG iDevice)
+        : type(UIMediumTargetType_WithID)
+        , name(strName), port(iPort), device(iDevice), mediumType(UIMediumType_Invalid)
+        , data(QString())
+    {}
+
+    /** Open medium-target constructor. */
+    UIMediumTarget(const QString &strName, LONG iPort, LONG iDevice, UIMediumType otherMediumType)
+        : type(UIMediumTargetType_WithID)
+        , name(strName), port(iPort), device(iDevice), mediumType(otherMediumType)
+        , data(QString())
+    {}
+
+    /** Predefined medium-target constructor. */
+    UIMediumTarget(const QString &strName, LONG iPort, LONG iDevice, const QString &strID)
+        : type(UIMediumTargetType_WithID)
+        , name(strName), port(iPort), device(iDevice), mediumType(UIMediumType_Invalid)
+        , data(strID)
+    {}
+
+    /** Recent medium-target constructor. */
+    UIMediumTarget(const QString &strName, LONG iPort, LONG iDevice, UIMediumType otherMediumType, const QString &strLocation)
+        : type(UIMediumTargetType_WithLocation)
+        , name(strName), port(iPort), device(iDevice), mediumType(otherMediumType)
+        , data(strLocation)
+    {}
+
+    /** Determines medium-target type. */
+    UIMediumTargetType type;
+
+    /** Determines controller name. */
+    QString name;
+    /** Determines controller port. */
+    LONG port;
+    /** Determines controller device. */
+    LONG device;
+
+    /** Determines medium-target medium-type. */
+    UIMediumType mediumType;
+
+    /** Depending on medium-target type holds <i>ID</i> or <i>location</i>. */
+    QString data;
+};
+
+/* Let QMetaType know about our types: */
 Q_DECLARE_METATYPE(UIMediumType);
+Q_DECLARE_METATYPE(UIMediumTarget);
 
-#endif /* __UIMediumDefs_h__ */
-
+#endif /* !___UIMediumDefs_h___ */
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp	(revision 50863)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp	(revision 50864)
@@ -97,34 +97,4 @@
 # include <QX11Info>
 #endif /* Q_WS_X11 */
-
-struct MediumTarget
-{
-    MediumTarget() : name(QString("")), port(0), device(0), id(QString()), type(UIMediumType_Invalid) {}
-    MediumTarget(const QString &strName, LONG iPort, LONG iDevice)
-        : name(strName), port(iPort), device(iDevice), id(QString()), type(UIMediumType_Invalid) {}
-    MediumTarget(const QString &strName, LONG iPort, LONG iDevice, const QString &strId)
-        : name(strName), port(iPort), device(iDevice), id(strId), type(UIMediumType_Invalid) {}
-    MediumTarget(const QString &strName, LONG iPort, LONG iDevice, UIMediumType eType)
-        : name(strName), port(iPort), device(iDevice), id(QString()), type(eType) {}
-    QString name;
-    LONG port;
-    LONG device;
-    QString id;
-    UIMediumType type;
-};
-Q_DECLARE_METATYPE(MediumTarget);
-
-struct RecentMediumTarget
-{
-    RecentMediumTarget() : name(QString("")), port(0), device(0), location(QString()), type(UIMediumType_Invalid) {}
-    RecentMediumTarget(const QString &strName, LONG iPort, LONG iDevice, const QString &strLocation, UIMediumType eType)
-        : name(strName), port(iPort), device(iDevice), location(strLocation), type(eType) {}
-    QString name;
-    LONG port;
-    LONG device;
-    QString location;
-    UIMediumType type;
-};
-Q_DECLARE_METATYPE(RecentMediumTarget);
 
 struct USBTarget
@@ -1542,177 +1512,51 @@
     pMenu->clear();
 
-    /* Short way to common storage menus: */
-    QMenu *pOpticalDevicesMenu = gActionPool->action(UIActionIndexRuntime_Menu_OpticalDevices)->menu();
-    QMenu *pFloppyDevicesMenu = gActionPool->action(UIActionIndexRuntime_Menu_FloppyDevices)->menu();
-
-    /* Determine medium & device types: */
-    UIMediumType mediumType = pMenu == pOpticalDevicesMenu ? UIMediumType_DVD :
-                                      pMenu == pFloppyDevicesMenu  ? UIMediumType_Floppy :
-                                                                     UIMediumType_Invalid;
-    KDeviceType deviceType = mediumTypeToGlobal(mediumType);
-    AssertMsg(mediumType != UIMediumType_Invalid, ("Incorrect storage medium type!\n"));
-    AssertMsg(deviceType != KDeviceType_Null, ("Incorrect storage device type!\n"));
-
-    /* Fill attachments menu: */
-    const CMachine &machine = session().GetMachine();
-    const CMediumAttachmentVector &attachments = machine.GetMediumAttachments();
-    for (int iAttachmentIndex = 0; iAttachmentIndex < attachments.size(); ++iAttachmentIndex)
-    {
-        /* Current attachment: */
-        const CMediumAttachment &attachment = attachments[iAttachmentIndex];
+    /* Determine device-type: */
+    const QMenu *pOpticalDevicesMenu = gActionPool->action(UIActionIndexRuntime_Menu_OpticalDevices)->menu();
+    const QMenu *pFloppyDevicesMenu = gActionPool->action(UIActionIndexRuntime_Menu_FloppyDevices)->menu();
+    const KDeviceType deviceType = pMenu == pOpticalDevicesMenu ? KDeviceType_DVD :
+                                   pMenu == pFloppyDevicesMenu  ? KDeviceType_Floppy :
+                                                                  KDeviceType_Null;
+    AssertMsgReturnVoid(deviceType != KDeviceType_Null, ("Incorrect storage device-type!\n"));
+
+    /* Prepare/fill all storage menus: */
+    const CMachine machine = session().GetMachine();
+    foreach (const CMediumAttachment &attachment, machine.GetMediumAttachments())
+    {
         /* Current controller: */
-        const CStorageController &controller = machine.GetStorageControllerByName(attachment.GetController());
-        /* If controller present and device type correct: */
-        if (!controller.isNull() && (attachment.GetType() == deviceType))
+        const CStorageController controller = machine.GetStorageControllerByName(attachment.GetController());
+        /* If controller present and device-type correct: */
+        if (!controller.isNull() && attachment.GetType() == deviceType)
         {
-            /* Current attachment attributes: */
-            const CMedium &currentMedium = attachment.GetMedium();
-            QString strCurrentId = currentMedium.isNull() ? QString::null : currentMedium.GetId();
-            QString strCurrentLocation = currentMedium.isNull() ? QString::null : currentMedium.GetLocation();
-
-            /* Attachment menu item: */
-            QMenu *pAttachmentMenu = 0;
+            /* Current controller/attachment attributes: */
+            const QString strControllerName = controller.GetName();
+            const StorageSlot storageSlot(controller.GetBus(), attachment.GetPort(), attachment.GetDevice());
+
+            /* Prepare current storage menu: */
+            QMenu *pStorageMenu = 0;
+            /* If it will be more than one storage menu: */
             if (pMenu->menuAction()->data().toInt() > 1)
             {
-                pAttachmentMenu = new QMenu(pMenu);
-                pAttachmentMenu->setTitle(QString("%1 (%2)").arg(controller.GetName())
-                                          .arg(gpConverter->toString(StorageSlot(controller.GetBus(),
-                                                                                 attachment.GetPort(),
-                                                                                 attachment.GetDevice()))));
+                /* We have to create sub-menu for each of them: */
+                pStorageMenu = new QMenu(QString("%1 (%2)").arg(strControllerName).arg(gpConverter->toString(storageSlot)), pMenu);
                 switch (controller.GetBus())
                 {
-                    case KStorageBus_IDE:
-                        pAttachmentMenu->setIcon(QIcon(":/ide_16px.png")); break;
-                    case KStorageBus_SATA:
-                        pAttachmentMenu->setIcon(QIcon(":/sata_16px.png")); break;
-                    case KStorageBus_SCSI:
-                        pAttachmentMenu->setIcon(QIcon(":/scsi_16px.png")); break;
-                    case KStorageBus_Floppy:
-                        pAttachmentMenu->setIcon(QIcon(":/floppy_16px.png")); break;
-                    default:
-                        break;
+                    case KStorageBus_IDE:    pStorageMenu->setIcon(QIcon(":/ide_16px.png")); break;
+                    case KStorageBus_SATA:   pStorageMenu->setIcon(QIcon(":/sata_16px.png")); break;
+                    case KStorageBus_SCSI:   pStorageMenu->setIcon(QIcon(":/scsi_16px.png")); break;
+                    case KStorageBus_Floppy: pStorageMenu->setIcon(QIcon(":/floppy_16px.png")); break;
+                    case KStorageBus_SAS:    pStorageMenu->setIcon(QIcon(":/sata_16px.png")); break;
+                    case KStorageBus_USB:    pStorageMenu->setIcon(QIcon(":/usb_16px.png")); break;
+                    default: break;
                 }
-                pMenu->addMenu(pAttachmentMenu);
+                pMenu->addMenu(pStorageMenu);
             }
-            else pAttachmentMenu = pMenu;
-
-            /* Prepare choose-existing-medium action: */
-            QAction *pChooseExistingMediumAction = pAttachmentMenu->addAction(QIcon(":/select_file_16px.png"), QString(),
-                                                                              this, SLOT(sltMountStorageMedium()));
-            pChooseExistingMediumAction->setData(QVariant::fromValue(MediumTarget(controller.GetName(), attachment.GetPort(),
-                                                                                  attachment.GetDevice(), mediumType)));
-
-            /* Prepare choose-particular-medium actions: */
-            CMediumVector mediums;
-            QString strRecentMediumAddress;
-            switch (mediumType)
-            {
-                case UIMediumType_DVD:
-                    mediums = vboxGlobal().host().GetDVDDrives();
-                    strRecentMediumAddress = GUI_RecentListCD;
-                    break;
-                case UIMediumType_Floppy:
-                    mediums = vboxGlobal().host().GetFloppyDrives();
-                    strRecentMediumAddress = GUI_RecentListFD;
-                    break;
-                default:
-                    break;
-            }
-
-            /* Prepare choose-host-drive actions: */
-            for (int iHostDriveIndex = 0; iHostDriveIndex < mediums.size(); ++iHostDriveIndex)
-            {
-                const CMedium &medium = mediums[iHostDriveIndex];
-                bool fIsHostDriveUsed = false;
-                for (int iOtherAttachmentIndex = 0; iOtherAttachmentIndex < attachments.size(); ++iOtherAttachmentIndex)
-                {
-                    const CMediumAttachment &otherAttachment = attachments[iOtherAttachmentIndex];
-                    if (otherAttachment != attachment)
-                    {
-                        const CMedium &otherMedium = otherAttachment.GetMedium();
-                        if (!otherMedium.isNull() && otherMedium.GetId() == medium.GetId())
-                        {
-                            fIsHostDriveUsed = true;
-                            break;
-                        }
-                    }
-                }
-                if (!fIsHostDriveUsed)
-                {
-                    QAction *pChooseHostDriveAction = pAttachmentMenu->addAction(UIMedium(medium, mediumType).name(),
-                                                                                 this, SLOT(sltMountStorageMedium()));
-                    pChooseHostDriveAction->setCheckable(true);
-                    pChooseHostDriveAction->setChecked(!currentMedium.isNull() && medium.GetId() == strCurrentId);
-                    pChooseHostDriveAction->setData(QVariant::fromValue(MediumTarget(controller.GetName(), attachment.GetPort(),
-                                                                                     attachment.GetDevice(), medium.GetId())));
-                }
-            }
-
-            /* Prepare choose-recent-medium actions: */
-            QStringList recentMediumList = vboxGlobal().virtualBox().GetExtraData(strRecentMediumAddress).split(';');
-            /* For every list-item: */
-            for (int i = 0; i < recentMediumList.size(); ++i)
-            {
-                QString strRecentMediumLocation = QDir::toNativeSeparators(recentMediumList[i]);
-                if (QFile::exists(strRecentMediumLocation))
-                {
-                    bool fIsRecentMediumUsed = false;
-                    for (int iOtherAttachmentIndex = 0; iOtherAttachmentIndex < attachments.size(); ++iOtherAttachmentIndex)
-                    {
-                        const CMediumAttachment &otherAttachment = attachments[iOtherAttachmentIndex];
-                        if (otherAttachment != attachment)
-                        {
-                            const CMedium &otherMedium = otherAttachment.GetMedium();
-                            if (!otherMedium.isNull() && otherMedium.GetLocation() == strRecentMediumLocation)
-                            {
-                                fIsRecentMediumUsed = true;
-                                break;
-                            }
-                        }
-                    }
-                    if (!fIsRecentMediumUsed)
-                    {
-                        QAction *pChooseRecentMediumAction = pAttachmentMenu->addAction(QFileInfo(strRecentMediumLocation).fileName(),
-                                                                                        this, SLOT(sltMountRecentStorageMedium()));
-                        pChooseRecentMediumAction->setCheckable(true);
-                        pChooseRecentMediumAction->setChecked(!currentMedium.isNull() && strRecentMediumLocation == strCurrentLocation);
-                        pChooseRecentMediumAction->setData(QVariant::fromValue(RecentMediumTarget(controller.GetName(), attachment.GetPort(),
-                                                                                                  attachment.GetDevice(), strRecentMediumLocation, mediumType)));
-                        pChooseRecentMediumAction->setToolTip(strRecentMediumLocation);
-
-                    }
-                }
-            }
-
-            /* Insert separator: */
-            pAttachmentMenu->addSeparator();
-
-            /* Unmount Medium action: */
-            QAction *unmountMediumAction = new QAction(pAttachmentMenu);
-            unmountMediumAction->setEnabled(!currentMedium.isNull());
-            unmountMediumAction->setData(QVariant::fromValue(MediumTarget(controller.GetName(),
-                                                                          attachment.GetPort(),
-                                                                          attachment.GetDevice())));
-            connect(unmountMediumAction, SIGNAL(triggered(bool)), this, SLOT(sltMountStorageMedium()));
-            pAttachmentMenu->addAction(unmountMediumAction);
-
-            /* Switch CD/FD naming */
-            switch (mediumType)
-            {
-                case UIMediumType_DVD:
-                    pChooseExistingMediumAction->setText(QApplication::translate("UIMachineSettingsStorage", "Choose a virtual CD/DVD disk file..."));
-                    unmountMediumAction->setText(QApplication::translate("UIMachineSettingsStorage", "Remove disk from virtual drive"));
-                    unmountMediumAction->setIcon(UIIconPool::iconSet(":/cd_unmount_16px.png",
-                                                                     ":/cd_unmount_dis_16px.png"));
-                    break;
-                case UIMediumType_Floppy:
-                    pChooseExistingMediumAction->setText(QApplication::translate("UIMachineSettingsStorage", "Choose a virtual floppy disk file..."));
-                    unmountMediumAction->setText(QApplication::translate("UIMachineSettingsStorage", "Remove disk from virtual drive"));
-                    unmountMediumAction->setIcon(UIIconPool::iconSet(":/fd_unmount_16px.png",
-                                                                     ":/fd_unmount_dis_16px.png"));
-                    break;
-                default:
-                    break;
-            }
+            /* Otherwise just use existing one: */
+            else pStorageMenu = pMenu;
+
+            /* Fill current storage menu: */
+            vboxGlobal().prepareStorageMenu(*pStorageMenu,
+                                            this, SLOT(sltMountStorageMedium()),
+                                            machine, strControllerName, storageSlot);
         }
     }
@@ -1721,148 +1565,15 @@
 void UIMachineLogic::sltMountStorageMedium()
 {
-    /* Get sender action: */
-    QAction *action = qobject_cast<QAction*>(sender());
-    AssertMsg(action, ("This slot should only be called on selecting storage menu item!\n"));
-
-    /* Get current machine: */
-    CMachine machine = session().GetMachine();
-
-    /* Get mount-target: */
-    MediumTarget target = action->data().value<MediumTarget>();
-
-    /* Current mount-target attributes: */
-    CMediumAttachment currentAttachment = machine.GetMediumAttachment(target.name, target.port, target.device);
-    CMedium currentMedium = currentAttachment.GetMedium();
-    QString currentId = currentMedium.isNull() ? QString("") : currentMedium.GetId();
-
-    /* New mount-target attributes: */
-    QString newId = QString("");
-    bool fSelectWithMediaManager = target.type != UIMediumType_Invalid;
-
-    /* Open Virtual Media Manager to select image id: */
-    if (fSelectWithMediaManager)
-    {
-        /* Search for already used images: */
-        QStringList usedImages;
-        foreach (const CMediumAttachment &attachment, machine.GetMediumAttachments())
-        {
-            CMedium medium = attachment.GetMedium();
-            if (attachment != currentAttachment && !medium.isNull() && !medium.GetHostDrive())
-                usedImages << medium.GetId();
-        }
-        /* To that moment application focus already returned to machine-view,
-         * so the keyboard already captured too.
-         * We should clear application focus from machine-view now
-         * to let file-open dialog get it. That way the keyboard will be released too: */
-        if (QApplication::focusWidget())
-            QApplication::focusWidget()->clearFocus();
-        /* Call for file-open window: */
-        QString strMachineFolder(QFileInfo(machine.GetSettingsFilePath()).absolutePath());
-        QString strMediumId = vboxGlobal().openMediumWithFileOpenDialog(target.type, activeMachineWindow(),
-                                                                        strMachineFolder);
-        activeMachineWindow()->machineView()->setFocus();
-        if (!strMediumId.isNull())
-            newId = strMediumId;
-        else return;
-    }
-    /* Use medium which was sent: */
-    else if (!target.id.isNull() && target.id != currentId)
-        newId = target.id;
-
-    bool fMount = !newId.isEmpty();
-
-    UIMedium vmedium = vboxGlobal().medium(newId);
-    CMedium medium = vmedium.medium();              // @todo r=dj can this be cached somewhere?
-
-    /* Remount medium to the predefined port/device: */
-    bool fWasMounted = false;
-    machine.MountMedium(target.name, target.port, target.device, medium, false /* force */);
-    if (machine.isOk())
-        fWasMounted = true;
-    else
-    {
-        /* Ask for force remounting: */
-        if (msgCenter().cannotRemountMedium(machine, vboxGlobal().medium(fMount ? newId : currentId),
-                                            fMount, true /* retry? */, activeMachineWindow()))
-        {
-            /* Force remount medium to the predefined port/device: */
-            machine.MountMedium(target.name, target.port, target.device, medium, true /* force */);
-            if (machine.isOk())
-                fWasMounted = true;
-            else
-                msgCenter().cannotRemountMedium(machine, vboxGlobal().medium(fMount ? newId : currentId),
-                                                fMount, false /* retry? */, activeMachineWindow());
-        }
-    }
-
-    /* Save medium mounted at runtime */
-    if (fWasMounted && !uisession()->isIgnoreRuntimeMediumsChanging())
-    {
-        machine.SaveSettings();
-        if (!machine.isOk())
-            msgCenter().cannotSaveMachineSettings(machine, activeMachineWindow());
-    }
-}
-
-void UIMachineLogic::sltMountRecentStorageMedium()
-{
-    /* Get sender action: */
-    QAction *pSender = qobject_cast<QAction*>(sender());
-    AssertMsg(pSender, ("This slot should only be called on selecting storage menu item!\n"));
-
-    /* Get mount-target: */
-    RecentMediumTarget target = pSender->data().value<RecentMediumTarget>();
-
-    /* Get new medium id: */
-    QString strNewId = vboxGlobal().openMedium(target.type, target.location);
-
-    if (!strNewId.isEmpty())
-    {
-        /* Get current machine: */
-        CMachine machine = session().GetMachine();
-
-        /* Get current medium id: */
-        const CMediumAttachment &currentAttachment = machine.GetMediumAttachment(target.name, target.port, target.device);
-        CMedium currentMedium = currentAttachment.GetMedium();
-        QString strCurrentId = currentMedium.isNull() ? QString("") : currentMedium.GetId();
-
-        /* Should we mount or unmount? */
-        bool fMount = strNewId != strCurrentId;
-
-        /* Prepare target medium: */
-        const UIMedium &vboxMedium = fMount ? vboxGlobal().medium(strNewId) : UIMedium();
-        const CMedium &comMedium = fMount ? vboxMedium.medium() : CMedium();
-
-        /* 'Mounted' flag: */
-        bool fWasMounted = false;
-
-        /* Try to mount medium to the predefined port/device: */
-        machine.MountMedium(target.name, target.port, target.device, comMedium, false /* force? */);
-        if (machine.isOk())
-            fWasMounted = true;
-        else
-        {
-            /* Ask for force remounting: */
-            if (msgCenter().cannotRemountMedium(machine, vboxGlobal().medium(fMount ? strNewId : strCurrentId),
-                                                fMount, true /* retry? */, activeMachineWindow()))
-            {
-                /* Force remount medium to the predefined port/device: */
-                machine.MountMedium(target.name, target.port, target.device, comMedium, true /* force? */);
-                if (machine.isOk())
-                    fWasMounted = true;
-                else
-                    msgCenter().cannotRemountMedium(machine, vboxGlobal().medium(fMount ? strNewId : strCurrentId),
-                                                    fMount, false /* retry? */, activeMachineWindow());
-            }
-        }
-
-        /* Save medium mounted at runtime if necessary: */
-        if (fWasMounted && !uisession()->isIgnoreRuntimeMediumsChanging())
-        {
-            machine.SaveSettings();
-            if (!machine.isOk())
-                msgCenter().cannotSaveMachineSettings(machine, activeMachineWindow());
-        }
-    }
+    /* Sender action: */
+    QAction *pAction = qobject_cast<QAction*>(sender());
+    AssertMsgReturnVoid(pAction, ("This slot should only be called by menu action!\n"));
+
+    /* Current machine: */
+    const CMachine machine = session().GetMachine();
+    /* Current mount-target: */
+    const UIMediumTarget target = pAction->data().value<UIMediumTarget>();
+
+    /* Update current machine mount-target: */
+    vboxGlobal().updateMachineStorage(machine, target);
 }
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h	(revision 50863)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h	(revision 50864)
@@ -213,5 +213,4 @@
     void sltPrepareStorageMenu();
     void sltMountStorageMedium();
-    void sltMountRecentStorageMedium();
     void sltPrepareUSBMenu();
     void sltPrepareWebCamMenu();
