VirtualBox

Changeset 98123 in vbox for trunk/src/VBox/Main/src-client


Ignore:
Timestamp:
Jan 19, 2023 12:04:47 AM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
155292
Message:

Main/Console: Todo wrt MSD hotplugging and some coding style nits.

Location:
trunk/src/VBox/Main/src-client
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r98103 r98123  
    41284128                                                 bool fSilent)
    41294129{
    4130     LogFlowFunc(("pThis=%p uInstance=%u pszDevice=%p:{%s} enmBus=%u, pMediumAtt=%p\n",
     4130    LogRelFlowFunc(("pThis=%p uInstance=%u pszDevice=%p:{%s} enmBus=%u, pMediumAtt=%p\n",
    41314131                 pThis, uInstance, pcszDevice, pcszDevice, enmBus, pMediumAtt));
    41324132
     
    41434143
    41444144    /* Determine the base path for the device instance. */
    4145     PCFGMNODE pCtlInst;
    4146     pCtlInst = pVMM->pfnCFGMR3GetChildF(pVMM->pfnCFGMR3GetRootU(pUVM), "Devices/%s/%u/", pcszDevice, uInstance);
     4145    PCFGMNODE pCtlInst = pVMM->pfnCFGMR3GetChildF(pVMM->pfnCFGMR3GetRootU(pUVM), "Devices/%s/%u/", pcszDevice, uInstance);
    41474146    AssertReturn(pCtlInst || enmBus == StorageBus_USB, VERR_INTERNAL_ERROR);
    41484147
     
    41504149
    41514150    HRESULT hrc;
    4152     int rc = VINF_SUCCESS;
    4153     int rcRet = VINF_SUCCESS;
     4151    int vrc = VINF_SUCCESS;
     4152    LONG lDev;
     4153    hrc = pMediumAtt->COMGETTER(Device)(&lDev);                             H();
     4154    LONG lPort;
     4155    hrc = pMediumAtt->COMGETTER(Port)(&lPort);                              H();
     4156    DeviceType_T lType;
     4157    hrc = pMediumAtt->COMGETTER(Type)(&lType);                              H();
    41544158    unsigned uLUN;
    4155     LONG lDev;
    4156     LONG lPort;
    4157     DeviceType_T lType;
     4159    hrc = Console::i_storageBusPortDeviceToLun(enmBus, lPort, lDev, uLUN);  H();
     4160
     4161#undef H
     4162
    41584163    PCFGMNODE pLunL0 = NULL;
    4159 
    4160     hrc = pMediumAtt->COMGETTER(Device)(&lDev);                             H();
    4161     hrc = pMediumAtt->COMGETTER(Port)(&lPort);                              H();
    4162     hrc = pMediumAtt->COMGETTER(Type)(&lType);                              H();
    4163     hrc = Console::i_storageBusPortDeviceToLun(enmBus, lPort, lDev, uLUN);  H();
    4164 
    4165 #undef H
    4166 
    41674164    if (enmBus != StorageBus_USB)
    41684165    {
     
    41724169        {
    41734170            uint32_t fFlags = 0;
    4174 
    41754171            if (fSilent)
    41764172                fFlags |= PDM_TACH_FLAGS_NOT_HOT_PLUG;
    41774173
    4178             rc = pVMM->pfnPDMR3DeviceDetach(pUVM, pcszDevice, uInstance, uLUN, fFlags);
    4179             if (rc == VERR_PDM_NO_DRIVER_ATTACHED_TO_LUN)
    4180                 rc = VINF_SUCCESS;
    4181             AssertRCReturn(rc, rc);
     4174            vrc = pVMM->pfnPDMR3DeviceDetach(pUVM, pcszDevice, uInstance, uLUN, fFlags);
     4175            if (vrc == VERR_PDM_NO_DRIVER_ATTACHED_TO_LUN)
     4176                vrc = VINF_SUCCESS;
     4177            AssertLogRelRCReturn(vrc, vrc);
    41824178            pVMM->pfnCFGMR3RemoveNode(pLunL0);
    41834179
    41844180            Utf8StrFmt devicePath("%s/%u/LUN#%u", pcszDevice, uInstance, uLUN);
    41854181            pThis->mapMediumAttachments.erase(devicePath);
    4186 
    41874182        }
    41884183        else
    4189             AssertFailedReturn(VERR_INTERNAL_ERROR);
     4184            AssertLogRelFailedReturn(VERR_INTERNAL_ERROR);
    41904185
    41914186        pVMM->pfnCFGMR3Dump(pCtlInst);
     
    41974192        USBStorageDeviceList::iterator it;
    41984193        for (it = pThis->mUSBStorageDevices.begin(); it != pThis->mUSBStorageDevices.end(); ++it)
    4199         {
    42004194            if (it->iPort == lPort)
    42014195                break;
    4202         }
    4203 
    4204         AssertReturn(it != pThis->mUSBStorageDevices.end(), VERR_INTERNAL_ERROR);
    4205         rc = pVMM->pfnPDMR3UsbDetachDevice(pUVM, &it->mUuid);
    4206         AssertRCReturn(rc, rc);
     4196        AssertLogRelReturn(it != pThis->mUSBStorageDevices.end(), VERR_INTERNAL_ERROR);
     4197
     4198        vrc = pVMM->pfnPDMR3UsbDetachDevice(pUVM, &it->mUuid);
     4199        AssertLogRelRCReturn(vrc, vrc);
    42074200        pThis->mUSBStorageDevices.erase(it);
    42084201    }
    42094202#endif
    42104203
    4211     LogFlowFunc(("Returning %Rrc\n", rcRet));
    4212     return rcRet;
     4204    LogFlowFunc(("Returning VINF_SUCCESS\n"));
     4205    return VINF_SUCCESS;
    42134206}
    42144207
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r98103 r98123  
    49434943                pCtlInst = pVMM->pfnCFGMR3GetChildF(pVMM->pfnCFGMR3GetRootU(pUVM), "USB/%s/", pcszDevice);
    49444944            else
    4945                 pCtlInst = pVMM->pfnCFGMR3CreateTree(pUVM);
     4945                pCtlInst = pVMM->pfnCFGMR3CreateTree(pUVM); /** @todo r=bird: Leaked in error paths! */
    49464946        }
    49474947        AssertReturn(pCtlInst, VERR_INTERNAL_ERROR);
     
    49654965            uInstance = lPort; /* Overwrite uInstance with the correct one. */
    49664966
     4967            /** @todo No LED after hotplugging. */
    49674968            if (!fHotplug && !fAttachDetach)
    49684969            {
    49694970                USBStorageDevice UsbMsd;
    4970 
    49714971                UsbMsd.iPort = uInstance;
    49724972                vrc = RTUuidCreate(&UsbMsd.mUuid);
     
    49774977                mUSBStorageDevices.push_back(UsbMsd);
    49784978
    4979                 /** @todo No LED after hotplugging. */
     4979                /** @todo This LED set is not freed if the device is unplugged.  We could
     4980                 *        keep the LED set index in the UsbMsd structure and clean it up in
     4981                 *        i_detachStorageDevice. */
    49804982                /* Attach the status driver */
    49814983                i_attachStatusDriver(pCtlInst, RT_BIT_32(DeviceType_HardDisk),
     
    50525054         */
    50535055        if (   (fHotplug || !fAttachDetach)
    5054             && (   (enmBus == StorageBus_SCSI || enmBus == StorageBus_SAS || enmBus == StorageBus_USB || enmBus == StorageBus_VirtioSCSI)
     5056            && (   enmBus == StorageBus_SCSI
     5057                || enmBus == StorageBus_SAS
     5058                || enmBus == StorageBus_USB
     5059                || enmBus == StorageBus_VirtioSCSI
    50555060                || (enmBus == StorageBus_SATA && enmType == DeviceType_DVD && !fPassthrough)))
    50565061        {
Note: See TracChangeset for help on using the changeset viewer.

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