VirtualBox

Ignore:
Timestamp:
Mar 18, 2016 10:51:02 AM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
106086
Message:

Main,VBoxManage: Add API to IHost for adding and removing USB device sources in addition to the default host one (only USB/IP backend supported so far which will be used in the future for automatic USB testing). Add support for it in VBoxManage

File:
1 edited

Legend:

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

    r60068 r60089  
    6060 * Initialize data members.
    6161 */
    62 USBProxyBackendLinux::USBProxyBackendLinux(USBProxyService *aUsbProxyService)
    63     : USBProxyBackend(aUsbProxyService), mhFile(NIL_RTFILE), mhWakeupPipeR(NIL_RTPIPE),
    64       mhWakeupPipeW(NIL_RTPIPE), mUsingUsbfsDevices(true /* see init */),
    65       mUdevPolls(0), mpWaiter(NULL)
    66 {
    67     LogFlowThisFunc(("aUsbProxyService=%p\n", aUsbProxyService));
     62USBProxyBackendLinux::USBProxyBackendLinux()
     63    : USBProxyBackend(), mhWakeupPipeR(NIL_RTPIPE), mhWakeupPipeW(NIL_RTPIPE)
     64{
     65    LogFlowThisFunc(("\n"));
     66}
     67
     68
     69/**
     70 * Stop all service threads and free the device chain.
     71 */
     72USBProxyBackendLinux::~USBProxyBackendLinux()
     73{
     74    LogFlowThisFunc(("\n"));
    6875}
    6976
     
    7380 * @returns VBox status code.
    7481 */
    75 int USBProxyBackendLinux::init(void)
    76 {
     82int USBProxyBackendLinux::init(USBProxyService *pUsbProxyService, const com::Utf8Str &strId, const com::Utf8Str &strAddress)
     83{
     84    USBProxyBackend::init(pUsbProxyService, strId, strAddress);
     85
    7786    const char *pcszDevicesRoot;
    7887    int rc = USBProxyLinuxChooseMethod(&mUsingUsbfsDevices, &pcszDevicesRoot);
     
    8897
    8998    return rc;
     99}
     100
     101void USBProxyBackendLinux::uninit()
     102{
     103    /*
     104     * Stop the service.
     105     */
     106    if (isActive())
     107        stop();
     108
     109    /*
     110     * Free resources.
     111     */
     112    doUsbfsCleanupAsNeeded();
     113#ifdef VBOX_USB_WITH_SYSFS
     114    if (mpWaiter)
     115        delete mpWaiter;
     116#endif
     117
     118    USBProxyBackend::uninit();
    90119}
    91120
     
    179208
    180209/**
    181  * Stop all service threads and free the device chain.
    182  */
    183 USBProxyBackendLinux::~USBProxyBackendLinux()
    184 {
    185     LogFlowThisFunc(("\n"));
    186 
    187     /*
    188      * Stop the service.
    189      */
    190     if (isActive())
    191         stop();
    192 
    193     /*
    194      * Free resources.
    195      */
    196     doUsbfsCleanupAsNeeded();
    197 #ifdef VBOX_USB_WITH_SYSFS
    198     if (mpWaiter)
    199         delete mpWaiter;
    200 #endif
    201 }
    202 
    203 
    204 /**
    205210 * If any Usbfs-related resources are currently allocated, then free them
    206211 * and mark them as freed.
     
    211216     * Free resources.
    212217     */
    213     RTFileClose(mhFile);
     218    if (mhFile != NIL_RTFILE)
     219        RTFileClose(mhFile);
    214220    mhFile = NIL_RTFILE;
    215221
    216     RTPipeClose(mhWakeupPipeR);
    217     RTPipeClose(mhWakeupPipeW);
     222    if (mhWakeupPipeR != NIL_RTPIPE)
     223        RTPipeClose(mhWakeupPipeR);
     224    if (mhWakeupPipeW != NIL_RTPIPE)
     225        RTPipeClose(mhWakeupPipeW);
    218226    mhWakeupPipeW = mhWakeupPipeR = NIL_RTPIPE;
    219227}
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