VirtualBox

Changeset 34867 in vbox for trunk/src


Ignore:
Timestamp:
Dec 9, 2010 10:33:41 AM (14 years ago)
Author:
vboxsync
Message:

GuestControl/VBoxService: Implemented dynamic input buffer size handling, raised default 64K -> 1MB.

Location:
trunk/src/VBox/Additions/common/VBoxService
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.cpp

    r34406 r34867  
    153153
    154154                case HOST_EXEC_SET_INPUT:
    155                     rc = VBoxServiceControlExecHandleCmdSetInput(g_GuestControlSvcClientID, uNumParms);
     155                    /** @todo Make buffer size configurable via guest properties/argv! */
     156                    rc = VBoxServiceControlExecHandleCmdSetInput(g_GuestControlSvcClientID, uNumParms, _1M /* Buffer size */);
    156157                    break;
    157158
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlExec.cpp

    r34709 r34867  
    104104    {
    105105        size_t cbToWrite = pStdInBuf->cbSize - pStdInBuf->cbOffset;
    106         cbToWrite = RT_MIN(cbToWrite, _64K);
     106        cbToWrite = RT_MIN(cbToWrite, _1M);
    107107        *pfClose = false;
    108108        if (cbToWrite && pStdInBuf->fAlive)
     
    15971597 *                                      offering.
    15981598 */
    1599 int VBoxServiceControlExecHandleCmdSetInput(uint32_t u32ClientId, uint32_t uNumParms)
     1599int VBoxServiceControlExecHandleCmdSetInput(uint32_t u32ClientId, uint32_t uNumParms, size_t cbMaxBufSize)
    16001600{
    16011601    uint32_t uContextID;
    16021602    uint32_t uPID;
    16031603    uint32_t uFlags;
    1604     uint8_t  abBuffer[_64K];
    16051604    uint32_t cbSize;
    16061605
    1607     if (uNumParms != 5)
    1608         return VERR_INVALID_PARAMETER;
     1606    AssertReturn(RT_IS_POWER_OF_TWO(cbMaxBufSize), VERR_INVALID_PARAMETER);
     1607    uint8_t *pabBuffer = (uint8_t*)RTMemAlloc(cbMaxBufSize);
     1608    AssertPtrReturn(pabBuffer, VERR_NO_MEMORY);
    16091609
    16101610    /*
     
    16131613    int rc = VbglR3GuestCtrlExecGetHostCmdInput(u32ClientId, uNumParms,
    16141614                                                &uContextID, &uPID, &uFlags,
    1615                                                 abBuffer, sizeof(abBuffer), &cbSize);
     1615                                                pabBuffer, cbMaxBufSize, &cbSize);
    16161616    if (RT_FAILURE(rc))
    16171617    {
     
    16191619    }
    16201620    else if (   cbSize <= 0
    1621              || cbSize > sizeof(abBuffer))
     1621             || cbSize >  cbMaxBufSize)
    16221622    {
    16231623        VBoxServiceError("ControlExec: Input size is invalid! cbSize=%u\n", cbSize);
     
    16521652             */
    16531653            uint32_t cbWritten;
    1654             rc = VBoxServiceControlExecWritePipeBuffer(&pData->stdIn, abBuffer, cbSize, fPendingClose, &cbWritten);
     1654            rc = VBoxServiceControlExecWritePipeBuffer(&pData->stdIn, pabBuffer, cbSize, fPendingClose, &cbWritten);
    16551655#ifdef DEBUG
    16561656            VBoxServiceVerbose(4, "ControlExec: Written to StdIn buffer (PID %u): rc=%Rrc, uFlags=0x%x, cbAlloc=%u, cbSize=%u, cbOffset=%u\n",
     
    16921692            rc = VERR_NOT_FOUND; /* PID not found! */
    16931693    }
     1694    RTMemFree(pabBuffer);
    16941695    VBoxServiceVerbose(3, "ControlExec: VBoxServiceControlExecHandleCmdSetInput returned with %Rrc\n", rc);
    16951696    return rc;
     
    17131714    int rc = VbglR3GuestCtrlExecGetHostCmdOutput(u32ClientId, uNumParms,
    17141715                                                 &uContextID, &uPID, &uHandleID, &uFlags);
    1715     if (RT_FAILURE(rc))
    1716     {
    1717         VBoxServiceError("ControlExec: Failed to retrieve exec output command! Error: %Rrc\n", rc);
    1718     }
    1719     else
     1716    if (RT_SUCCESS(rc))
    17201717    {
    17211718        PVBOXSERVICECTRLTHREAD pNode = VBoxServiceControlExecFindProcess(uPID);
     
    17251722            AssertPtr(pData);
    17261723
    1727             const uint32_t cbSize = _4K;
     1724            const uint32_t cbSize = _1M;
    17281725            uint32_t cbRead = cbSize;
    17291726            uint8_t *pBuf = (uint8_t*)RTMemAlloc(cbSize);
     
    17491746            rc = VERR_NOT_FOUND; /* PID not found! */
    17501747    }
     1748    else
     1749        VBoxServiceError("ControlExec: Failed to retrieve exec output command! Error: %Rrc\n", rc);
    17511750    VBoxServiceVerbose(3, "ControlExec: VBoxServiceControlExecHandleCmdGetOutput returned with %Rrc\n", rc);
    17521751    return rc;
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceInternal.h

    r34273 r34867  
    9393
    9494/** The service name (needed for mutex creation on Windows). */
    95 #define VBOXSERVICE_NAME           "VBoxService"
     95#define VBOXSERVICE_NAME            "VBoxService"
    9696
    9797#ifdef RT_OS_WINDOWS
     
    292292#ifdef VBOX_WITH_GUEST_CONTROL
    293293extern int          VBoxServiceControlExecHandleCmdStartProcess(uint32_t u32ClientId, uint32_t uNumParms);
    294 extern int          VBoxServiceControlExecHandleCmdSetInput(uint32_t u32ClientId, uint32_t uNumParms);
     294extern int          VBoxServiceControlExecHandleCmdSetInput(uint32_t u32ClientId, uint32_t uNumParms, size_t cbMaxBufSize);
    295295extern int          VBoxServiceControlExecHandleCmdGetOutput(uint32_t u32ClientId, uint32_t uNumParms);
    296296extern int          VBoxServiceControlExecProcess(uint32_t uContext, const char *pszCmd, uint32_t uFlags,
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