Index: /trunk/src/VBox/Devices/USB/DrvVUSBRootHub.cpp
===================================================================
--- /trunk/src/VBox/Devices/USB/DrvVUSBRootHub.cpp	(revision 76999)
+++ /trunk/src/VBox/Devices/USB/DrvVUSBRootHub.cpp	(revision 77000)
@@ -234,20 +234,5 @@
 {
     LogFlow(("vusbHubAttach: pHub=%p[%s] pDev=%p[%s]\n", pHub, pHub->pszName, pDev, pDev->pUsbIns->pszName));
-    AssertMsg(pDev->enmState == VUSB_DEVICE_STATE_DETACHED, ("enmState=%d\n", pDev->enmState));
-
-    pDev->pHub = pHub;
-    pDev->enmState = VUSB_DEVICE_STATE_ATTACHED;
-
-    /* noone else ever messes with the default pipe while we are attached */
-    vusbDevMapEndpoint(pDev, &g_Endpoint0);
-    vusbDevDoSelectConfig(pDev, &g_Config0);
-
-    int rc = pHub->pOps->pfnAttach(pHub, pDev);
-    if (RT_FAILURE(rc))
-    {
-        pDev->pHub = NULL;
-        pDev->enmState = VUSB_DEVICE_STATE_DETACHED;
-    }
-    return rc;
+    return vusbDevAttach(pDev, pHub);
 }
 
Index: /trunk/src/VBox/Devices/USB/VUSBDevice.cpp
===================================================================
--- /trunk/src/VBox/Devices/USB/VUSBDevice.cpp	(revision 76999)
+++ /trunk/src/VBox/Devices/USB/VUSBDevice.cpp	(revision 77000)
@@ -1214,4 +1214,37 @@
 
 /**
+ * Attaches a device to the given hub.
+ *
+ * @returns VBox status code.
+ * @param   pDev        The device to attach.
+ * @param   pHub        THe hub to attach to.
+ */
+int vusbDevAttach(PVUSBDEV pDev, PVUSBHUB pHub)
+{
+    AssertMsg(pDev->enmState == VUSB_DEVICE_STATE_DETACHED, ("enmState=%d\n", pDev->enmState));
+
+    pDev->pHub = pHub;
+    pDev->enmState = VUSB_DEVICE_STATE_ATTACHED;
+
+    /* noone else ever messes with the default pipe while we are attached */
+    vusbDevMapEndpoint(pDev, &g_Endpoint0);
+    vusbDevDoSelectConfig(pDev, &g_Config0);
+
+    /* Create I/O thread and attach to the hub. */
+    int rc = vusbDevUrbIoThreadCreate(pDev);
+    if (RT_SUCCESS(rc))
+        rc = pHub->pOps->pfnAttach(pHub, pDev);
+
+    if (RT_FAILURE(rc))
+    {
+        pDev->pHub = NULL;
+        pDev->enmState = VUSB_DEVICE_STATE_DETACHED;
+    }
+
+    return rc;
+}
+
+
+/**
  * Detaches a device from the hub it's attached to.
  *
@@ -1245,8 +1278,4 @@
     vusbDevUrbIoThreadDestroy(pDev);
 
-    int rc = RTReqQueueDestroy(pDev->hReqQueueSync);
-    AssertRC(rc);
-    pDev->hReqQueueSync = NIL_RTREQQUEUE;
-
     vusbDevSetState(pDev, VUSB_DEVICE_STATE_DETACHED);
     pDev->pHub = NULL;
@@ -1283,4 +1312,8 @@
 
     vusbUrbPoolDestroy(&pDev->UrbPool);
+
+    int rc = RTReqQueueDestroy(pDev->hReqQueueSync);
+    AssertRC(rc);
+    pDev->hReqQueueSync = NIL_RTREQQUEUE;
 
     RTCritSectDelete(&pDev->CritSectAsyncUrbs);
@@ -1715,10 +1748,4 @@
 }
 
-
-static DECLCALLBACK(int) vusbDevGetDescriptorCacheWorker(PPDMUSBINS pUsbIns, PCPDMUSBDESCCACHE *ppDescCache)
-{
-    *ppDescCache = pUsbIns->pReg->pfnUsbGetDescriptorCache(pUsbIns);
-    return VINF_SUCCESS;
-}
 
 /**
@@ -1782,8 +1809,4 @@
     AssertRCReturn(rc, rc);
 
-    /* Create I/O thread. */
-    rc = vusbDevUrbIoThreadCreate(pDev);
-    AssertRCReturn(rc, rc);
-
     /*
      * Create the reset timer.
@@ -1802,6 +1825,5 @@
      * Get the descriptor cache from the device. (shall cannot fail)
      */
-    rc = vusbDevIoThreadExecSync(pDev, (PFNRT)vusbDevGetDescriptorCacheWorker, 2, pUsbIns, &pDev->pDescCache);
-    AssertRC(rc);
+    pDev->pDescCache = pUsbIns->pReg->pfnUsbGetDescriptorCache(pUsbIns);
     AssertPtr(pDev->pDescCache);
 #ifdef VBOX_STRICT
Index: /trunk/src/VBox/Devices/USB/VUSBInternal.h
===================================================================
--- /trunk/src/VBox/Devices/USB/VUSBInternal.h	(revision 76999)
+++ /trunk/src/VBox/Devices/USB/VUSBInternal.h	(revision 77000)
@@ -298,4 +298,5 @@
 void vusbDevMapEndpoint(PVUSBDEV dev, PCVUSBDESCENDPOINTEX ep);
 int vusbDevDetach(PVUSBDEV pDev);
+int vusbDevAttach(PVUSBDEV pDev, PVUSBHUB pHub);
 DECLINLINE(PVUSBROOTHUB) vusbDevGetRh(PVUSBDEV pDev);
 size_t vusbDevMaxInterfaces(PVUSBDEV dev);
@@ -738,8 +739,4 @@
 /** Strings for the CTLSTAGE enum values. */
 extern const char * const g_apszCtlStates[4];
-/** Default message pipe. */
-extern const VUSBDESCENDPOINTEX g_Endpoint0;
-/** Default configuration. */
-extern const VUSBDESCCONFIGEX g_Config0;
 
 RT_C_DECLS_END
