VirtualBox

Changeset 70322 in vbox for trunk/src


Ignore:
Timestamp:
Dec 22, 2017 4:53:41 PM (7 years ago)
Author:
vboxsync
Message:

USB: When capturing devices, provide the speed rather than USB port version, since the speed provides a superset of the information (bugref:7280).

Location:
trunk/src/VBox
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r68992 r70322  
    738738    static DECLCALLBACK(int) i_usbAttachCallback(Console *that, PUVM pUVM, IUSBDevice *aHostDevice, PCRTUUID aUuid,
    739739                                                 const char *aBackend, const char *aAddress, void *pvRemoteBackend,
    740                                                  USHORT aPortVersion, ULONG aMaskedIfs, const char *pszCaptureFilename);
     740                                                 USBConnectionSpeed_T enmSpeed, ULONG aMaskedIfs,
     741                                                 const char *pszCaptureFilename);
    741742    static DECLCALLBACK(int) i_usbDetachCallback(Console *that, PUVM pUVM, PCRTUUID aUuid);
    742743#endif
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r70063 r70322  
    89228922    }
    89238923
    8924     USHORT portVersion = 0;
    8925     hrc = aHostDevice->COMGETTER(PortVersion)(&portVersion);
     8924    USBConnectionSpeed_T enmSpeed;
     8925    hrc = aHostDevice->COMGETTER(Speed)(&enmSpeed);
    89268926    AssertComRCReturnRC(hrc);
    8927     Assert(portVersion == 1 || portVersion == 2 || portVersion == 3);
    89288927
    89298928    int vrc = VMR3ReqCallWaitU(ptrVM.rawUVM(), 0 /* idDstCpu (saved state, see #6232) */,
    89308929                               (PFNRT)i_usbAttachCallback, 10,
    89318930                               this, ptrVM.rawUVM(), aHostDevice, uuid.raw(), Backend.c_str(),
    8932                                Address.c_str(), pvRemoteBackend, portVersion, aMaskedIfs,
     8931                               Address.c_str(), pvRemoteBackend, enmSpeed, aMaskedIfs,
    89338932                               aCaptureFilename.isEmpty() ? NULL : aCaptureFilename.c_str());
    89348933    if (RT_SUCCESS(vrc))
     
    89818980DECLCALLBACK(int)
    89828981Console::i_usbAttachCallback(Console *that, PUVM pUVM, IUSBDevice *aHostDevice, PCRTUUID aUuid, const char *pszBackend,
    8983                              const char *aAddress, void *pvRemoteBackend, USHORT aPortVersion, ULONG aMaskedIfs,
     8982                             const char *aAddress, void *pvRemoteBackend, USBConnectionSpeed_T aEnmSpeed, ULONG aMaskedIfs,
    89848983                             const char *pszCaptureFilename)
    89858984{
     
    89918990    AssertReturn(!that->isWriteLockOnCurrentThread(), VERR_GENERAL_FAILURE);
    89928991
     8992    VUSBSPEED enmSpeed = VUSB_SPEED_UNKNOWN;
     8993    switch (aEnmSpeed)
     8994    {
     8995        case USBConnectionSpeed_Low:        enmSpeed = VUSB_SPEED_LOW;          break;
     8996        case USBConnectionSpeed_Full:       enmSpeed = VUSB_SPEED_FULL;         break;
     8997        case USBConnectionSpeed_High:       enmSpeed = VUSB_SPEED_HIGH;         break;
     8998        case USBConnectionSpeed_Super:      enmSpeed = VUSB_SPEED_SUPER;        break;
     8999        case USBConnectionSpeed_SuperPlus:  enmSpeed = VUSB_SPEED_SUPERPLUS;    break;
     9000        default:                            AssertFailed();                     break;
     9001    }
     9002
    89939003    int vrc = PDMR3UsbCreateProxyDevice(pUVM, aUuid, pszBackend, aAddress, pvRemoteBackend,
    8994                                         aPortVersion == 3 ? VUSB_STDVER_30 :
    8995                                         aPortVersion == 2 ? VUSB_STDVER_20 : VUSB_STDVER_11,
    8996                                         aMaskedIfs, pszCaptureFilename);
     9004                                        enmSpeed, aMaskedIfs, pszCaptureFilename);
    89979005    LogFlowFunc(("vrc=%Rrc\n", vrc));
    89989006    LogFlowFuncLeave();
  • trunk/src/VBox/VMM/VMMR3/PDMUsb.cpp

    r70039 r70322  
    459459
    460460/**
    461  * Translates a USB vesion (a bit-mask) to USB speed (enum). Picks
     461 * Translates a USB version (a bit-mask) to USB speed (enum). Picks
    462462 * the highest available version.
    463463 *
     
    480480
    481481    return enmSpd;
     482}
     483
     484
     485/**
     486 * Translates a USB speed (enum) to USB version.
     487 *
     488 * @returns USB version mask
     489 *
     490 * @param   enmSpeed        The USB connection speed.
     491 *
     492 */
     493static uint32_t pdmR3UsbSpd2Ver(VUSBSPEED enmSpeed)
     494{
     495    uint32_t    iUsbVersion = 0;
     496    Assert(enmSpeed != VUSB_SPEED_UNKNOWN);
     497
     498    switch (enmSpeed)
     499    {
     500    case VUSB_SPEED_LOW:
     501    case VUSB_SPEED_FULL:
     502        iUsbVersion = VUSB_STDVER_11;
     503        break;
     504    case VUSB_SPEED_HIGH:
     505        iUsbVersion = VUSB_STDVER_20;
     506        break;
     507    case VUSB_SPEED_SUPER:
     508    case VUSB_SPEED_SUPERPLUS:
     509    default:
     510        iUsbVersion = VUSB_STDVER_30;
     511        break;
     512    }
     513
     514    return iUsbVersion;
    482515}
    483516
     
    9871020 * @param   pszAddress          The address string.
    9881021 * @param   pvBackend           Pointer to the backend.
    989  * @param   iUsbVersion         The preferred USB version.
     1022 * @param   enmSpeed            The speed the USB device is operating at.
    9901023 * @param   fMaskedIfs          The interfaces to hide from the guest.
    9911024 * @param   pszCaptureFilename  Path to the file for USB traffic capturing, optional.
    9921025 */
    9931026VMMR3DECL(int) PDMR3UsbCreateProxyDevice(PUVM pUVM, PCRTUUID pUuid, const char *pszBackend, const char *pszAddress, void *pvBackend,
    994                                          uint32_t iUsbVersion, uint32_t fMaskedIfs, const char *pszCaptureFilename)
     1027                                         VUSBSPEED enmSpeed, uint32_t fMaskedIfs, const char *pszCaptureFilename)
    9951028{
    9961029    /*
     
    10031036    AssertPtrReturn(pUuid, VERR_INVALID_POINTER);
    10041037    AssertPtrReturn(pszAddress, VERR_INVALID_POINTER);
    1005     AssertReturn(    iUsbVersion == VUSB_STDVER_30
    1006                  ||  iUsbVersion == VUSB_STDVER_20
    1007                  ||  iUsbVersion == VUSB_STDVER_11, VERR_INVALID_PARAMETER);
     1038    AssertReturn(    enmSpeed == VUSB_SPEED_LOW
     1039                 ||  enmSpeed == VUSB_SPEED_FULL
     1040                 ||  enmSpeed == VUSB_SPEED_HIGH
     1041                 ||  enmSpeed == VUSB_SPEED_SUPER
     1042                 ||  enmSpeed == VUSB_SPEED_SUPERPLUS, VERR_INVALID_PARAMETER);
    10081043
    10091044    /*
     
    10211056     */
    10221057    PPDMUSBHUB pHub;
     1058    uint32_t iUsbVersion = pdmR3UsbSpd2Ver(enmSpeed);
    10231059    int rc = pdmR3UsbFindHub(pVM, iUsbVersion, &pHub);
    10241060    if (RT_FAILURE(rc))
     
    10421078        rc = CFGMR3InsertString(pConfig,  "UUID", szUuid);                      AssertRCBreak(rc);
    10431079        rc = CFGMR3InsertString(pConfig, "Backend", pszBackend);                AssertRCBreak(rc);
    1044         rc = CFGMR3InsertInteger(pConfig, "USBVersion", iUsbVersion);           AssertRCBreak(rc);
    10451080        rc = CFGMR3InsertInteger(pConfig, "pvBackend", (uintptr_t)pvBackend);   AssertRCBreak(rc);
    10461081        rc = CFGMR3InsertInteger(pConfig, "MaskedIfs", fMaskedIfs);             AssertRCBreak(rc);
     
    10541089    }
    10551090
    1056     VUSBSPEED enmSpeed = pdmR3UsbVer2Spd(iUsbVersion);
     1091    if (enmSpeed == VUSB_SPEED_UNKNOWN)
     1092        enmSpeed = pdmR3UsbVer2Spd(iUsbVersion);
    10571093
    10581094    /*
Note: See TracChangeset for help on using the changeset viewer.

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