VirtualBox

忽略:
時間撮記:
2019-1-26 上午10:30:14 (6 年 以前)
作者:
vboxsync
svn:sync-xref-src-repo-rev:
128422
訊息:

Devices/USB: Create the USB I/O thread for each device during the attach phase (as it was destructed during a detach) to fix a debug assertion when saving a VM state where the device gets reattached during the process

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Devices/USB/VUSBDevice.cpp

    r76684 r77000  
    12141214
    12151215/**
     1216 * Attaches a device to the given hub.
     1217 *
     1218 * @returns VBox status code.
     1219 * @param   pDev        The device to attach.
     1220 * @param   pHub        THe hub to attach to.
     1221 */
     1222int vusbDevAttach(PVUSBDEV pDev, PVUSBHUB pHub)
     1223{
     1224    AssertMsg(pDev->enmState == VUSB_DEVICE_STATE_DETACHED, ("enmState=%d\n", pDev->enmState));
     1225
     1226    pDev->pHub = pHub;
     1227    pDev->enmState = VUSB_DEVICE_STATE_ATTACHED;
     1228
     1229    /* noone else ever messes with the default pipe while we are attached */
     1230    vusbDevMapEndpoint(pDev, &g_Endpoint0);
     1231    vusbDevDoSelectConfig(pDev, &g_Config0);
     1232
     1233    /* Create I/O thread and attach to the hub. */
     1234    int rc = vusbDevUrbIoThreadCreate(pDev);
     1235    if (RT_SUCCESS(rc))
     1236        rc = pHub->pOps->pfnAttach(pHub, pDev);
     1237
     1238    if (RT_FAILURE(rc))
     1239    {
     1240        pDev->pHub = NULL;
     1241        pDev->enmState = VUSB_DEVICE_STATE_DETACHED;
     1242    }
     1243
     1244    return rc;
     1245}
     1246
     1247
     1248/**
    12161249 * Detaches a device from the hub it's attached to.
    12171250 *
     
    12451278    vusbDevUrbIoThreadDestroy(pDev);
    12461279
    1247     int rc = RTReqQueueDestroy(pDev->hReqQueueSync);
    1248     AssertRC(rc);
    1249     pDev->hReqQueueSync = NIL_RTREQQUEUE;
    1250 
    12511280    vusbDevSetState(pDev, VUSB_DEVICE_STATE_DETACHED);
    12521281    pDev->pHub = NULL;
     
    12831312
    12841313    vusbUrbPoolDestroy(&pDev->UrbPool);
     1314
     1315    int rc = RTReqQueueDestroy(pDev->hReqQueueSync);
     1316    AssertRC(rc);
     1317    pDev->hReqQueueSync = NIL_RTREQQUEUE;
    12851318
    12861319    RTCritSectDelete(&pDev->CritSectAsyncUrbs);
     
    17151748}
    17161749
    1717 
    1718 static DECLCALLBACK(int) vusbDevGetDescriptorCacheWorker(PPDMUSBINS pUsbIns, PCPDMUSBDESCCACHE *ppDescCache)
    1719 {
    1720     *ppDescCache = pUsbIns->pReg->pfnUsbGetDescriptorCache(pUsbIns);
    1721     return VINF_SUCCESS;
    1722 }
    17231750
    17241751/**
     
    17821809    AssertRCReturn(rc, rc);
    17831810
    1784     /* Create I/O thread. */
    1785     rc = vusbDevUrbIoThreadCreate(pDev);
    1786     AssertRCReturn(rc, rc);
    1787 
    17881811    /*
    17891812     * Create the reset timer.
     
    18021825     * Get the descriptor cache from the device. (shall cannot fail)
    18031826     */
    1804     rc = vusbDevIoThreadExecSync(pDev, (PFNRT)vusbDevGetDescriptorCacheWorker, 2, pUsbIns, &pDev->pDescCache);
    1805     AssertRC(rc);
     1827    pDev->pDescCache = pUsbIns->pReg->pfnUsbGetDescriptorCache(pUsbIns);
    18061828    AssertPtr(pDev->pDescCache);
    18071829#ifdef VBOX_STRICT
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette