Changeset 37687 in vbox for trunk/src/VBox/Main/src-client
- Timestamp:
- Jun 29, 2011 3:22:11 PM (14 years ago)
- Location:
- trunk/src/VBox/Main/src-client
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r37661 r37687 3663 3663 * Attach a new storage device to the VM. 3664 3664 * 3665 * @param aMediumAttachment The medium attachment which is added.3665 * @param aMediumAttachment The medium attachment which is added. 3666 3666 * @param pVM Safe VM handle. 3667 3667 * … … 3908 3908 * Attach a new storage device to the VM. 3909 3909 * 3910 * @param aMediumAttachment The medium attachment which is added.3910 * @param aMediumAttachment The medium attachment which is added. 3911 3911 * @param pVM Safe VM handle. 3912 3912 * … … 4113 4113 if (pLunL0) 4114 4114 { 4115 rc = PDMR3DeviceDetach(pVM, pcszDevice, uInstance, uLUN, 0); 4116 if (rc == VERR_PDM_NO_DRIVER_ATTACHED_TO_LUN) 4117 rc = VINF_SUCCESS; 4118 AssertRCReturn(rc, rc); 4119 CFGMR3RemoveNode(pLunL0); 4115 rc = PDMR3DeviceDetach(pVM, pcszDevice, uInstance, uLUN, 0); 4116 if (rc == VERR_PDM_NO_DRIVER_ATTACHED_TO_LUN) 4117 rc = VINF_SUCCESS; 4118 AssertRCReturn(rc, rc); 4119 CFGMR3RemoveNode(pLunL0); 4120 4121 Utf8Str devicePath = Utf8StrFmt("%s/%u/LUN#%u", pcszDevice, uInstance, uLUN); 4122 pConsole->mapMediumAttachments.erase(devicePath); 4123 4120 4124 } 4121 4125 else … … 9466 9470 * (The size of the LED array is iLastLUN - iFirstLUN + 1.) */ 9467 9471 RTUINT iLastLUN; 9472 /** Pointer to the driver instance. */ 9473 PPDMDRVINS pDrvIns; 9474 /** The Media Notify interface. */ 9475 PDMIMEDIANOTIFY IMediaNotify; 9476 /** Map for translating PDM storage controller/LUN information to 9477 * IMediumAttachment references. */ 9478 Console::MediumAttachmentMap *pmapMediumAttachments; 9479 /** Device name+instance for mapping */ 9480 char *pszDeviceInstance; 9481 /** Pointer to the Console object, for driver triggered activities. */ 9482 Console *pConsole; 9468 9483 } DRVMAINSTATUS, *PDRVMAINSTATUS; 9469 9484 … … 9480 9495 DECLCALLBACK(void) Console::drvStatus_UnitChanged(PPDMILEDCONNECTORS pInterface, unsigned iLUN) 9481 9496 { 9482 PDRVMAINSTATUS pData = (PDRVMAINSTATUS)( void *)pInterface;9497 PDRVMAINSTATUS pData = (PDRVMAINSTATUS)((uintptr_t)pInterface - RT_OFFSETOF(DRVMAINSTATUS, ILedConnectors)); 9483 9498 if (iLUN >= pData->iFirstLUN && iLUN <= pData->iLastLUN) 9484 9499 { … … 9494 9509 9495 9510 /** 9511 * Notification about a medium eject. 9512 * 9513 * @returns VBox status. 9514 * @param pInterface Pointer to the interface structure containing the called function pointer. 9515 * @param uLUN The unit number. 9516 */ 9517 DECLCALLBACK(int) Console::drvStatus_MediumEjected(PPDMIMEDIANOTIFY pInterface, unsigned uLUN) 9518 { 9519 PDRVMAINSTATUS pData = (PDRVMAINSTATUS)((uintptr_t)pInterface - RT_OFFSETOF(DRVMAINSTATUS, IMediaNotify)); 9520 PPDMDRVINS pDrvIns = pData->pDrvIns; 9521 LogFunc(("uLUN=%d\n", uLUN)); 9522 if (pData->pmapMediumAttachments) 9523 { 9524 AutoWriteLock alock(pData->pConsole COMMA_LOCKVAL_SRC_POS); 9525 9526 ComPtr<IMediumAttachment> pMediumAtt; 9527 Utf8Str devicePath = Utf8StrFmt("%s/LUN#%u", pData->pszDeviceInstance, uLUN); 9528 Console::MediumAttachmentMap::const_iterator end = pData->pmapMediumAttachments->end(); 9529 Console::MediumAttachmentMap::const_iterator it = pData->pmapMediumAttachments->find(devicePath); 9530 if (it != end) 9531 pMediumAtt = it->second; 9532 Assert(!pMediumAtt.isNull()); 9533 if (!pMediumAtt.isNull()) 9534 { 9535 alock.release(); 9536 9537 ComPtr<IMediumAttachment> pNewMediumAtt; 9538 HRESULT rc = pData->pConsole->mControl->EjectMedium(pMediumAtt, pNewMediumAtt.asOutParam()); 9539 if (SUCCEEDED(rc)) 9540 fireMediumChangedEvent(pData->pConsole->mEventSource, pNewMediumAtt); 9541 9542 alock.acquire(); 9543 if (pNewMediumAtt != pMediumAtt) 9544 { 9545 pData->pmapMediumAttachments->erase(devicePath); 9546 pData->pmapMediumAttachments->insert(std::make_pair(devicePath, pNewMediumAtt)); 9547 } 9548 } 9549 } 9550 return VINF_SUCCESS; 9551 } 9552 9553 9554 /** 9496 9555 * @interface_method_impl{PDMIBASE,pfnQueryInterface} 9497 9556 */ … … 9502 9561 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase); 9503 9562 PDMIBASE_RETURN_INTERFACE(pszIID, PDMILEDCONNECTORS, &pThis->ILedConnectors); 9563 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIANOTIFY, &pThis->IMediaNotify); 9504 9564 return NULL; 9505 9565 } … … 9541 9601 * Validate configuration. 9542 9602 */ 9543 if (!CFGMR3AreValuesValid(pCfg, "papLeds\0 First\0Last\0"))9603 if (!CFGMR3AreValuesValid(pCfg, "papLeds\0pmapMediumAttachments\0DeviceInstance\0pConsole\0First\0Last\0")) 9544 9604 return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES; 9545 9605 AssertMsgReturn(PDMDrvHlpNoAttach(pDrvIns) == VERR_PDM_NO_ATTACHED_DRIVER, … … 9552 9612 pDrvIns->IBase.pfnQueryInterface = Console::drvStatus_QueryInterface; 9553 9613 pData->ILedConnectors.pfnUnitChanged = Console::drvStatus_UnitChanged; 9614 pData->IMediaNotify.pfnEjected = Console::drvStatus_MediumEjected; 9615 pData->pDrvIns = pDrvIns; 9616 pData->pszDeviceInstance = NULL; 9554 9617 9555 9618 /* … … 9561 9624 AssertMsgFailed(("Configuration error: Failed to query the \"papLeds\" value! rc=%Rrc\n", rc)); 9562 9625 return rc; 9626 } 9627 9628 rc = CFGMR3QueryPtrDef(pCfg, "pmapMediumAttachments", (void **)&pData->pmapMediumAttachments, NULL); 9629 if (RT_FAILURE(rc)) 9630 { 9631 AssertMsgFailed(("Configuration error: Failed to query the \"pmapMediumAttachments\" value! rc=%Rrc\n", rc)); 9632 return rc; 9633 } 9634 if (pData->pmapMediumAttachments) 9635 { 9636 rc = CFGMR3QueryStringAlloc(pCfg, "DeviceInstance", &pData->pszDeviceInstance); 9637 if (RT_FAILURE(rc)) 9638 { 9639 AssertMsgFailed(("Configuration error: Failed to query the \"DeviceInstance\" value! rc=%Rrc\n", rc)); 9640 return rc; 9641 } 9642 rc = CFGMR3QueryPtr(pCfg, "pConsole", (void **)&pData->pConsole); 9643 if (RT_FAILURE(rc)) 9644 { 9645 AssertMsgFailed(("Configuration error: Failed to query the \"pConsole\" value! rc=%Rrc\n", rc)); 9646 return rc; 9647 } 9563 9648 } 9564 9649 -
trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
r37589 r37687 573 573 #endif 574 574 575 576 void Console::attachStatusDriver(PCFGMNODE pCtlInst, PPDMLED *papLeds, 577 uint64_t uFirst, uint64_t uLast, 578 Console::MediumAttachmentMap *pmapMediumAttachments, 579 const char *pcszDevice, unsigned uInstance) 580 { 581 PCFGMNODE pLunL0, pCfg; 582 InsertConfigNode(pCtlInst, "LUN#999", &pLunL0); 583 InsertConfigString(pLunL0, "Driver", "MainStatus"); 584 InsertConfigNode(pLunL0, "Config", &pCfg); 585 InsertConfigInteger(pCfg, "papLeds", (uintptr_t)papLeds); 586 if (pmapMediumAttachments) 587 { 588 InsertConfigInteger(pCfg, "pmapMediumAttachments", (uintptr_t)pmapMediumAttachments); 589 InsertConfigInteger(pCfg, "pConsole", (uintptr_t)this); 590 AssertPtr(pcszDevice); 591 Utf8Str deviceInstance = Utf8StrFmt("%s/%u", pcszDevice, uInstance); 592 InsertConfigString(pCfg, "DeviceInstance", deviceInstance.c_str()); 593 } 594 InsertConfigInteger(pCfg, "First", uFirst); 595 InsertConfigInteger(pCfg, "Last", uLast); 596 } 597 598 575 599 /** 576 600 * Construct the VM configuration tree (CFGM). … … 1482 1506 1483 1507 /* Attach the status driver */ 1484 InsertConfigNode(pCtlInst, "LUN#999", &pLunL0);1485 InsertConfigString(pLunL0, "Driver", "MainStatus");1486 InsertConfigNode(pLunL0, "Config", &pCfg);1487 InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&mapStorageLeds[iLedScsi]);1488 InsertConfigInteger(pCfg, "First", 0);1489 1508 Assert(cLedScsi >= 16); 1490 InsertConfigInteger(pCfg, "Last", 15);1509 attachStatusDriver(pCtlInst, &mapStorageLeds[iLedScsi], 0, 15, &mapMediumAttachments, pszCtrlDev, ulInstance); 1491 1510 paLedDevType = &maStorageDevType[iLedScsi]; 1492 1511 break; … … 1500 1519 1501 1520 /* Attach the status driver */ 1502 InsertConfigNode(pCtlInst, "LUN#999", &pLunL0);1503 InsertConfigString(pLunL0, "Driver", "MainStatus");1504 InsertConfigNode(pLunL0, "Config", &pCfg);1505 InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&mapStorageLeds[iLedScsi]);1506 InsertConfigInteger(pCfg, "First", 0);1507 1521 Assert(cLedScsi >= 16); 1508 InsertConfigInteger(pCfg, "Last", 15);1522 attachStatusDriver(pCtlInst, &mapStorageLeds[iLedScsi], 0, 15, &mapMediumAttachments, pszCtrlDev, ulInstance); 1509 1523 paLedDevType = &maStorageDevType[iLedScsi]; 1510 1524 break; … … 1544 1558 1545 1559 /* Attach the status driver */ 1546 InsertConfigNode(pCtlInst, "LUN#999", &pLunL0);1547 InsertConfigString(pLunL0, "Driver", "MainStatus");1548 InsertConfigNode(pLunL0, "Config", &pCfg);1549 1560 AssertRelease(cPorts <= cLedSata); 1550 InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&mapStorageLeds[iLedSata]); 1551 InsertConfigInteger(pCfg, "First", 0); 1552 InsertConfigInteger(pCfg, "Last", cPorts - 1); 1561 attachStatusDriver(pCtlInst, &mapStorageLeds[iLedSata], 0, cPorts - 1, &mapMediumAttachments, pszCtrlDev, ulInstance); 1553 1562 paLedDevType = &maStorageDevType[iLedSata]; 1554 1563 break; … … 1564 1573 hrc = BusMgr->assignPciDevice("piix3ide", pCtlInst); H(); 1565 1574 InsertConfigString(pCfg, "Type", controllerString(enmCtrlType)); 1566 1567 1575 /* Attach the status driver */ 1568 InsertConfigNode(pCtlInst, "LUN#999", &pLunL0);1569 InsertConfigString(pLunL0, "Driver", "MainStatus");1570 InsertConfigNode(pLunL0, "Config", &pCfg);1571 InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&mapStorageLeds[iLedIde]);1572 InsertConfigInteger(pCfg, "First", 0);1573 1576 Assert(cLedIde >= 4); 1574 InsertConfigInteger(pCfg, "Last", 3);1577 attachStatusDriver(pCtlInst, &mapStorageLeds[iLedIde], 0, 3, &mapMediumAttachments, pszCtrlDev, ulInstance); 1575 1578 paLedDevType = &maStorageDevType[iLedIde]; 1576 1579 … … 1594 1597 1595 1598 /* Attach the status driver */ 1596 InsertConfigNode(pCtlInst, "LUN#999", &pLunL0); 1597 InsertConfigString(pLunL0, "Driver", "MainStatus"); 1598 InsertConfigNode(pLunL0, "Config", &pCfg); 1599 InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&mapStorageLeds[iLedFloppy]); 1600 InsertConfigInteger(pCfg, "First", 0); 1601 Assert(cLedFloppy >= 1); 1602 InsertConfigInteger(pCfg, "Last", 0); 1599 Assert(cLedFloppy >= 2); 1600 attachStatusDriver(pCtlInst, &mapStorageLeds[iLedFloppy], 0, 1, &mapMediumAttachments, pszCtrlDev, ulInstance); 1603 1601 paLedDevType = &maStorageDevType[iLedFloppy]; 1604 1602 break; … … 1613 1611 1614 1612 /* Attach the status driver */ 1615 InsertConfigNode(pCtlInst, "LUN#999", &pLunL0);1616 InsertConfigString(pLunL0, "Driver", "MainStatus");1617 InsertConfigNode(pLunL0, "Config", &pCfg);1618 InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&mapStorageLeds[iLedSas]);1619 InsertConfigInteger(pCfg, "First", 0);1620 1613 Assert(cLedSas >= 8); 1621 InsertConfigInteger(pCfg, "Last", 7);1614 attachStatusDriver(pCtlInst, &mapStorageLeds[iLedSas], 0, 7, &mapMediumAttachments, pszCtrlDev, ulInstance); 1622 1615 paLedDevType = &maStorageDevType[iLedSas]; 1623 1616 break; … … 1640 1633 for (size_t j = 0; j < atts.size(); ++j) 1641 1634 { 1635 IMediumAttachment *pMediumAtt = atts[j]; 1642 1636 rc = configMediumAttachment(pCtlInst, 1643 1637 pszCtrlDev, … … 1649 1643 0 /* uMergeSource */, 1650 1644 0 /* uMergeTarget */, 1651 atts[j],1645 pMediumAtt, 1652 1646 mMachineState, 1653 1647 NULL /* phrc */, … … 1844 1838 * Attach the status driver. 1845 1839 */ 1846 InsertConfigNode(pInst, "LUN#999", &pLunL0); 1847 InsertConfigString(pLunL0, "Driver", "MainStatus"); 1848 InsertConfigNode(pLunL0, "Config", &pCfg); 1849 InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&mapNetworkLeds[ulInstance]); 1840 attachStatusDriver(pInst, &mapNetworkLeds[ulInstance], 0, 0, NULL, NULL, 0); 1850 1841 1851 1842 /* … … 2015 2006 * Attach the status driver. 2016 2007 */ 2017 InsertConfigNode(pInst, "LUN#999", &pLunL0); 2018 InsertConfigString(pLunL0, "Driver", "MainStatus"); 2019 InsertConfigNode(pLunL0, "Config", &pCfg); 2020 InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&mapSharedFolderLed); 2021 InsertConfigInteger(pCfg, "First", 0); 2022 InsertConfigInteger(pCfg, "Last", 0); 2008 attachStatusDriver(pInst, &mapSharedFolderLed, 0, 0, NULL, NULL, 0); 2023 2009 2024 2010 /* … … 2188 2174 * Attach the status driver. 2189 2175 */ 2190 InsertConfigNode(pInst, "LUN#999", &pLunL0); 2191 InsertConfigString(pLunL0, "Driver", "MainStatus"); 2192 InsertConfigNode(pLunL0, "Config", &pCfg); 2193 InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&mapUSBLed[0]); 2194 InsertConfigInteger(pCfg, "First", 0); 2195 InsertConfigInteger(pCfg, "Last", 0); 2176 attachStatusDriver(pInst, &mapUSBLed[0], 0, 0, NULL, NULL, 0); 2196 2177 2197 2178 #ifdef VBOX_WITH_EHCI … … 2226 2207 * Attach the status driver. 2227 2208 */ 2228 InsertConfigNode(pInst, "LUN#999", &pLunL0); 2229 InsertConfigString(pLunL0, "Driver", "MainStatus"); 2230 InsertConfigNode(pLunL0, "Config", &pCfg); 2231 InsertConfigInteger(pCfg, "papLeds", (uintptr_t)&mapUSBLed[1]); 2232 InsertConfigInteger(pCfg, "First", 0); 2233 InsertConfigInteger(pCfg, "Last", 0); 2209 attachStatusDriver(pInst, &mapUSBLed[1], 0, 0, NULL, NULL, 0); 2234 2210 } 2235 2211 # ifdef VBOX_WITH_EXTPACK … … 2904 2880 2905 2881 InsertConfigNode(pCtlInst, Utf8StrFmt("LUN#%u", uLUN).c_str(), &pLunL0); 2882 2883 Utf8Str devicePath = Utf8StrFmt("%s/%u/LUN#%u", pcszDevice, uInstance, uLUN); 2884 mapMediumAttachments[devicePath] = pMediumAtt; 2906 2885 2907 2886 /* SCSI has a another driver between device and block. */ … … 3113 3092 3114 3093 rc = configMedium(pLunL0, 3115 !!fPassthrough,3116 lType,3117 fUseHostIOCache,3118 fBuiltinIoCache,3119 fSetupMerge,3120 uMergeSource,3121 uMergeTarget,3122 strBwGroup.isEmpty() ? NULL : Utf8Str(strBwGroup).c_str(),3123 pMedium,3124 aMachineState,3125 phrc);3094 !!fPassthrough, 3095 lType, 3096 fUseHostIOCache, 3097 fBuiltinIoCache, 3098 fSetupMerge, 3099 uMergeSource, 3100 uMergeTarget, 3101 strBwGroup.isEmpty() ? NULL : Utf8Str(strBwGroup).c_str(), 3102 pMedium, 3103 aMachineState, 3104 phrc); 3126 3105 if (RT_FAILURE(rc)) 3127 3106 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.