VirtualBox

Changeset 53062 in vbox


Ignore:
Timestamp:
Oct 15, 2014 12:34:18 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
96564
Message:

USB: Integrate USB sniffer. Make it possible to specify a file to dump the traffic to when attaching a USB device with VBoxManage

Location:
trunk
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/pdmdrv.h

    r46788 r53062  
    508508     *
    509509     * @returns VBox status code.
    510      * @param   pDrvIns     The hub instance.
    511      * @param   pUsbIns     The device to attach.
    512      * @param   piPort      Where to store the port number the device was attached to.
     510     * @param   pDrvIns            The hub instance.
     511     * @param   pUsbIns            The device to attach.
     512     * @param   pszCaptureFilename Path to the file for USB traffic capturing, optional.
     513     * @param   piPort             Where to store the port number the device was attached to.
    513514     * @thread EMT.
    514515     */
    515     DECLR3CALLBACKMEMBER(int, pfnAttachDevice,(PPDMDRVINS pDrvIns, PPDMUSBINS pUsbIns, uint32_t *piPort));
     516    DECLR3CALLBACKMEMBER(int, pfnAttachDevice,(PPDMDRVINS pDrvIns, PPDMUSBINS pUsbIns, const char *pszCaptureFilename, uint32_t *piPort));
    516517
    517518    /**
     
    537538
    538539/** Current PDMUSBHUBREG version number. */
    539 #define PDM_USBHUBREG_VERSION                   PDM_VERSION_MAKE(0xf0fd, 1, 0)
     540#define PDM_USBHUBREG_VERSION                   PDM_VERSION_MAKE(0xf0fd, 2, 0)
    540541
    541542
  • trunk/include/VBox/vmm/pdmusb.h

    r51290 r53062  
    10581058typedef DECLCALLBACK(int) FNPDMVBOXUSBREGISTER(PCPDMUSBREGCB pCallbacks, uint32_t u32Version);
    10591059
    1060 VMMR3DECL(int)  PDMR3UsbCreateEmulatedDevice(PUVM pUVM, const char *pszDeviceName, PCFGMNODE pDeviceNode, PCRTUUID pUuid);
     1060VMMR3DECL(int)  PDMR3UsbCreateEmulatedDevice(PUVM pUVM, const char *pszDeviceName, PCFGMNODE pDeviceNode, PCRTUUID pUuid,
     1061                                             const char *pszCaptureFilename);
    10611062VMMR3DECL(int)  PDMR3UsbCreateProxyDevice(PUVM pUVM, PCRTUUID pUuid, bool fRemote, const char *pszAddress, void *pvBackend,
    1062                                           uint32_t iUsbVersion, uint32_t fMaskedIfs);
     1063                                          uint32_t iUsbVersion, uint32_t fMaskedIfs, const char *pszCaptureFilename);
    10631064VMMR3DECL(int)  PDMR3UsbDetachDevice(PUVM pUVM, PCRTUUID pUuid);
    10641065VMMR3DECL(bool) PDMR3UsbHasHub(PUVM pUVM);
  • trunk/src/VBox/Devices/Makefile.kmk

    r52797 r53062  
    354354        USB/VUSBDevice.cpp \
    355355        USB/VUSBReadAhead.cpp \
    356         USB/VUSBUrb.cpp
     356        USB/VUSBUrb.cpp \
     357        USB/VUSBSniffer.cpp
    357358 endif
    358359
  • trunk/src/VBox/Devices/USB/DrvVUSBRootHub.cpp

    r52878 r53062  
    255255
    256256/** @copydoc PDMUSBHUBREG::pfnAttachDevice */
    257 static DECLCALLBACK(int) vusbPDMHubAttachDevice(PPDMDRVINS pDrvIns, PPDMUSBINS pUsbIns, uint32_t *piPort)
     257static DECLCALLBACK(int) vusbPDMHubAttachDevice(PPDMDRVINS pDrvIns, PPDMUSBINS pUsbIns, const char *pszCaptureFilename, uint32_t *piPort)
    258258{
    259259    PVUSBROOTHUB pThis = PDMINS_2_DATA(pDrvIns, PVUSBROOTHUB);
     
    264264    PVUSBDEV pDev = (PVUSBDEV)RTMemAllocZ(sizeof(*pDev));
    265265    AssertReturn(pDev, VERR_NO_MEMORY);
    266     int rc = vusbDevInit(pDev, pUsbIns);
     266    int rc = vusbDevInit(pDev, pUsbIns, pszCaptureFilename);
    267267    if (RT_SUCCESS(rc))
    268268    {
  • trunk/src/VBox/Devices/USB/VUSBDevice.cpp

    r52881 r53062  
    3434#include "VUSBInternal.h"
    3535
     36#include "VUSBSniffer.h"
    3637
    3738/*******************************************************************************
     
    12831284    AssertRC(rc);
    12841285
     1286    if (pDev->hSniffer != VUSBSNIFFER_NIL)
     1287        VUSBSnifferDestroy(pDev->hSniffer);
     1288
    12851289    RTCritSectDelete(&pDev->CritSectAsyncUrbs);
    12861290    /* Not using vusbDevSetState() deliberately here because it would assert on the state. */
     
    16971701 * @param   pUsbIns Pointer to the PDM USB Device instance.
    16981702 */
    1699 int vusbDevInit(PVUSBDEV pDev, PPDMUSBINS pUsbIns)
     1703int vusbDevInit(PVUSBDEV pDev, PPDMUSBINS pUsbIns, const char *pszCaptureFilename)
    17001704{
    17011705    /*
     
    17331737    }
    17341738    pDev->pResetTimer = NULL;
     1739    pDev->hSniffer = VUSBSNIFFER_NIL;
    17351740
    17361741    int rc = RTCritSectInit(&pDev->CritSectAsyncUrbs);
     
    17511756                                "USB Device Reset Timer",  &pDev->pResetTimer);
    17521757    AssertRCReturn(rc, rc);
     1758
     1759    if (pszCaptureFilename)
     1760    {
     1761        rc = VUSBSnifferCreate(&pDev->hSniffer, 0, pszCaptureFilename, NULL);
     1762        AssertRCReturn(rc, rc);
     1763    }
    17531764
    17541765    /*
  • trunk/src/VBox/Devices/USB/VUSBInternal.h

    r52881 r53062  
    3131#include <iprt/queueatomic.h>
    3232#include <iprt/req.h>
     33
     34#include "VUSBSniffer.h"
    3335
    3436RT_C_DECLS_BEGIN
     
    216218     * synchronous and without any other thread accessing the USB device. */
    217219    RTREQQUEUE          hReqQueueSync;
     220    /** Sniffer instance for this device if configured. */
     221    VUSBSNIFFER         hSniffer;
    218222    /** Flag whether the URB I/O thread should terminate. */
    219223    bool volatile       fTerminate;
     
    222226#if HC_ARCH_BITS == 32
    223227    /** Align the size to a 8 byte boundary. */
    224     bool                afAlignment0[2];
     228    bool                afAlignment0[6];
    225229#endif
    226230} VUSBDEV;
     
    248252
    249253
    250 int vusbDevInit(PVUSBDEV pDev, PPDMUSBINS pUsbIns);
     254int vusbDevInit(PVUSBDEV pDev, PPDMUSBINS pUsbIns, const char *pszCaptureFilename);
    251255int vusbDevCreateOld(const char *pszDeviceName, void *pvDriverInit, PCRTUUID pUuid, PVUSBDEV *ppDev);
    252256void vusbDevDestroy(PVUSBDEV pDev);
  • trunk/src/VBox/Devices/USB/VUSBUrb.cpp

    r52881 r53062  
    10121012              || pUrb->enmState == VUSBURBSTATE_CANCELLED, ("%d\n", pUrb->enmState));
    10131013
     1014    if (pUrb->VUsb.pDev->hSniffer)
     1015    {
     1016        int rc = VUSBSnifferRecordEvent(pUrb->VUsb.pDev->hSniffer, pUrb,
     1017                                          pUrb->enmStatus == VUSBSTATUS_OK
     1018                                        ? VUSBSNIFFEREVENT_COMPLETE
     1019                                        : VUSBSNIFFEREVENT_ERROR_COMPLETE);
     1020        if (RT_FAILURE(rc))
     1021            LogRel(("VUSB: Capturing URB completion event failed with %Rrc\n", rc));
     1022    }
    10141023
    10151024#ifdef VBOX_WITH_STATISTICS
     
    18961905    int rc;
    18971906
     1907    if (pDev->hSniffer)
     1908    {
     1909        rc = VUSBSnifferRecordEvent(pDev->hSniffer, pUrb, VUSBSNIFFEREVENT_SUBMIT);
     1910        if (RT_FAILURE(rc))
     1911            LogRel(("VUSB: Capturing URB submit event failed with %Rrc\n", rc));
     1912    }
     1913
    18981914#ifdef VBOX_WITH_USB
    18991915    if (pPipe && pPipe->hReadAhead)
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageControlVM.cpp

    r52978 r53062  
    933933                break;
    934934            }
     935            else if (a->argc == 4 || a->argc > 5)
     936            {
     937                errorSyntax(USAGE_CONTROLVM, "Wrong number of arguments");
     938                rc = E_FAIL;
     939                break;
     940            }
    935941
    936942            bool attach = !strcmp(a->argv[1], "usbattach");
    937943
    938944            Bstr usbId = a->argv[2];
     945            Bstr captureFilename;
     946
     947            if (a->argc == 5)
     948            {
     949                if (!strcmp(a->argv[3], "--capturefile"))
     950                    captureFilename = a->argv[4];
     951                else
     952                {
     953                    errorArgument("Invalid parameter '%s'", a->argv[3]);
     954                    rc = E_FAIL;
     955                    break;
     956                }
     957            }
    939958
    940959            Guid guid(usbId);
     
    971990
    972991            if (attach)
    973                 CHECK_ERROR_BREAK(console, AttachUSBDevice(usbId.raw()));
     992                CHECK_ERROR_BREAK(console, AttachUSBDevice(usbId.raw(), captureFilename.raw()));
    974993            else
    975994            {
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp

    r52312 r53062  
    372372                     "                            [--autostart-enabled on|off]\n"
    373373                     "                            [--autostart-delay <seconds>]\n"
    374 #if 0 /* Disabled until the feature is implemented. */
     374#if 0
    375375                     "                            [--autostop-type disabled|savestate|poweroff|\n"
    376376                     "                                             acpishutdown]\n"
     
    468468                     "                            natpf<1-N> delete <rulename> |\n"
    469469                     "                            guestmemoryballoon <balloonsize in MB> |\n"
    470                      "                            usbattach <uuid>|<address> |\n"
     470                     "                            usbattach <uuid>|<address>\n"
     471                     "                                      [--capturefile <filename>] |\n"
    471472                     "                            usbdetach <uuid>|<address> |\n"
    472473                     "                            clipboard disabled|hosttoguest|guesttohost|\n"
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r53046 r53062  
    16401640    {
    16411641        /* Try to attach corresponding device: */
    1642         console().AttachUSBDevice(target.id);
     1642        console().AttachUSBDevice(target.id, QString(""));
    16431643        /* Check if console is OK: */
    16441644        if (!console().isOk())
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r52978 r53062  
    34953495  <interface
    34963496    name="IInternalMachineControl" extends="$unknown"
    3497     uuid="2d9ce4b7-0ab2-4931-ac4a-e45aa66465ef"
     3497    uuid="1470ff16-d7fa-448e-9c38-0352a36053bf"
    34983498    internal="yes"
    34993499    wsmap="suppress"
     
    36053605      </desc>
    36063606      <param name="id" type="uuid" mod="string" dir="in"/>
     3607      <param name="captureFilename" type="wstring" dir="in"/>
    36073608    </method>
    36083609
     
    74927493  <interface
    74937494    name="IConsole" extends="$unknown"
    7494     uuid="d129b03e-037a-40b1-b288-a08ae73de535"
     7495    uuid="e51702d7-4f8f-4ebe-ac47-4b77defffd18"
    74957496    wsmap="managed"
    74967497    >
     
    79407941      <param name="id" type="uuid" mod="string" dir="in">
    79417942        <desc>UUID of the host USB device to attach.</desc>
     7943      </param>
     7944      <param name="captureFilename" type="wstring" dir="in">
     7945        <desc>Filename to capture the USB traffic to.</desc>
    79427946      </param>
    79437947    </method>
     
    1788017884  <interface
    1788117885    name="IInternalSessionControl" extends="$unknown"
    17882     uuid="b7c71040-2761-42c4-a44a-4e2c2d7e2820"
     17886    uuid="fdb5fa71-eddb-4e06-9844-277d22270fe0"
    1788317887    internal="yes"
    1788417888    wsmap="suppress"
     
    1822118225      <param name="error" type="IVirtualBoxErrorInfo" dir="in"/>
    1822218226      <param name="maskedInterfaces" type="unsigned long" dir="in"/>
     18227      <param name="captureFilename" type="wstring" dir="in"/>
    1822318228    </method>
    1822418229
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r52934 r53062  
    168168    HRESULT i_onUSBControllerChange();
    169169    HRESULT i_onSharedFolderChange(BOOL aGlobal);
    170     HRESULT i_onUSBDeviceAttach(IUSBDevice *aDevice, IVirtualBoxErrorInfo *aError, ULONG aMaskedIfs);
     170    HRESULT i_onUSBDeviceAttach(IUSBDevice *aDevice, IVirtualBoxErrorInfo *aError, ULONG aMaskedIfs,
     171                                const Utf8Str &aCaptureFilename);
    171172    HRESULT i_onUSBDeviceDetach(IN_BSTR aId, IVirtualBoxErrorInfo *aError);
    172173    HRESULT i_onBandwidthGroupChange(IBandwidthGroup *aBandwidthGroup);
     
    318319    HRESULT getDeviceActivity(const std::vector<DeviceType_T> &aType,
    319320                              std::vector<DeviceActivity_T> &aActivity);
    320     HRESULT attachUSBDevice(const com::Guid &aId);
     321    HRESULT attachUSBDevice(const com::Guid &aId, const com::Utf8Str &aCaptureFilename);
    321322    HRESULT detachUSBDevice(const com::Guid &aId,
    322323                            ComPtr<IUSBDevice> &aDevice);
     
    743744
    744745#ifdef VBOX_WITH_USB
    745     HRESULT i_attachUSBDevice(IUSBDevice *aHostDevice, ULONG aMaskedIfs);
     746    HRESULT i_attachUSBDevice(IUSBDevice *aHostDevice, ULONG aMaskedIfs, const Utf8Str &aCaptureFilename);
    746747    HRESULT i_detachUSBDevice(const ComObjPtr<OUSBDevice> &aHostDevice);
    747748
    748749    static DECLCALLBACK(int) i_usbAttachCallback(Console *that, PUVM pUVM, IUSBDevice *aHostDevice, PCRTUUID aUuid,
    749750                                                 bool aRemote, const char *aAddress, void *pvRemoteBackend,
    750                                                  USHORT aPortVersion, ULONG aMaskedIfs);
     751                                                 USHORT aPortVersion, ULONG aMaskedIfs, const char *pszCaptureFilename);
    751752    static DECLCALLBACK(int) i_usbDetachCallback(Console *that, PUVM pUVM, PCRTUUID aUuid);
    752753#endif
  • trunk/src/VBox/Main/include/HostUSBDeviceImpl.h

    r49960 r53062  
    209209    com::Utf8Str i_getName();
    210210
    211     HRESULT i_requestCaptureForVM(SessionMachine *aMachine, bool aSetError, ULONG aMaskedIfs = 0);
     211    HRESULT i_requestCaptureForVM(SessionMachine *aMachine, bool aSetError,
     212                                  const com::Utf8Str &aCaptureFilename, ULONG aMaskedIfs = 0);
    212213    HRESULT i_onDetachFromVM(SessionMachine *aMachine, bool aDone, bool *aRunFilters, bool aAbnormal = false);
    213214    HRESULT i_requestReleaseToHost();
     
    229230protected:
    230231
    231     HRESULT i_attachToVM(SessionMachine *aMachine, ULONG aMaskedIfs = 0);
     232    HRESULT i_attachToVM(SessionMachine *aMachine, const com::Utf8Str &aCaptureFilename, ULONG aMaskedIfs = 0);
    232233    void i_detachFromVM(HostUSBDeviceState aFinalState);
    233234    void i_onPhysicalDetachedInternal();
     
    300301     * This points to the string in mNameObj. */
    301302    const char *mName;
     303    /** The filename to capture the USB traffic to. */
     304    com::Utf8Str mCaptureFilename;
    302305
    303306    friend class USBProxyService;
  • trunk/src/VBox/Main/include/MachineImpl.h

    r52958 r53062  
    11441144                                BOOL *aMatched,
    11451145                                ULONG *aMaskedInterfaces);
    1146     HRESULT captureUSBDevice(const com::Guid &aId);
     1146    HRESULT captureUSBDevice(const com::Guid &aId, const com::Utf8Str &aCaptureFilename);
    11471147    HRESULT detachUSBDevice(const com::Guid &aId,
    11481148                            BOOL aDone);
     
    12851285    HRESULT i_onUSBDeviceAttach(IUSBDevice *aDevice,
    12861286                                IVirtualBoxErrorInfo *aError,
    1287                                 ULONG aMaskedIfs);
     1287                                ULONG aMaskedIfs,
     1288                                const com::Utf8Str &aCaptureFilename);
    12881289    HRESULT i_onUSBDeviceDetach(IN_BSTR aId,
    12891290                                IVirtualBoxErrorInfo *aError);
     
    13151316                                BOOL *aMatched,
    13161317                                ULONG *aMaskedInterfaces);
    1317     HRESULT captureUSBDevice(const com::Guid &aId);
     1318    HRESULT captureUSBDevice(const com::Guid &aId, const com::Utf8Str &aCaptureFilename);
    13181319    HRESULT detachUSBDevice(const com::Guid &aId,
    13191320                            BOOL aDone);
  • trunk/src/VBox/Main/include/SessionImpl.h

    r52251 r53062  
    9797    HRESULT onUSBDeviceAttach(const ComPtr<IUSBDevice> &aDevice,
    9898                              const ComPtr<IVirtualBoxErrorInfo> &aError,
    99                               ULONG aMaskedInterfaces);
     99                              ULONG aMaskedInterfaces,
     100                              const com::Utf8Str &aCaptureFilename);
    100101    HRESULT onUSBDeviceDetach(const com::Guid &aId,
    101102                              const ComPtr<IVirtualBoxErrorInfo> &aError);
  • trunk/src/VBox/Main/include/USBProxyService.h

    r52934 r53062  
    6363    /** @name SessionMachine Interfaces
    6464     * @{ */
    65     HRESULT captureDeviceForVM(SessionMachine *aMachine, IN_GUID aId);
     65    HRESULT captureDeviceForVM(SessionMachine *aMachine, IN_GUID aId, const com::Utf8Str &aCaptureFilename);
    6666    HRESULT detachDeviceFromVM(SessionMachine *aMachine, IN_GUID aId, bool aDone);
    6767    HRESULT autoCaptureDevicesForVM(SessionMachine *aMachine);
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r53031 r53062  
    28272827}
    28282828
    2829 HRESULT Console::attachUSBDevice(const com::Guid &aId)
     2829HRESULT Console::attachUSBDevice(const com::Guid &aId, const com::Utf8Str &aCaptureFilename)
    28302830{
    28312831#ifdef VBOX_WITH_USB
     
    28532853
    28542854    /* Request the device capture */
    2855     return mControl->CaptureUSBDevice(Bstr(aId.toString()).raw());
     2855    return mControl->CaptureUSBDevice(Bstr(aId.toString()).raw(), Bstr(aCaptureFilename).raw());
    28562856
    28572857#else   /* !VBOX_WITH_USB */
     
    52715271 * @note Locks this object for writing.
    52725272 */
    5273 HRESULT Console::i_onUSBDeviceAttach(IUSBDevice *aDevice, IVirtualBoxErrorInfo *aError, ULONG aMaskedIfs)
     5273HRESULT Console::i_onUSBDeviceAttach(IUSBDevice *aDevice, IVirtualBoxErrorInfo *aError, ULONG aMaskedIfs,
     5274                                     const Utf8Str &aCaptureFilename)
    52745275{
    52755276#ifdef VBOX_WITH_USB
     
    53095310
    53105311    alock.release();
    5311     HRESULT rc = i_attachUSBDevice(aDevice, aMaskedIfs);
     5312    HRESULT rc = i_attachUSBDevice(aDevice, aMaskedIfs, aCaptureFilename);
    53125313    if (FAILED(rc))
    53135314    {
     
    83168317 * @note Synchronously calls EMT.
    83178318 */
    8318 HRESULT Console::i_attachUSBDevice(IUSBDevice *aHostDevice, ULONG aMaskedIfs)
     8319HRESULT Console::i_attachUSBDevice(IUSBDevice *aHostDevice, ULONG aMaskedIfs,
     8320                                   const Utf8Str &aCaptureFilename)
    83198321{
    83208322    AssertReturn(aHostDevice, E_FAIL);
     
    83658367
    83668368    int vrc = VMR3ReqCallWaitU(ptrVM.rawUVM(), 0 /* idDstCpu (saved state, see #6232) */,
    8367                                (PFNRT)i_usbAttachCallback, 9,
     8369                               (PFNRT)i_usbAttachCallback, 10,
    83688370                               this, ptrVM.rawUVM(), aHostDevice, uuid.raw(), fRemote,
    8369                                Address.c_str(), pvRemoteBackend, portVersion, aMaskedIfs);
     8371                               Address.c_str(), pvRemoteBackend, portVersion, aMaskedIfs,
     8372                               aCaptureFilename.isEmpty() ? NULL : aCaptureFilename.c_str());
    83708373    if (RT_SUCCESS(vrc))
    83718374    {
     
    84188421DECLCALLBACK(int)
    84198422Console::i_usbAttachCallback(Console *that, PUVM pUVM, IUSBDevice *aHostDevice, PCRTUUID aUuid, bool aRemote,
    8420                              const char *aAddress, void *pvRemoteBackend, USHORT aPortVersion, ULONG aMaskedIfs)
     8423                             const char *aAddress, void *pvRemoteBackend, USHORT aPortVersion, ULONG aMaskedIfs,
     8424                             const char *pszCaptureFilename)
    84218425{
    84228426    LogFlowFuncEnter();
     
    84298433                                        aPortVersion == 3 ? VUSB_STDVER_30 :
    84308434                                        aPortVersion == 2 ? VUSB_STDVER_11 : VUSB_STDVER_20,
    8431                                         aMaskedIfs);
     8435                                        aMaskedIfs, pszCaptureFilename);
    84328436    LogFlowFunc(("vrc=%Rrc\n", vrc));
    84338437    LogFlowFuncLeave();
     
    90539057            {
    90549058                alock.release();
    9055                 hrc = i_onUSBDeviceAttach(pUSBDevice, NULL, fMaskedIfs);
     9059                hrc = i_onUSBDeviceAttach(pUSBDevice, NULL, fMaskedIfs, Utf8Str());
    90569060                alock.acquire();
    90579061
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r53012 r53062  
    39553955                    RTUuidCreate(&UsbMsd.mUuid);
    39563956                    UsbMsd.iPort = uInstance;
    3957                     rc = PDMR3UsbCreateEmulatedDevice(pUVM, pcszDevice, pCtlInst, &UsbMsd.mUuid);
     3957                    rc = PDMR3UsbCreateEmulatedDevice(pUVM, pcszDevice, pCtlInst, &UsbMsd.mUuid, NULL);
    39583958                    if (RT_SUCCESS(rc))
    39593959                        mUSBStorageDevices.push_back(UsbMsd);
  • trunk/src/VBox/Main/src-client/EmulatedUSBImpl.cpp

    r50580 r53062  
    171171
    172172    /* pInstance will be used by PDM and deallocated on error. */
    173     rc = PDMR3UsbCreateEmulatedDevice(pUVM, "Webcam", pInstance, &pThis->mUuid);
     173    rc = PDMR3UsbCreateEmulatedDevice(pUVM, "Webcam", pInstance, &pThis->mUuid, NULL);
    174174    LogRelFlowFunc(("PDMR3UsbCreateEmulatedDevice %Rrc\n", rc));
    175175    return rc;
  • trunk/src/VBox/Main/src-client/SessionImpl.cpp

    r52481 r53062  
    730730HRESULT Session::onUSBDeviceAttach(const ComPtr<IUSBDevice> &aDevice,
    731731                                   const ComPtr<IVirtualBoxErrorInfo> &aError,
    732                                    ULONG aMaskedInterfaces)
    733 {
    734     LogFlowThisFunc(("\n"));
    735 
    736     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    737     AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
    738     AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
    739 #ifndef VBOX_COM_INPROC_API_CLIENT
    740     AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE);
    741 
    742     return mConsole->i_onUSBDeviceAttach(aDevice, aError, aMaskedInterfaces);
     732                                   ULONG aMaskedInterfaces,
     733                                   const com::Utf8Str &aCaptureFilename)
     734{
     735    LogFlowThisFunc(("\n"));
     736
     737    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     738    AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     739    AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
     740#ifndef VBOX_COM_INPROC_API_CLIENT
     741    AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE);
     742
     743    return mConsole->i_onUSBDeviceAttach(aDevice, aError, aMaskedInterfaces, aCaptureFilename);
    743744#else
    744745    return S_OK;
  • trunk/src/VBox/Main/src-server/HostUSBDeviceImpl.cpp

    r52743 r53062  
    312312 * process, which means it will temporarily release all locks. (Is this a good idea?)
    313313 *
    314  * @param   aMachine    Machine this device should be attach to.
    315  * @param   aSetError   Whether to set full error message or not to bother.
    316  * @param   aMaskedIfs  The interfaces to hide from the guest.
     314 * @param   aMachine         Machine this device should be attach to.
     315 * @param   aSetError        Whether to set full error message or not to bother.
     316 * @param   aCaptureFilename The filename to capture the USB traffic to.
     317 * @param   aMaskedIfs       The interfaces to hide from the guest.
    317318 *
    318319 * @returns Status indicating whether it was successfully captured and/or attached.
     
    321322 * @retval  E_* as appropriate.
    322323 */
    323 HRESULT HostUSBDevice::i_requestCaptureForVM(SessionMachine *aMachine, bool aSetError, ULONG aMaskedIfs /* = 0*/)
     324HRESULT HostUSBDevice::i_requestCaptureForVM(SessionMachine *aMachine, bool aSetError,
     325                                             const com::Utf8Str &aCaptureFilename, ULONG aMaskedIfs /* = 0*/)
    324326{
    325327    /*
     
    377379    {
    378380        alock.release();
    379         HRESULT hrc = i_attachToVM(aMachine, aMaskedIfs);
     381        HRESULT hrc = i_attachToVM(aMachine, aCaptureFilename, aMaskedIfs);
    380382        return SUCCEEDED(hrc);
    381383    }
     
    396398    mMachine = aMachine;
    397399    mMaskedIfs = aMaskedIfs;
     400    mCaptureFilename = aCaptureFilename;
    398401    alock.release();
    399402    int rc = mUSBProxyService->captureDevice(this);
     
    430433 * @param   aMaskedIfs      The interfaces to hide from the guest.
    431434 */
    432 HRESULT HostUSBDevice::i_attachToVM(SessionMachine *aMachine, ULONG aMaskedIfs /* = 0*/)
     435HRESULT HostUSBDevice::i_attachToVM(SessionMachine *aMachine, const com::Utf8Str &aCaptureFilename,
     436                                    ULONG aMaskedIfs /* = 0*/)
    433437{
    434438    AssertReturn(!isWriteLockOnCurrentThread(), E_FAIL);
     
    457461    LogFlowThisFunc(("{%s} Calling machine->onUSBDeviceAttach()...\n", mName));
    458462    alock.release();
    459     HRESULT hrc = aMachine->i_onUSBDeviceAttach(d, NULL, aMaskedIfs);
     463    HRESULT hrc = aMachine->i_onUSBDeviceAttach(d, NULL, aMaskedIfs, aCaptureFilename);
    460464    LogFlowThisFunc(("{%s} Done machine->onUSBDeviceAttach()=%08X\n", mName, hrc));
    461465
     
    13371341                        {
    13381342                            alock.release();
    1339                             i_attachToVM(mMachine, mMaskedIfs);
     1343                            i_attachToVM(mMachine, mCaptureFilename, mMaskedIfs);
    13401344                            alock.acquire();
    13411345                        }
     
    14751479            {
    14761480                alock.release();
    1477                 i_attachToVM(mMachine, mMaskedIfs);
     1481                i_attachToVM(mMachine, mCaptureFilename, mMaskedIfs);
    14781482            }
    14791483            return true;
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r53012 r53062  
    1278412784 *  @note Locks the same as Host::captureUSBDevice() does.
    1278512785 */
    12786 HRESULT SessionMachine::captureUSBDevice(const com::Guid &aId)
     12786HRESULT SessionMachine::captureUSBDevice(const com::Guid &aId, const com::Utf8Str &aCaptureFilename)
    1278712787{
    1278812788    LogFlowThisFunc(("\n"));
     
    1279612796    USBProxyService *service = mParent->i_host()->i_usbProxyService();
    1279712797    AssertReturn(service, E_FAIL);
    12798     return service->captureDeviceForVM(this, aId.ref());
     12798    return service->captureDeviceForVM(this, aId.ref(), aCaptureFilename);
    1279912799#else
    1280012800    NOREF(aId);
     
    1381413814HRESULT SessionMachine::i_onUSBDeviceAttach(IUSBDevice *aDevice,
    1381513815                                            IVirtualBoxErrorInfo *aError,
    13816                                             ULONG aMaskedIfs)
     13816                                            ULONG aMaskedIfs,
     13817                                            const com::Utf8Str &aCaptureFilename)
    1381713818{
    1381813819    LogFlowThisFunc(("\n"));
     
    1383913840    AssertMsg(RTLockValidatorReadLockGetCount(RTThreadSelf()) == 0, ("%d\n", RTLockValidatorReadLockGetCount(RTThreadSelf())));
    1384013841
    13841     return directControl->OnUSBDeviceAttach(aDevice, aError, aMaskedIfs);
     13842    return directControl->OnUSBDeviceAttach(aDevice, aError, aMaskedIfs, Bstr(aCaptureFilename).raw());
    1384213843}
    1384313844
     
    1439314394}
    1439414395
    14395 HRESULT Machine::captureUSBDevice(const com::Guid &aId)
     14396HRESULT Machine::captureUSBDevice(const com::Guid &aId, const com::Utf8Str &aCaptureFilename)
    1439614397{
    1439714398    NOREF(aId);
  • trunk/src/VBox/Main/src-server/USBProxyService.cpp

    r52934 r53062  
    166166 *          former case it will temporarily abandon locks because of IPC.
    167167 */
    168 HRESULT USBProxyService::captureDeviceForVM(SessionMachine *aMachine, IN_GUID aId)
     168HRESULT USBProxyService::captureDeviceForVM(SessionMachine *aMachine, IN_GUID aId, const com::Utf8Str &aCaptureFilename)
    169169{
    170170    ComAssertRet(aMachine, E_INVALIDARG);
     
    183183     */
    184184    alock.release();
    185     return pHostDevice->i_requestCaptureForVM(aMachine, true /* aSetError */);
     185    return pHostDevice->i_requestCaptureForVM(aMachine, true /* aSetError */, aCaptureFilename);
    186186}
    187187
     
    528528    {
    529529        /* try to capture the device */
    530         HRESULT hrc = aDevice->i_requestCaptureForVM(aMachine, false /* aSetError */, ulMaskedIfs);
     530        HRESULT hrc = aDevice->i_requestCaptureForVM(aMachine, false /* aSetError */, Utf8Str(), ulMaskedIfs);
    531531        return SUCCEEDED(hrc)
    532532            || hrc == E_UNEXPECTED /* bad device state, give up */;
  • trunk/src/VBox/VMM/VMMR3/PDMUsb.cpp

    r53031 r53062  
    458458 *
    459459 * @returns VBox status code.
    460  * @param   pVM             Pointer to the VM.
    461  * @param   pUsbDev         The USB device emulation.
    462  * @param   iInstance       -1 if not called by pdmR3UsbInstantiateDevices().
    463  * @param   pUuid           The UUID for this device.
    464  * @param   ppInstanceNode  Pointer to the device instance pointer. This is set to NULL if inserted
    465  *                          into the tree or cleaned up.
    466  *
    467  *                          In the pdmR3UsbInstantiateDevices() case (iInstance != -1) this is
    468  *                          the actual instance node and will not be cleaned up.
    469  *
    470  * @parma   iUsbVersion     The USB version preferred by the device.
     460 * @param   pVM                 Pointer to the VM.
     461 * @param   pUsbDev             The USB device emulation.
     462 * @param   iInstance           -1 if not called by pdmR3UsbInstantiateDevices().
     463 * @param   pUuid               The UUID for this device.
     464 * @param   ppInstanceNode      Pointer to the device instance pointer. This is set to NULL if inserted
     465 *                              into the tree or cleaned up.
     466 *
     467 *                              In the pdmR3UsbInstantiateDevices() case (iInstance != -1) this is
     468 *                              the actual instance node and will not be cleaned up.
     469 *
     470 * @param   iUsbVersion         The USB version preferred by the device.
     471 * @param   pszCaptureFilename  Path to the file for USB traffic capturing, optional.
    471472 */
    472473static int pdmR3UsbCreateDevice(PVM pVM, PPDMUSBHUB pHub, PPDMUSB pUsbDev, int iInstance, PCRTUUID pUuid,
    473                                 PCFGMNODE *ppInstanceNode, uint32_t iUsbVersion)
     474                                PCFGMNODE *ppInstanceNode, uint32_t iUsbVersion, const char *pszCaptureFilename)
    474475{
    475476    const bool fAtRuntime = iInstance == -1;
     
    629630         */
    630631        Log(("PDM: Attaching it...\n"));
    631         rc = pHub->Reg.pfnAttachDevice(pHub->pDrvIns, pUsbIns, &pUsbIns->Internal.s.iPort);
     632        rc = pHub->Reg.pfnAttachDevice(pHub->pDrvIns, pUsbIns, pszCaptureFilename, &pUsbIns->Internal.s.iPort);
    632633        if (RT_SUCCESS(rc))
    633634        {
     
    856857         */
    857858        rc = pdmR3UsbCreateDevice(pVM, pHub, paUsbDevs[i].pUsbDev, paUsbDevs[i].iInstance, &paUsbDevs[i].Uuid,
    858                                   &paUsbDevs[i].pNode, iUsbVersion);
     859                                  &paUsbDevs[i].pNode, iUsbVersion, NULL);
    859860        if (RT_FAILURE(rc))
    860861            return rc;
     
    872873 *
    873874 * @returns VBox status code.
    874  * @param   pUVM            The user mode VM handle.
    875  * @param   pszDeviceName   The name of the PDM device to instantiate.
    876  * @param   pInstanceNode   The instance CFGM node.
    877  * @param   pUuid           The UUID to be associated with the device.
     875 * @param   pUVM                The user mode VM handle.
     876 * @param   pszDeviceName       The name of the PDM device to instantiate.
     877 * @param   pInstanceNode       The instance CFGM node.
     878 * @param   pUuid               The UUID to be associated with the device.
     879 * @param   pszCaptureFilename  Path to the file for USB traffic capturing, optional.
    878880 *
    879881 * @thread EMT
    880882 */
    881 VMMR3DECL(int) PDMR3UsbCreateEmulatedDevice(PUVM pUVM, const char *pszDeviceName, PCFGMNODE pInstanceNode, PCRTUUID pUuid)
     883VMMR3DECL(int) PDMR3UsbCreateEmulatedDevice(PUVM pUVM, const char *pszDeviceName, PCFGMNODE pInstanceNode, PCRTUUID pUuid,
     884                                            const char *pszCaptureFilename)
    882885{
    883886    /*
     
    929932     * Create and attach the device.
    930933     */
    931     rc = pdmR3UsbCreateDevice(pVM, pHub, pUsbDev, -1, pUuid, &pInstanceNode, iUsbVersion);
     934    rc = pdmR3UsbCreateDevice(pVM, pHub, pUsbDev, -1, pUuid, &pInstanceNode, iUsbVersion, pszCaptureFilename);
    932935    AssertRCReturn(rc, rc);
    933936
     
    943946 *
    944947 * @returns VBox status code.
    945  * @param   pUVM            The user mode VM handle.
    946  * @param   pUuid           The UUID to be associated with the device.
    947  * @param   fRemote         Whether it's a remove or local device.
    948  * @param   pszAddress      The address string.
    949  * @param   pvBackend       Pointer to the backend.
    950  * @param   iUsbVersion     The preferred USB version.
    951  * @param   fMaskedIfs      The interfaces to hide from the guest.
     948 * @param   pUVM                The user mode VM handle.
     949 * @param   pUuid               The UUID to be associated with the device.
     950 * @param   fRemote             Whether it's a remove or local device.
     951 * @param   pszAddress          The address string.
     952 * @param   pvBackend           Pointer to the backend.
     953 * @param   iUsbVersion         The preferred USB version.
     954 * @param   fMaskedIfs          The interfaces to hide from the guest.
     955 * @param   pszCaptureFilename  Path to the file for USB traffic capturing, optional.
    952956 */
    953957VMMR3DECL(int) PDMR3UsbCreateProxyDevice(PUVM pUVM, PCRTUUID pUuid, bool fRemote, const char *pszAddress, void *pvBackend,
    954                                          uint32_t iUsbVersion, uint32_t fMaskedIfs)
     958                                         uint32_t iUsbVersion, uint32_t fMaskedIfs, const char *pszCaptureFilename)
    955959{
    956960    /*
     
    10171021     * Finally, try to create it.
    10181022     */
    1019     rc = pdmR3UsbCreateDevice(pVM, pHub, pUsbDev, -1, pUuid, &pInstance, iUsbVersion);
     1023    rc = pdmR3UsbCreateDevice(pVM, pHub, pUsbDev, -1, pUuid, &pInstance, iUsbVersion, pszCaptureFilename);
    10201024    if (RT_FAILURE(rc) && pInstance)
    10211025        CFGMR3RemoveNode(pInstance);
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