Index: trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp	(revision 78270)
+++ trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp	(revision 78271)
@@ -120,5 +120,7 @@
     }
 
-    return configureVM(strTypeId, type);
+    if (configureVM(strTypeId, type))
+        return attachDefaultDevices(type);
+    return false;
 }
 
@@ -268,62 +270,79 @@
         return false;
     }
-
-    /* Attach default devices: */
-    {
-        bool success = false;
-        QUuid uMachineId = m_machine.GetId();
-        CSession session = vboxGlobal().openSession(uMachineId);
-        if (!session.isNull())
-        {
-            CMachine machine = session.GetMachine();
-
-            QUuid uId = field("virtualDiskId").toUuid();
-            /* Boot virtual hard drive: */
-            if (!uId.isNull())
+    return true;
+}
+
+bool UIWizardNewVM::attachDefaultDevices(const CGuestOSType &comGuestType)
+{
+    bool success = false;
+    QUuid uMachineId = m_machine.GetId();
+    CSession session = vboxGlobal().openSession(uMachineId);
+    if (!session.isNull())
+    {
+        CMachine machine = session.GetMachine();
+
+        QUuid uId = field("virtualDiskId").toUuid();
+        /* Boot virtual hard drive: */
+        if (!uId.isNull())
+        {
+            KStorageBus enmHDDBus = comGuestType.GetRecommendedHDStorageBus();
+            CStorageController comHDDController = m_machine.GetStorageControllerByInstance(enmHDDBus, 0);
+            if (!comHDDController.isNull())
             {
                 UIMedium vmedium = vboxGlobal().medium(uId);
                 CMedium medium = vmedium.medium();              /// @todo r=dj can this be cached somewhere?
-                machine.AttachDevice(strHDName, 0, 0, KDeviceType_HardDisk, medium);
+                machine.AttachDevice(comHDDController.GetName(), 0, 0, KDeviceType_HardDisk, medium);
                 if (!machine.isOk())
                     msgCenter().cannotAttachDevice(machine, UIMediumDeviceType_HardDisk, field("virtualDiskLocation").toString(),
-                                                   StorageSlot(ctrHDBus, 0, 0), this);
+                                                   StorageSlot(enmHDDBus, 0, 0), this);
             }
-
-            /* Attach empty optical drive: */
-            machine.AttachDevice(strDVDName, 1, 0, KDeviceType_DVD, CMedium());
+        }
+
+        /* Attach empty optical drive: */
+        KStorageBus enmDVDBus = comGuestType.GetRecommendedDVDStorageBus();
+        CStorageController comDVDController = m_machine.GetStorageControllerByInstance(enmDVDBus, 0);
+        if (!comDVDController.isNull())
+        {
+            machine.AttachDevice(comDVDController.GetName(), 1, 0, KDeviceType_DVD, CMedium());
             if (!machine.isOk())
-                msgCenter().cannotAttachDevice(machine, UIMediumDeviceType_DVD, QString(), StorageSlot(strDVDBus, 1, 0), this);
-
-
-            /* Attach an empty floppy drive if recommended */
-            if (comGuestType.GetRecommendedFloppy()) {
-                machine.AttachDevice(strFloppyName, 0, 0, KDeviceType_Floppy, CMedium());
+                msgCenter().cannotAttachDevice(machine, UIMediumDeviceType_DVD, QString(),
+                                               StorageSlot(enmDVDBus, 1, 0), this);
+
+        }
+
+        /* Attach an empty floppy drive if recommended */
+        if (comGuestType.GetRecommendedFloppy()) {
+            CStorageController comFloppyController = m_machine.GetStorageControllerByInstance(KStorageBus_Floppy, 0);
+            if (!comFloppyController.isNull())
+            {
+                machine.AttachDevice(comFloppyController.GetName(), 0, 0, KDeviceType_Floppy, CMedium());
                 if (!machine.isOk())
                     msgCenter().cannotAttachDevice(machine, UIMediumDeviceType_Floppy, QString(),
                                                    StorageSlot(KStorageBus_Floppy, 0, 0), this);
             }
-
+        }
+
+        if (machine.isOk())
+        {
+            machine.SaveSettings();
             if (machine.isOk())
-            {
-                machine.SaveSettings();
-                if (machine.isOk())
-                    success = true;
-                else
-                    msgCenter().cannotSaveMachineSettings(machine, this);
-            }
-
-            session.UnlockMachine();
-        }
-        if (!success)
-        {
-            /* Unregister on failure */
-            QVector<CMedium> aMedia = m_machine.Unregister(KCleanupMode_UnregisterOnly);   /// @todo replace with DetachAllReturnHardDisksOnly once a progress dialog is in place below
-            if (vbox.isOk())
-            {
-                CProgress progress = m_machine.DeleteConfig(aMedia);
-                progress.WaitForCompletion(-1);         /// @todo do this nicely with a progress dialog, this can delete lots of files
-            }
-            return false;
-        }
+                success = true;
+            else
+                msgCenter().cannotSaveMachineSettings(machine, this);
+        }
+
+        session.UnlockMachine();
+    }
+    if (!success)
+    {
+        CVirtualBox vbox = vboxGlobal().virtualBox();
+        /* Unregister on failure */
+        QVector<CMedium> aMedia = m_machine.Unregister(KCleanupMode_UnregisterOnly);   /// @todo replace with DetachAllReturnHardDisksOnly once a progress dialog is in place below
+        if (vbox.isOk())
+        {
+            CProgress progress = m_machine.DeleteConfig(aMedia);
+            progress.WaitForCompletion(-1);         /// @todo do this nicely with a progress dialog, this can delete lots of files
+        }
+        return false;
     }
 
Index: trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.h	(revision 78270)
+++ trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.h	(revision 78271)
@@ -61,8 +61,10 @@
 protected:
 
-    /* Create a new VM: */
+    /* Creates a new VM: */
     bool createVM();
-    /* Configure the newly created VM: */
+    /* Configures the newly created VM: */
     bool configureVM(const QString &strGuestTypeId, const CGuestOSType &comGuestType);
+    /* Attaches default devices: */
+    bool attachDefaultDevices(const CGuestOSType &comGuestType);
 
     /* Who will be able to create virtual-machine: */
