VirtualBox

Changeset 75406 in vbox


Ignore:
Timestamp:
Nov 12, 2018 7:49:08 PM (6 years ago)
Author:
vboxsync
Message:

VMMDev/HGCM: Added PDM interface + HGCM server helper for finding out if a command/call is being resubmitted on restore or not. This is handy for returning returning an async wait call to the guest upon restore. bugref:3544

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/hgcmsvc.h

    r69107 r75406  
    8282    /** The service disconnects the client. */
    8383    DECLR3CALLBACKMEMBER(void, pfnDisconnectClient, (void *pvInstance, uint32_t u32ClientID));
     84
     85    /**
     86     * Check if the @a callHandle is for a call restored and re-submitted from saved state.
     87     *
     88     * @returns true if restored, false if not.
     89     * @param   callHandle      The call we're checking up on.
     90     */
     91    DECLR3CALLBACKMEMBER(bool, pfnIsCallRestored, (VBOXHGCMCALLHANDLE callHandle));
     92
    8493} VBOXHGCMSVCHELPERS;
    8594
     
    392401     *  Return code is passed to pfnCallComplete callback.
    393402     */
    394     DECLR3CALLBACKMEMBER(void, pfnCall, (void *pvService, VBOXHGCMCALLHANDLE callHandle, uint32_t u32ClientID, void *pvClient, uint32_t function, uint32_t cParms, VBOXHGCMSVCPARM paParms[]));
     403    DECLR3CALLBACKMEMBER(void, pfnCall, (void *pvService, VBOXHGCMCALLHANDLE callHandle, uint32_t u32ClientID, void *pvClient,
     404                                         uint32_t function, uint32_t cParms, VBOXHGCMSVCPARM paParms[]));
    395405
    396406    /** Host Service entry point meant for privileged features invisible to the guest.
  • trunk/include/VBox/vmm/pdmifs.h

    r73766 r75406  
    20712071     * @param   rc                  The return code (VBox error code).
    20722072     * @param   pCmd                A pointer that identifies the completed command.
    2073      *
    2074      * @returns VBox status code
    20752073     */
    20762074    DECLR3CALLBACKMEMBER(void, pfnCompleted,(PPDMIHGCMPORT pInterface, int32_t rc, PVBOXHGCMCMD pCmd));
     2075
     2076    /**
     2077     * Checks if @a pCmd was restored & resubmitted from saved state.
     2078     *
     2079     * @returns true if restored, false if not.
     2080     * @param   pInterface          Pointer to this interface.
     2081     * @param   pCmd                The command we're checking on.
     2082     */
     2083    DECLR3CALLBACKMEMBER(bool, pfnIsCmdRestored,(PPDMIHGCMPORT pInterface, PVBOXHGCMCMD pCmd));
    20772084
    20782085} PDMIHGCMPORT;
    20792086/** PDMIHGCMPORT interface ID. */
    2080 # define PDMIHGCMPORT_IID                       "e00a0cbf-b75a-45c3-87f4-41cddbc5ae0b"
     2087# define PDMIHGCMPORT_IID                       "10ca89d3-18ef-44d3-535e-ca46532e3caa"
    20812088
    20822089
  • trunk/src/VBox/Devices/VMMDev/VMMDev.cpp

    r73698 r75406  
    41224122    /* HGCM port */
    41234123    pThis->IHGCMPort.pfnCompleted           = hgcmCompleted;
     4124    pThis->IHGCMPort.pfnIsCmdRestored       = hgcmIsCmdRestored;
    41244125#endif
    41254126
  • trunk/src/VBox/Devices/VMMDev/VMMDevHGCM.cpp

    r72054 r75406  
    128128    bool                fCancelled;
    129129
     130    /** Whether the command was restored from saved state. */
     131    bool                fRestored;
     132
    130133    /** GC physical address of the guest request. */
    131134    RTGCPHYS            GCPhys;
     
    137140    VMMDevRequestType   enmRequestType;
    138141
    139     union {
     142    union
     143    {
    140144        struct
    141145        {
     
    10631067    if (result == VINF_HGCM_SAVE_STATE)
    10641068    {
    1065         /* If the completion routine was called because HGCM saves its state,
    1066          * then currently nothing to be done here. The pCmd stays in the list
    1067          * and will be saved later when the VMMDev state will be saved.
     1069        /* If the completion routine was called while the HGCM service saves its state,
     1070         * then currently nothing to be done here.  The pCmd stays in the list and will
     1071         * be saved later when the VMMDev state will be saved and re-submitted on load.
    10681072         *
    1069          * It it assumed that VMMDev saves state after the HGCM services,
    1070          * and, therefore, VBOXHGCMCMD structures are not removed by
    1071          * vmmdevHGCMSaveState from the list, while HGCM uses them.
     1073         * It it assumed that VMMDev saves state after the HGCM services (VMMDev driver
     1074         * attached by constructor before it registers its SSM state), and, therefore,
     1075         * VBOXHGCMCMD structures are not removed by vmmdevHGCMSaveState from the list,
     1076         * while HGCM uses them.
    10721077         */
    10731078        LogFlowFunc(("VINF_HGCM_SAVE_STATE for command %p\n", pCmd));
     
    12161221                                   (PFNRT)hgcmCompletedWorker, 3, pInterface, result, pCmd);
    12171222    AssertRC(rc);
     1223}
     1224
     1225/**
     1226 * @interface_method_impl{PDMIHGCMPORT, pfnIsCmdRestored}
     1227 */
     1228DECLCALLBACK(bool) hgcmIsCmdRestored(PPDMIHGCMPORT pInterface, PVBOXHGCMCMD pCmd)
     1229{
     1230    RT_NOREF(pInterface);
     1231    return pCmd && pCmd->fRestored;
    12181232}
    12191233
     
    16051619    else
    16061620        pCmd->fCancelled = false;
    1607 
     1621    pCmd->fRestored      = true;
    16081622    pCmd->enmRequestType = enmRequestType;
    16091623
     
    16491663    else
    16501664        pCmd->fCancelled = false;
    1651 
     1665    pCmd->fRestored      = true;
    16521666    pCmd->enmRequestType = enmRequestType;
    16531667
     
    16951709    else
    16961710        pCmd->fCancelled = false;
    1697 
     1711    pCmd->fRestored      = true;
    16981712    pCmd->enmRequestType = enmRequestType;
    16991713
  • trunk/src/VBox/Devices/VMMDev/VMMDevHGCM.h

    r71891 r75406  
    2929
    3030DECLCALLBACK(void) hgcmCompleted(PPDMIHGCMPORT pInterface, int32_t result, PVBOXHGCMCMD pCmdPtr);
     31DECLCALLBACK(bool) hgcmIsCmdRestored(PPDMIHGCMPORT pInterface, PVBOXHGCMCMD pCmd);
    3132
    3233int vmmdevHGCMSaveState(VMMDevState *pVMMDevState, PSSMHANDLE pSSM);
  • trunk/src/VBox/Main/src-client/HGCM.cpp

    r75385 r75406  
    132132        static DECLCALLBACK(void) svcHlpCallComplete(VBOXHGCMCALLHANDLE callHandle, int32_t rc);
    133133        static DECLCALLBACK(void) svcHlpDisconnectClient(void *pvInstance, uint32_t u32ClientId);
     134        static DECLCALLBACK(bool) svcHlpIsCallRestored(VBOXHGCMCALLHANDLE callHandle);
    134135
    135136    public:
     
    755756}
    756757
     758/**
     759 * @interface_method_impl{VBOXHGCMSVCHELPERS,pfnCallComplete}
     760 */
    757761/* static */ DECLCALLBACK(void) HGCMService::svcHlpCallComplete(VBOXHGCMCALLHANDLE callHandle, int32_t rc)
    758762{
     
    773777}
    774778
     779/**
     780 * @interface_method_impl{VBOXHGCMSVCHELPERS,pfnDisconnectClient}
     781 */
    775782/* static */ DECLCALLBACK(void) HGCMService::svcHlpDisconnectClient(void *pvInstance, uint32_t u32ClientId)
    776783{
     
    781788         pService->DisconnectClient(u32ClientId, true);
    782789     }
     790}
     791
     792/**
     793 * @interface_method_impl{VBOXHGCMSVCHELPERS,pfnIsCallRestored}
     794 */
     795/* static */ DECLCALLBACK(bool) HGCMService::svcHlpIsCallRestored(VBOXHGCMCALLHANDLE callHandle)
     796{
     797    HGCMMsgHeader *pMsgHdr = (HGCMMsgHeader *)(callHandle);
     798    AssertPtrReturn(pMsgHdr, false);
     799
     800    PVBOXHGCMCMD pCmd = pMsgHdr->pCmd;
     801    AssertPtrReturn(pCmd, false);
     802
     803    PPDMIHGCMPORT pHgcmPort = pMsgHdr->pHGCMPort;
     804    AssertPtrReturn(pHgcmPort, false);
     805
     806    return pHgcmPort->pfnIsCmdRestored(pHgcmPort, pCmd);
    783807}
    784808
     
    836860            m_svcHelpers.pvInstance          = this;
    837861            m_svcHelpers.pfnDisconnectClient = svcHlpDisconnectClient;
     862            m_svcHelpers.pfnIsCallRestored   = svcHlpIsCallRestored;
    838863
    839864            /* Execute the load request on the service thread. */
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