Index: /trunk/src/VBox/Main/include/ConsoleImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/ConsoleImpl.h	(revision 54059)
+++ /trunk/src/VBox/Main/include/ConsoleImpl.h	(revision 54060)
@@ -663,6 +663,5 @@
                                    const ComPtr<IBIOSSettings> &ptrBiosSettings,
                                    bool fHMEnabled);
-    int i_configMediumAttachment(PCFGMNODE pCtlInst,
-                                 const char *pcszDevice,
+    int i_configMediumAttachment(const char *pcszDevice,
                                  unsigned uInstance,
                                  StorageBus_T enmBus,
Index: /trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/ConsoleImpl.cpp	(revision 54059)
+++ /trunk/src/VBox/Main/src-client/ConsoleImpl.cpp	(revision 54060)
@@ -3675,15 +3675,5 @@
     AssertReturn(enmVMState == VMSTATE_SUSPENDED, VERR_INVALID_STATE);
 
-    /* Determine the base path for the device instance. */
-    PCFGMNODE pCtlInst;
-    if (strcmp(pcszDevice, "Msd"))
-        pCtlInst = CFGMR3GetChildF(CFGMR3GetRootU(pUVM), "Devices/%s/%u/", pcszDevice, uInstance);
-    else
-        pCtlInst = CFGMR3GetChildF(CFGMR3GetRootU(pUVM), "USB/%s/", pcszDevice, uInstance);
-    AssertReturn(pCtlInst, VERR_INTERNAL_ERROR);
-
-    PCFGMNODE pLunL0 = NULL;
-    int rc = pThis->i_configMediumAttachment(pCtlInst,
-                                             pcszDevice,
+    int rc = pThis->i_configMediumAttachment(pcszDevice,
                                              uInstance,
                                              enmBus,
@@ -3701,8 +3691,5 @@
                                              pUVM,
                                              NULL /* paLedDevType */,
-                                             &pLunL0);
-    /* Dump the changed LUN if possible, dump the complete device otherwise */
-    CFGMR3Dump(pLunL0 ? pLunL0 : pCtlInst);
-
+                                             NULL /* ppLunL0 */);
     LogFlowFunc(("Returning %Rrc\n", rc));
     return rc;
@@ -3863,20 +3850,5 @@
     AssertReturn(enmVMState == VMSTATE_SUSPENDED, VERR_INVALID_STATE);
 
-    /*
-     * Determine the base path for the device instance. USB Msd devices are handled different
-     * because the PDM USB API requires a differnet CFGM tree when attaching a new USB device.
-     */
-    PCFGMNODE pCtlInst;
-
-    if (enmBus == StorageBus_USB)
-        pCtlInst = CFGMR3CreateTree(pUVM);
-    else
-        pCtlInst = CFGMR3GetChildF(CFGMR3GetRootU(pUVM), "Devices/%s/%u/", pcszDevice, uInstance);
-
-    AssertReturn(pCtlInst, VERR_INTERNAL_ERROR);
-
-    PCFGMNODE pLunL0 = NULL;
-    int rc = pThis->i_configMediumAttachment(pCtlInst,
-                                             pcszDevice,
+    int rc = pThis->i_configMediumAttachment(pcszDevice,
                                              uInstance,
                                              enmBus,
@@ -3894,9 +3866,5 @@
                                              pUVM,
                                              NULL /* paLedDevType */,
-                                             &pLunL0);
-    /* Dump the changed LUN if possible, dump the complete device otherwise */
-    if (enmBus != StorageBus_USB)
-        CFGMR3Dump(pLunL0 ? pLunL0 : pCtlInst);
-
+                                             NULL);
     LogFlowFunc(("Returning %Rrc\n", rc));
     return rc;
@@ -9702,18 +9670,6 @@
         return VINF_SUCCESS;
 
-    /* Determine the base path for the device instance. */
-    PCFGMNODE pCtlInst;
-
-    if (enmBus == StorageBus_USB)
-        pCtlInst = CFGMR3GetChildF(CFGMR3GetRootU(pUVM), "USB/%s/", pcszDevice);
-    else
-        pCtlInst = CFGMR3GetChildF(CFGMR3GetRootU(pUVM), "Devices/%s/%u/", pcszDevice, uInstance);
-
-    AssertReturn(pCtlInst, VERR_INTERNAL_ERROR);
-
     /* Update the device instance configuration. */
-    PCFGMNODE pLunL0 = NULL;
-    int rc = pThis->i_configMediumAttachment(pCtlInst,
-                                             pcszDevice,
+    int rc = pThis->i_configMediumAttachment(pcszDevice,
                                              uInstance,
                                              enmBus,
@@ -9731,7 +9687,5 @@
                                              pUVM,
                                              NULL /* paLedDevType */,
-                                             &pLunL0);
-    /* Dump the changed LUN if possible, dump the complete device otherwise */
-    CFGMR3Dump(pLunL0 ? pLunL0 : pCtlInst);
+                                             NULL /* ppLunL0)*/);
     if (RT_FAILURE(rc))
     {
Index: /trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp	(revision 54059)
+++ /trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp	(revision 54060)
@@ -2222,6 +2222,5 @@
             {
                 IMediumAttachment *pMediumAtt = atts[j];
-                rc = i_configMediumAttachment(pCtlInst,
-                                              pszCtrlDev,
+                rc = i_configMediumAttachment(pszCtrlDev,
                                               ulInstance,
                                               enmBus,
@@ -3546,6 +3545,5 @@
 }
 
-int Console::i_configMediumAttachment(PCFGMNODE pCtlInst,
-                                      const char *pcszDevice,
+int Console::i_configMediumAttachment(const char *pcszDevice,
                                       unsigned uInstance,
                                       StorageBus_T enmBus,
@@ -3571,4 +3569,5 @@
         HRESULT hrc;
         Bstr    bstr;
+        PCFGMNODE pCtlInst = NULL;
 
 // #define RC_CHECK()  AssertMsgReturn(RT_SUCCESS(rc), ("rc=%Rrc\n", rc), rc)
@@ -3589,4 +3588,17 @@
         PCFGMNODE pLunL0 = NULL;
         hrc = Console::i_convertBusPortDeviceToLun(enmBus, lPort, lDev, uLUN);                H();
+
+        /* Determine the base path for the device instance. */
+        if (enmBus != StorageBus_USB)
+            pCtlInst = CFGMR3GetChildF(CFGMR3GetRootU(pUVM), "Devices/%s/%u/", pcszDevice, uInstance);
+        else
+        {
+            /* If we hotplug a USB device create a new CFGM tree. */
+            if (!fHotplug)
+                pCtlInst = CFGMR3GetChildF(CFGMR3GetRootU(pUVM), "USB/%s/", pcszDevice, uInstance);
+            else
+                pCtlInst = CFGMR3CreateTree(pUVM);
+        }
+        AssertReturn(pCtlInst, VERR_INTERNAL_ERROR);
 
         if (enmBus == StorageBus_USB)
@@ -4007,4 +4019,9 @@
         if (paLedDevType)
             paLedDevType[uLUN] = lType;
+
+        /* Dump the changed LUN if possible, dump the complete device otherwise */
+        if (   aMachineState != MachineState_Starting
+            && aMachineState != MachineState_Restoring)
+            CFGMR3Dump(pLunL0 ? pLunL0 : pCtlInst);
     }
     catch (ConfigError &x)
