VirtualBox

Ignore:
Timestamp:
Dec 14, 2015 2:04:37 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
104688
Message:

USB,Main: Rework USBProxyService. Split it into a USBProxyService and USBProxyBackend class, USBProxyService can use multiple USBProxyBackend instances as sources for USB devices to attach to a VM which will be used for USB/IP support. Change the PDM USB API to contain a backend parameter instead of a remote flag to indicate the USB backend to use for the given device.

Location:
trunk/src/VBox/Main/src-server/linux
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/linux/USBGetDevices.cpp

    r58170 r59117  
    13521352                 pInfo->mDevice);
    13531353    Dev->pszAddress = pszAddress;
     1354    Dev->pszBackend = RTStrDup("host");
    13541355
    13551356    /* Work out from the data collected whether we can support this device. */
  • trunk/src/VBox/Main/src-server/linux/USBProxyBackendLinux.cpp

    r59116 r59117  
    6060 * Initialize data members.
    6161 */
    62 USBProxyServiceLinux::USBProxyServiceLinux(Host *aHost)
    63     : USBProxyService(aHost), mhFile(NIL_RTFILE), mhWakeupPipeR(NIL_RTPIPE),
     62USBProxyBackendLinux::USBProxyBackendLinux(USBProxyService *aUsbProxyService)
     63    : USBProxyBackend(aUsbProxyService), mhFile(NIL_RTFILE), mhWakeupPipeR(NIL_RTPIPE),
    6464      mhWakeupPipeW(NIL_RTPIPE), mUsingUsbfsDevices(true /* see init */),
    6565      mUdevPolls(0), mpWaiter(NULL)
    6666{
    67     LogFlowThisFunc(("aHost=%p\n", aHost));
     67    LogFlowThisFunc(("aUsbProxyService=%p\n", aUsbProxyService));
    6868}
    6969
     
    7171 * Initializes the object (called right after construction).
    7272 *
    73  * @returns S_OK on success and non-fatal failures, some COM error otherwise.
    74  */
    75 HRESULT USBProxyServiceLinux::init(void)
     73 * @returns VBox status code.
     74 */
     75int USBProxyBackendLinux::init(void)
    7676{
    7777    const char *pcszDevicesRoot;
     
    8686                mUsingUsbfsDevices ? "USBFS" : "sysfs"));
    8787    }
    88     mLastError = rc;
    89     return S_OK;
     88
     89    return rc;
    9090}
    9191
     
    9595 * @returns iprt status code.
    9696 */
    97 int USBProxyServiceLinux::initUsbfs(void)
     97int USBProxyBackendLinux::initUsbfs(void)
    9898{
    9999    Assert(mUsingUsbfsDevices);
     
    128128            }
    129129            else
    130                 Log(("USBProxyServiceLinux::USBProxyServiceLinux: RTFilePipe failed with rc=%Rrc\n", rc));
     130                Log(("USBProxyBackendLinux::USBProxyBackendLinux: RTFilePipe failed with rc=%Rrc\n", rc));
    131131            RTFileClose(mhFile);
    132132        }
     
    137137    {
    138138        rc = VERR_NO_MEMORY;
    139         Log(("USBProxyServiceLinux::USBProxyServiceLinux: out of memory!\n"));
     139        Log(("USBProxyBackendLinux::USBProxyBackendLinux: out of memory!\n"));
    140140    }
    141141
     
    150150 * @returns iprt status code
    151151 */
    152 int USBProxyServiceLinux::initSysfs(void)
     152int USBProxyBackendLinux::initSysfs(void)
    153153{
    154154    Assert(!mUsingUsbfsDevices);
     
    181181 * Stop all service threads and free the device chain.
    182182 */
    183 USBProxyServiceLinux::~USBProxyServiceLinux()
     183USBProxyBackendLinux::~USBProxyBackendLinux()
    184184{
    185185    LogFlowThisFunc(("\n"));
     
    206206 * and mark them as freed.
    207207 */
    208 void USBProxyServiceLinux::doUsbfsCleanupAsNeeded()
     208void USBProxyBackendLinux::doUsbfsCleanupAsNeeded()
    209209{
    210210    /*
     
    220220
    221221
    222 int USBProxyServiceLinux::captureDevice(HostUSBDevice *aDevice)
     222int USBProxyBackendLinux::captureDevice(HostUSBDevice *aDevice)
    223223{
    224224    AssertReturn(aDevice, VERR_GENERAL_FAILURE);
     
    239239
    240240
    241 int USBProxyServiceLinux::releaseDevice(HostUSBDevice *aDevice)
     241int USBProxyBackendLinux::releaseDevice(HostUSBDevice *aDevice)
    242242{
    243243    AssertReturn(aDevice, VERR_GENERAL_FAILURE);
     
    258258
    259259
    260 bool USBProxyServiceLinux::updateDeviceState(HostUSBDevice *aDevice, PUSBDEVICE aUSBDevice, bool *aRunFilters,
     260bool USBProxyBackendLinux::updateDeviceState(HostUSBDevice *aDevice, PUSBDEVICE aUSBDevice, bool *aRunFilters,
    261261                                             SessionMachine **aIgnoreMachine)
    262262{
     
    265265    AutoReadLock devLock(aDevice COMMA_LOCKVAL_SRC_POS);
    266266    if (    aUSBDevice->enmState == USBDEVICESTATE_USED_BY_HOST_CAPTURABLE
    267         &&  aDevice->mUsb->enmState == USBDEVICESTATE_USED_BY_HOST)
     267        &&  aDevice->i_getUsbData()->enmState == USBDEVICESTATE_USED_BY_HOST)
    268268        LogRel(("USBProxy: Device %04x:%04x (%s) has become accessible.\n",
    269269                aUSBDevice->idVendor, aUSBDevice->idProduct, aUSBDevice->pszAddress));
     
    278278 * See USBProxyService::deviceAdded for details.
    279279 */
    280 void USBProxyServiceLinux::deviceAdded(ComObjPtr<HostUSBDevice> &aDevice, SessionMachinesList &llOpenedMachines,
     280void USBProxyBackendLinux::deviceAdded(ComObjPtr<HostUSBDevice> &aDevice, SessionMachinesList &llOpenedMachines,
    281281                                       PUSBDEVICE aUSBDevice)
    282282{
     
    292292
    293293    devLock.release();
    294     USBProxyService::deviceAdded(aDevice, llOpenedMachines, aUSBDevice);
    295 }
    296 
    297 
    298 int USBProxyServiceLinux::wait(RTMSINTERVAL aMillies)
     294    USBProxyBackend::deviceAdded(aDevice, llOpenedMachines, aUSBDevice);
     295}
     296
     297
     298int USBProxyBackendLinux::wait(RTMSINTERVAL aMillies)
    299299{
    300300    int rc;
     
    312312#define WAKE_UP_STRING_LEN  ( sizeof(WAKE_UP_STRING) - 1 )
    313313
    314 int USBProxyServiceLinux::waitUsbfs(RTMSINTERVAL aMillies)
     314int USBProxyBackendLinux::waitUsbfs(RTMSINTERVAL aMillies)
    315315{
    316316    struct pollfd PollFds[2];
     
    347347
    348348
    349 int USBProxyServiceLinux::waitSysfs(RTMSINTERVAL aMillies)
     349int USBProxyBackendLinux::waitSysfs(RTMSINTERVAL aMillies)
    350350{
    351351#ifdef VBOX_USB_WITH_SYSFS
     
    363363
    364364
    365 int USBProxyServiceLinux::interruptWait(void)
     365int USBProxyBackendLinux::interruptWait(void)
    366366{
    367367    AssertReturn(!isWriteLockOnCurrentThread(), VERR_GENERAL_FAILURE);
     
    385385
    386386
    387 PUSBDEVICE USBProxyServiceLinux::getDevices(void)
     387PUSBDEVICE USBProxyBackendLinux::getDevices(void)
    388388{
    389389    return USBProxyLinuxGetDevices(mDevicesRoot.c_str(), !mUsingUsbfsDevices);
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