Index: /trunk/src/VBox/Main/ConsoleImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/ConsoleImpl.cpp	(revision 24578)
+++ /trunk/src/VBox/Main/ConsoleImpl.cpp	(revision 24579)
@@ -2696,5 +2696,6 @@
 
 
-const char *Console::controllerTypeToDev(StorageControllerType_T enmCtrlType)
+/* static */
+const char *Console::convertControllerTypeToDev(StorageControllerType_T enmCtrlType)
 {
     switch (enmCtrlType)
@@ -2792,5 +2793,5 @@
     rc = ctrl->COMGETTER(ControllerType)(&enmCtrlType);
     AssertComRC(rc);
-    pszDevice = controllerTypeToDev(enmCtrlType);
+    pszDevice = convertControllerTypeToDev(enmCtrlType);
 
     /** @todo support multiple instances of a controller */
@@ -7000,19 +7001,21 @@
 
 /**
- * Reconfigures a VDI.
+ * Reconfigures a medium attachment (part of taking an online snapshot).
  *
  * @param   pVM           The VM handle.
  * @param   lInstance     The instance of the controller.
  * @param   enmController The type of the controller.
- * @param   hda           The harddisk attachment.
+ * @param   enmBus        The storage bus type of the controller.
+ * @param   aMediumAtt    The medium attachment.
  * @param   phrc          Where to store com error - only valid if we return VERR_GENERAL_FAILURE.
  * @return  VBox status code.
  */
-static DECLCALLBACK(int) reconfigureHardDisks(PVM pVM, ULONG lInstance,
-                                              StorageControllerType_T enmController,
-                                              IMediumAttachment *hda,
-                                              HRESULT *phrc)
-{
-    LogFlowFunc(("pVM=%p hda=%p phrc=%p\n", pVM, hda, phrc));
+static DECLCALLBACK(int) reconfigureMedium(PVM pVM, ULONG lInstance,
+                                           StorageControllerType_T enmController,
+                                           StorageBus_T enmBus,
+                                           IMediumAttachment *aMediumAtt,
+                                           HRESULT *phrc)
+{
+    LogFlowFunc(("pVM=%p aMediumAtt=%p phrc=%p\n", pVM, aMediumAtt, phrc));
 
     int             rc;
@@ -7024,65 +7027,24 @@
 
     /*
-     * Figure out which IDE device this is.
+     * Figure out medium and other attachment details.
      */
-    ComPtr<IMedium> hardDisk;
-    hrc = hda->COMGETTER(Medium)(hardDisk.asOutParam());                      H();
+    ComPtr<IMedium> medium;
+    hrc = aMediumAtt->COMGETTER(Medium)(medium.asOutParam());                   H();
     LONG lDev;
-    hrc = hda->COMGETTER(Device)(&lDev);                                        H();
+    hrc = aMediumAtt->COMGETTER(Device)(&lDev);                                 H();
     LONG lPort;
-    hrc = hda->COMGETTER(Port)(&lPort);                                         H();
-
-    int         iLUN;
-    const char *pcszDevice = NULL;
-    bool        fSCSI = false;
-
-    switch (enmController)
-    {
-        case StorageControllerType_PIIX3:
-        case StorageControllerType_PIIX4:
-        case StorageControllerType_ICH6:
-        {
-            if (lPort >= 2 || lPort < 0)
-            {
-                AssertMsgFailed(("invalid controller channel number: %d\n", lPort));
-                return VERR_GENERAL_FAILURE;
-            }
-
-            if (lDev >= 2 || lDev < 0)
-            {
-                AssertMsgFailed(("invalid controller device number: %d\n", lDev));
-                return VERR_GENERAL_FAILURE;
-            }
-
-            iLUN = 2*lPort + lDev;
-            pcszDevice = "piix3ide";
-            break;
-        }
-        case StorageControllerType_IntelAhci:
-        {
-            iLUN = lPort;
-            pcszDevice = "ahci";
-            break;
-        }
-        case StorageControllerType_BusLogic:
-        {
-            iLUN = lPort;
-            pcszDevice = "buslogic";
-            fSCSI = true;
-            break;
-        }
-        case StorageControllerType_LsiLogic:
-        {
-            iLUN = lPort;
-            pcszDevice = "lsilogicscsi";
-            fSCSI = true;
-            break;
-        }
-        default:
-        {
-            AssertMsgFailed(("invalid disk controller type: %d\n", enmController));
-            return VERR_GENERAL_FAILURE;
-        }
-    }
+    hrc = aMediumAtt->COMGETTER(Port)(&lPort);                                  H();
+    DeviceType_T lType;
+    hrc = aMediumAtt->COMGETTER(Type)(&lType);                                  H();
+
+    unsigned iLUN;
+    const char *pcszDevice = Console::convertControllerTypeToDev(enmController);
+    AssertMsgReturn(pcszDevice, ("invalid disk controller type: %d\n", enmController), VERR_GENERAL_FAILURE);
+    hrc = Console::convertBusPortDeviceToLun(enmBus, lPort, lDev, iLUN);        H();
+
+    /* Ignore attachments other than hard disks, since at the moment they are
+     * not subject to snapshotting in general. */
+    if (lType != DeviceType_HardDisk || medium.isNull())
+        return VINF_SUCCESS;
 
     /** @todo this should be unified with the relevant part of
@@ -7091,5 +7053,4 @@
     /*
      * Is there an existing LUN? If not create it.
-     * We ASSUME that this will NEVER collide with the DVD.
      */
     PCFGMNODE pCfg;
@@ -7097,8 +7058,8 @@
 
     /* SCSI has an extra driver between the device and the block driver. */
-    if (fSCSI)
-        pLunL1 = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/%u/LUN#%d/AttachedDriver/AttachedDriver/", pcszDevice, lInstance, iLUN);
+    if (enmBus == StorageBus_SCSI)
+        pLunL1 = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/%u/LUN#%u/AttachedDriver/AttachedDriver/", pcszDevice, lInstance, iLUN);
     else
-        pLunL1 = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/%u/LUN#%d/AttachedDriver/", pcszDevice, lInstance, iLUN);
+        pLunL1 = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/%u/LUN#%u/AttachedDriver/", pcszDevice, lInstance, iLUN);
 
     if (!pLunL1)
@@ -7108,7 +7069,7 @@
 
         PCFGMNODE pLunL0;
-        rc = CFGMR3InsertNodeF(pInst, &pLunL0, "LUN#%d", iLUN);                     RC_CHECK();
-
-        if (fSCSI)
+        rc = CFGMR3InsertNodeF(pInst, &pLunL0, "LUN#%u", iLUN);                     RC_CHECK();
+
+        if (enmBus == StorageBus_SCSI)
         {
             rc = CFGMR3InsertString(pLunL0, "Driver",              "SCSI");             RC_CHECK();
@@ -7155,9 +7116,9 @@
      * Create the driver configuration.
      */
-    hrc = hardDisk->COMGETTER(Location)(bstr.asOutParam());                     H();
-    LogFlowFunc(("LUN#%d: leaf location '%ls'\n", iLUN, bstr.raw()));
+    hrc = medium->COMGETTER(Location)(bstr.asOutParam());                       H();
+    LogFlowFunc(("LUN#%u: leaf location '%ls'\n", iLUN, bstr.raw()));
     rc = CFGMR3InsertString(pCfg, "Path", Utf8Str(bstr).c_str());                       RC_CHECK();
-    hrc = hardDisk->COMGETTER(Format)(bstr.asOutParam());                       H();
-    LogFlowFunc(("LUN#%d: leaf format '%ls'\n", iLUN, bstr.raw()));
+    hrc = medium->COMGETTER(Format)(bstr.asOutParam());                         H();
+    LogFlowFunc(("LUN#%u: leaf format '%ls'\n", iLUN, bstr.raw()));
     rc = CFGMR3InsertString(pCfg, "Format", Utf8Str(bstr).c_str());                     RC_CHECK();
 
@@ -7166,7 +7127,7 @@
     SafeArray<BSTR> names;
     SafeArray<BSTR> values;
-    hrc = hardDisk->GetProperties(NULL,
-                                  ComSafeArrayAsOutParam(names),
-                                  ComSafeArrayAsOutParam(values));      H();
+    hrc = medium->GetProperties(NULL,
+                                ComSafeArrayAsOutParam(names),
+                                ComSafeArrayAsOutParam(values));        H();
 
     if (names.size() != 0)
@@ -7189,17 +7150,17 @@
 
     /* Create an inversed tree of parents. */
-    ComPtr<IMedium> parentHardDisk = hardDisk;
+    ComPtr<IMedium> parentMedium = medium;
     for (PCFGMNODE pParent = pCfg;;)
     {
-        hrc = parentHardDisk->COMGETTER(Parent)(hardDisk.asOutParam());     H();
-        if (hardDisk.isNull())
+        hrc = parentMedium->COMGETTER(Parent)(medium.asOutParam());             H();
+        if (medium.isNull())
             break;
 
         PCFGMNODE pCur;
         rc = CFGMR3InsertNode(pParent, "Parent", &pCur);                        RC_CHECK();
-        hrc = hardDisk->COMGETTER(Location)(bstr.asOutParam());                 H();
+        hrc = medium->COMGETTER(Location)(bstr.asOutParam());                   H();
         rc = CFGMR3InsertString(pCur,  "Path", Utf8Str(bstr).c_str());          RC_CHECK();
 
-        hrc = hardDisk->COMGETTER(Format)(bstr.asOutParam());                   H();
+        hrc = medium->COMGETTER(Format)(bstr.asOutParam());                     H();
         rc = CFGMR3InsertString(pCur,  "Format", Utf8Str(bstr).c_str());        RC_CHECK();
 
@@ -7207,7 +7168,7 @@
         SafeArray<BSTR> names;
         SafeArray<BSTR> values;
-        hrc = hardDisk->GetProperties(NULL,
-                                      ComSafeArrayAsOutParam(names),
-                                      ComSafeArrayAsOutParam(values));  H();
+        hrc = medium->GetProperties(NULL,
+                                    ComSafeArrayAsOutParam(names),
+                                    ComSafeArrayAsOutParam(values));            H();
 
         if (names.size() != 0)
@@ -7229,5 +7190,4 @@
         }
 
-
         /* Custom code: put marker to not use host IP stack to driver
         * configuration node. Simplifies life of DrvVD a bit. */
@@ -7240,5 +7200,5 @@
         /* next */
         pParent = pCur;
-        parentHardDisk = hardDisk;
+        parentMedium = medium;
     }
 
@@ -7337,5 +7297,5 @@
             LogFlowFunc(("Reattaching new differencing hard disks...\n"));
 
-            pTask->mProgress->SetNextOperation(Bstr(tr("Reconfiguring hard disks")),
+            pTask->mProgress->SetNextOperation(Bstr(tr("Reconfiguring medium attachments")),
                                                1);       // operation weight, same as computed when setting up progress object
 
@@ -7352,4 +7312,5 @@
                 ULONG lInstance;
                 StorageControllerType_T enmController;
+                StorageBus_T enmBus;
 
                 /*
@@ -7359,6 +7320,5 @@
                 */
                 rc = atts[i]->COMGETTER(Controller)(&controllerName);
-                if (FAILED(rc))
-                    break;
+                if (FAILED(rc)) throw rc;
 
                 rc = that->mMachine->GetStorageControllerByName(controllerName, controller.asOutParam());
@@ -7366,17 +7326,22 @@
 
                 rc = controller->COMGETTER(ControllerType)(&enmController);
+                if (FAILED(rc)) throw rc;
                 rc = controller->COMGETTER(Instance)(&lInstance);
+                if (FAILED(rc)) throw rc;
+                rc = controller->COMGETTER(Bus)(&enmBus);
+                if (FAILED(rc)) throw rc;
 
                 /*
-                 * don't leave the lock since reconfigureHardDisks isn't going
+                 * don't leave the lock since reconfigureMedium isn't going
                  * to access Console.
                  */
                 int vrc = VMR3ReqCallWait(that->mpVM,
                                           VMCPUID_ANY,
-                                          (PFNRT)reconfigureHardDisks,
-                                          5,
+                                          (PFNRT)reconfigureMedium,
+                                          6,
                                           that->mpVM,
                                           lInstance,
                                           enmController,
+                                          enmBus,
                                           atts[i],
                                           &rc);
@@ -7384,7 +7349,4 @@
                     throw setError(E_FAIL, Console::tr("%Rrc"), vrc);
                 if (FAILED(rc)) throw rc;
-                    break;
-                if (FAILED(rc))
-                    break;
             }
         }
Index: /trunk/src/VBox/Main/ConsoleImpl2.cpp
===================================================================
--- /trunk/src/VBox/Main/ConsoleImpl2.cpp	(revision 24578)
+++ /trunk/src/VBox/Main/ConsoleImpl2.cpp	(revision 24579)
@@ -809,5 +809,5 @@
 
         /* /Devices/<ctrldev>/ */
-        const char *pszCtrlDev = pConsole->controllerTypeToDev(enmCtrlType);
+        const char *pszCtrlDev = pConsole->convertControllerTypeToDev(enmCtrlType);
         pDev = aCtrlNodes[enmCtrlType];
         if (!pDev)
@@ -825,5 +825,4 @@
         rc = CFGMR3InsertNode(pCtlInst,    "Config",    &pCfg);                                 RC_CHECK();
 
-        bool fSCSI = false;
         switch (enmCtrlType)
         {
@@ -834,5 +833,4 @@
                 afPciDeviceNo[20] = true;
                 rc = CFGMR3InsertInteger(pCtlInst, "PCIFunctionNo",        0);                  RC_CHECK();
-                fSCSI = true;
 
                 /* Attach the status driver */
@@ -852,5 +850,4 @@
                 afPciDeviceNo[21] = true;
                 rc = CFGMR3InsertInteger(pCtlInst, "PCIFunctionNo",        0);                  RC_CHECK();
-                fSCSI = true;
 
                 /* Attach the status driver */
@@ -961,5 +958,5 @@
         }
 
-        /* Attach the hard disks. */
+        /* Attach the media to the storage controllers. */
         com::SafeIfaceArray<IMediumAttachment> atts;
         hrc = pMachine->GetMediumAttachmentsOfController(controllerName,
@@ -982,5 +979,5 @@
 
             /* SCSI has a another driver between device and block. */
-            if (fSCSI)
+            if (enmBus == StorageBus_SCSI)
             {
                 rc = CFGMR3InsertString(pLunL0, "Driver", "SCSI");                              RC_CHECK();
Index: /trunk/src/VBox/Main/include/ConsoleImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/ConsoleImpl.h	(revision 24578)
+++ /trunk/src/VBox/Main/include/ConsoleImpl.h	(revision 24579)
@@ -223,4 +223,7 @@
     }
 
+    static const char *convertControllerTypeToDev(StorageControllerType_T enmCtrlType);
+    static HRESULT convertBusPortDeviceToLun(StorageBus_T enmBus, LONG port, LONG device, unsigned &uLun);
+
     // for VirtualBoxSupportErrorInfoImpl
     static const wchar_t *getComponentName() { return L"Console"; }
@@ -443,6 +446,4 @@
                                           const char *pszFormat, bool fPassthrough,
                                           bool fForce);
-    const char *controllerTypeToDev(StorageControllerType_T enmCtrlType);
-    HRESULT convertBusPortDeviceToLun(StorageBus_T enmBus, LONG port, LONG device, unsigned &uLun);
     HRESULT doMediumChange(IMediumAttachment *aMediumAttachment, bool fForce);
 
