VirtualBox

Ignore:
Timestamp:
Nov 29, 2018 7:09:21 AM (6 years ago)
Author:
vboxsync
Message:

VBoxGuestControl: Optimizing message handling - part 3. bugref:9313

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibGuestCtrl.cpp

    r75804 r75807  
    8383 *
    8484 * @returns VBox status code.
    85  * @param   uClientId       The client ID returned by VbglR3GuestCtrlConnect().
     85 * @param   idClient        The client ID returned by VbglR3GuestCtrlConnect().
    8686 * @param   pidMsg          Where to store the message id.
    8787 * @param   pcParameters    Where to store the number  of parameters which will
    8888 *                          be received in a second call to the host.
    8989 */
    90 static int vbglR3GuestCtrlMsgWaitFor(uint32_t uClientId, uint32_t *pidMsg, uint32_t *pcParameters)
     90static int vbglR3GuestCtrlMsgWaitFor(uint32_t idClient, uint32_t *pidMsg, uint32_t *pcParameters)
    9191{
    9292    AssertPtrReturn(pidMsg, VERR_INVALID_POINTER);
     
    9494
    9595    HGCMMsgCmdWaitFor Msg;
    96     VBGL_HGCM_HDR_INIT(&Msg.hdr, uClientId,
     96    VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient,
    9797                       GUEST_MSG_WAIT,      /* Tell the host we want our next command. */
    9898                       2);                  /* Just peek for the next message! */
     
    275275
    276276/**
     277 * Checks if the host supports the optimizes message and session functions.
     278 *
     279 * @returns true / false.
     280 * @param   idClient    The client ID returned by VbglR3GuestCtrlConnect().
     281 *                      We may need to use this for checking.
     282 * @since   6.0
     283 */
     284VBGLR3DECL(bool) VbglR3GuestCtrlSupportsOptimizations(uint32_t idClient)
     285{
     286    return vbglR3GuestCtrlSupportsPeekGetCancel(idClient);
     287}
     288
     289
     290/**
     291 * Make us the guest control master client.
     292 *
     293 * @returns VBox status code.
     294 * @param   idClient    The client ID returned by VbglR3GuestCtrlConnect().
     295 */
     296VBGLR3DECL(int) VbglR3GuestCtrlMakeMeMaster(uint32_t idClient)
     297{
     298    int rc;
     299    do
     300    {
     301        VBGLIOCHGCMCALL Hdr;
     302        VBGL_HGCM_HDR_INIT(&Hdr, idClient, GUEST_MAKE_ME_MASTER, 0);
     303        rc = VbglR3HGCMCall(&Hdr, sizeof(Hdr));
     304    } while (rc == VERR_INTERRUPTED);
     305    return rc;
     306}
     307
     308
     309
     310/**
    277311 * Peeks at the next host message, waiting for one to turn up.
    278312 *
     
    299333        VbglHGCMParmUInt32Set(&Msg.num_parms, 0);
    300334        rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
     335        LogRel(("VbglR3GuestCtrlMsgPeekWait -> %Rrc\n", rc));
    301336        if (RT_SUCCESS(rc))
    302337        {
     
    342377 *
    343378 * @return  IPRT status code.
    344  * @param   uClientId       The client ID returned by VbglR3GuestCtrlConnect().
     379 * @param   idClient        The client ID returned by VbglR3GuestCtrlConnect().
    345380 * @param   uValue          The value to filter messages for.
    346381 * @param   uMaskAdd        Filter mask to add.
    347382 * @param   uMaskRemove     Filter mask to remove.
    348383 */
    349 VBGLR3DECL(int) VbglR3GuestCtrlMsgFilterSet(uint32_t uClientId, uint32_t uValue, uint32_t uMaskAdd, uint32_t uMaskRemove)
     384VBGLR3DECL(int) VbglR3GuestCtrlMsgFilterSet(uint32_t idClient, uint32_t uValue, uint32_t uMaskAdd, uint32_t uMaskRemove)
    350385{
    351386    HGCMMsgCmdFilterSet Msg;
    352387
    353388    /* Tell the host we want to set a filter. */
    354     VBGL_HGCM_HDR_INIT(&Msg.hdr, uClientId, GUEST_MSG_FILTER_SET, 4);
     389    VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, GUEST_MSG_FILTER_SET, 4);
    355390    VbglHGCMParmUInt32Set(&Msg.value, uValue);
    356391    VbglHGCMParmUInt32Set(&Msg.mask_add, uMaskAdd);
     
    387422}
    388423
     424/**
     425 * Tell the host to skip the current message replying VERR_NOT_SUPPORTED
     426 *
     427 * @return  IPRT status code.
     428 * @param   idClient        The client ID returned by VbglR3GuestCtrlConnect().
     429 */
     430VBGLR3DECL(int) VbglR3GuestCtrlMsgSkip(uint32_t idClient)
     431{
     432    if (vbglR3GuestCtrlSupportsPeekGetCancel(idClient))
     433    {
     434        VBGLIOCHGCMCALL Hdr;
     435        VBGL_HGCM_HDR_INIT(&Hdr, idClient, GUEST_MSG_SKIP, 0);
     436        return VbglR3HGCMCall(&Hdr, sizeof(Hdr));
     437    }
     438
     439    /* This is generally better than nothing... */
     440    return VbglR3GuestCtrlMsgSkipOld(idClient);
     441}
     442
    389443
    390444/**
     
    393447 *
    394448 * @return  IPRT status code.
    395  * @param   uClientId       The client ID returned by VbglR3GuestCtrlConnect().
    396  */
    397 VBGLR3DECL(int) VbglR3GuestCtrlMsgSkipOld(uint32_t uClientId)
     449 * @param   idClient        The client ID returned by VbglR3GuestCtrlConnect().
     450 */
     451VBGLR3DECL(int) VbglR3GuestCtrlMsgSkipOld(uint32_t idClient)
    398452{
    399453    HGCMMsgCmdSkip Msg;
    400454
    401455    /* Tell the host we want to skip the current assigned command. */
    402     VBGL_HGCM_HDR_INIT(&Msg.hdr, uClientId, GUEST_MSG_SKIP_OLD, 1);
     456    VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, GUEST_MSG_SKIP_OLD, 1);
    403457    VbglHGCMParmUInt32Set(&Msg.flags, 0 /* Flags, unused */);
    404458    return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
     
    410464 *
    411465 * @returns VBox status code.
    412  * @param   uClientId     The client ID returned by VbglR3GuestCtrlConnect().
    413  */
    414 VBGLR3DECL(int) VbglR3GuestCtrlCancelPendingWaits(uint32_t uClientId)
     466 * @param   idClient        The client ID returned by VbglR3GuestCtrlConnect().
     467 */
     468VBGLR3DECL(int) VbglR3GuestCtrlCancelPendingWaits(uint32_t idClient)
    415469{
    416470    HGCMMsgCancelPendingWaits Msg;
    417     VBGL_HGCM_HDR_INIT(&Msg.hdr, uClientId, GUEST_MSG_CANCEL, 0);
     471    VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, GUEST_MSG_CANCEL, 0);
    418472    return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
     473}
     474
     475
     476/**
     477 * Prepares a session.
     478 * @since   6.0
     479 * @sa      GUEST_SESSION_PREPARE
     480 */
     481VBGLR3DECL(int) VbglR3GuestCtrlSessionPrepare(uint32_t idClient, uint32_t idSession, void const *pvKey, uint32_t cbKey)
     482{
     483    int rc;
     484    do
     485    {
     486        struct
     487        {
     488            VBGLIOCHGCMCALL         Hdr;
     489            HGCMFunctionParameter   idSession;
     490            HGCMFunctionParameter   pKey;
     491        } Msg;
     492        VBGL_HGCM_HDR_INIT(&Msg.Hdr, idClient, GUEST_SESSION_PREPARE, 2);
     493        VbglHGCMParmUInt32Set(&Msg.idSession, idSession);
     494        VbglHGCMParmPtrSet(&Msg.pKey, (void *)pvKey, cbKey);
     495        rc = VbglR3HGCMCall(&Msg.Hdr, sizeof(Msg));
     496    } while (rc == VERR_INTERRUPTED);
     497    return rc;
     498}
     499
     500
     501/**
     502 * Accepts a session.
     503 * @since   6.0
     504 * @sa      GUEST_SESSION_ACCEPT
     505 */
     506VBGLR3DECL(int) VbglR3GuestCtrlSessionAccept(uint32_t idClient, uint32_t idSession, void const *pvKey, uint32_t cbKey)
     507{
     508    int rc;
     509    do
     510    {
     511        struct
     512        {
     513            VBGLIOCHGCMCALL         Hdr;
     514            HGCMFunctionParameter   idSession;
     515            HGCMFunctionParameter   pKey;
     516        } Msg;
     517        VBGL_HGCM_HDR_INIT(&Msg.Hdr, idClient, GUEST_SESSION_ACCEPT, 2);
     518        VbglHGCMParmUInt32Set(&Msg.idSession, idSession);
     519        VbglHGCMParmPtrSet(&Msg.pKey, (void *)pvKey, cbKey);
     520        rc = VbglR3HGCMCall(&Msg.Hdr, sizeof(Msg));
     521    } while (rc == VERR_INTERRUPTED);
     522    return rc;
     523}
     524
     525
     526/**
     527 * Cancels a prepared session.
     528 * @since   6.0
     529 * @sa      GUEST_SESSION_CANCEL_PREPARED
     530 */
     531VBGLR3DECL(int) VbglR3GuestCtrlSessionCancelPrepared(uint32_t idClient, uint32_t idSession)
     532{
     533    int rc;
     534    do
     535    {
     536        struct
     537        {
     538            VBGLIOCHGCMCALL         Hdr;
     539            HGCMFunctionParameter   idSession;
     540        } Msg;
     541        VBGL_HGCM_HDR_INIT(&Msg.Hdr, idClient, GUEST_SESSION_CANCEL_PREPARED, 1);
     542        VbglHGCMParmUInt32Set(&Msg.idSession, idSession);
     543        rc = VbglR3HGCMCall(&Msg.Hdr, sizeof(Msg));
     544    } while (rc == VERR_INTERRUPTED);
     545    return rc;
    419546}
    420547
     
    442569
    443570
    444 VBGLR3DECL(int) VbglR3GuestCtrlSessionNotify(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uType, uint32_t uResult)
     571VBGLR3DECL(int) VbglR3GuestCtrlSessionNotify(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uType, int32_t iResult)
    445572{
    446573    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     
    450577    VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
    451578    VbglHGCMParmUInt32Set(&Msg.type, uType);
    452     VbglHGCMParmUInt32Set(&Msg.result, uResult);
     579    VbglHGCMParmUInt32Set(&Msg.result, (uint32_t)iResult);
    453580
    454581    return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
     
    497624                *pidSession = VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(pCtx->uContextID);
    498625        }
     626        /* Try get the context ID so we can inform the host about this message retrival failure. */
     627        else if (Msg.context.u.value32 != HOST_SESSION_CREATE)
     628            Msg.context.GetUInt32(&pCtx->uContextID);
     629
    499630    } while (rc == VERR_INTERRUPTED && g_fVbglR3GuestCtrlHavePeekGetCancel);
    500631    return rc;
     
    725856        HGCMMsgProcOutput Msg;
    726857        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, vbglR3GuestCtrlGetMsgFunctionNo(pCtx->uClientID), pCtx->uNumParms);
    727         VbglHGCMParmUInt32Set(&Msg.context, 0);
     858        VbglHGCMParmUInt32Set(&Msg.context, HOST_EXEC_GET_OUTPUT);
    728859        VbglHGCMParmUInt32Set(&Msg.pid, 0);
    729860        VbglHGCMParmUInt32Set(&Msg.handle, 0);
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