VirtualBox

Changeset 75740 in vbox


Ignore:
Timestamp:
Nov 26, 2018 3:59:11 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
126941
Message:

HGCM,VMMDev: Made the HGCM command/message completion callback return a status code so VMMDev can indicate that a guest call was cancelled and the service could implement a way of dealing with that, rather than just dropping information. Ran into this with SIGCHLD delivery interrupting GUEST_MSG_WAIT and dropping crucial HOST_SESSION_CLOSE close messages, causing the host to wait until sometime timed out and probably left stuff/processes behind.

Location:
trunk
Files:
5 edited

Legend:

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

    r75500 r75740  
    20682068     * Notify the guest on a command completion.
    20692069     *
     2070     * @returns VINF_SUCCESS or VERR_CANCELLED if the guest canceled the call.
    20702071     * @param   pInterface          Pointer to this interface.
    20712072     * @param   rc                  The return code (VBox error code).
    20722073     * @param   pCmd                A pointer that identifies the completed command.
    20732074     */
    2074     DECLR3CALLBACKMEMBER(void, pfnCompleted,(PPDMIHGCMPORT pInterface, int32_t rc, PVBOXHGCMCMD pCmd));
     2075    DECLR3CALLBACKMEMBER(int, pfnCompleted,(PPDMIHGCMPORT pInterface, int32_t rc, PVBOXHGCMCMD pCmd));
    20752076
    20762077    /**
     
    20852086} PDMIHGCMPORT;
    20862087/** PDMIHGCMPORT interface ID. */
    2087 # define PDMIHGCMPORT_IID                       "10ca89d3-18ef-44d3-535e-ca46532e3caa"
     2088# define PDMIHGCMPORT_IID                       "e82b1709-c245-4ccc-1611-0e6d50d93cbc"
    20882089
    20892090
  • trunk/src/VBox/Devices/VMMDev/VMMDevHGCM.cpp

    r75585 r75740  
    12461246/** Update HGCM request in the guest memory and mark it as completed.
    12471247 *
     1248 * @returns VINF_SUCCESS or VERR_CANCELLED.
    12481249 * @param   pInterface      Pointer to this PDM interface.
    12491250 * @param   result          HGCM completion status code (VBox status code).
     
    12521253 * @thread EMT
    12531254 */
    1254 DECLCALLBACK(void) hgcmCompletedWorker(PPDMIHGCMPORT pInterface, int32_t result, PVBOXHGCMCMD pCmd)
     1255static int hgcmCompletedWorker(PPDMIHGCMPORT pInterface, int32_t result, PVBOXHGCMCMD pCmd)
    12551256{
    12561257    PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDevState, IHGCMPort);
     
    12721273         */
    12731274        LogFlowFunc(("VINF_HGCM_SAVE_STATE for command %p\n", pCmd));
    1274         return;
     1275        return VINF_SUCCESS;
    12751276    }
    12761277
     
    14481449            VMMDevNotifyGuest(pThis, VMMDEV_EVENT_HGCM);
    14491450        }
     1451
     1452        /* Set the status to success for now, though we might consider passing
     1453           along the vmmdevHGCMCompleteCallRequest errors... */
     1454        rc = VINF_SUCCESS;
    14501455    }
    14511456    else
    14521457    {
    14531458        LogFlowFunc(("Cancelled command %p\n", pCmd));
     1459        rc = VERR_CANCELLED;
    14541460    }
    14551461
     
    14721478        STAM_REL_PROFILE_ADD_PERIOD(&pThis->StatHgcmCmdTotal,  tsNow - tsArrival);
    14731479#endif
    1474 }
    1475 
    1476 /** HGCM callback for request completion. Forwards to hgcmCompletedWorker.
    1477  *
     1480
     1481    return rc;
     1482}
     1483
     1484/**
     1485 * HGCM callback for request completion. Forwards to hgcmCompletedWorker.
     1486 *
     1487 * @returns VINF_SUCCESS or VERR_CANCELLED.
    14781488 * @param   pInterface      Pointer to this PDM interface.
    14791489 * @param   result          HGCM completion status code (VBox status code).
    14801490 * @param   pCmd            Completed command, which contains updated host parameters.
    14811491 */
    1482 DECLCALLBACK(void) hgcmCompleted(PPDMIHGCMPORT pInterface, int32_t result, PVBOXHGCMCMD pCmd)
     1492DECLCALLBACK(int) hgcmCompleted(PPDMIHGCMPORT pInterface, int32_t result, PVBOXHGCMCMD pCmd)
    14831493{
    14841494#if 0 /* This seems to be significantly slower.  Half of MsgTotal time seems to be spend here. */
     
    14941504                                   (PFNRT)hgcmCompletedWorker, 3, pInterface, result, pCmd);
    14951505    AssertRC(rc);
     1506    return VINF_SUCCESS; /* cannot tell if canceled or not... */
    14961507#else
    14971508    STAM_GET_TS(pCmd->tsComplete);
    14981509    VBOXDD_HGCMCALL_COMPLETED_REQ(pCmd, result);
    1499     hgcmCompletedWorker(pInterface, result, pCmd);
     1510    return hgcmCompletedWorker(pInterface, result, pCmd);
    15001511#endif
    15011512}
  • trunk/src/VBox/Devices/VMMDev/VMMDevHGCM.h

    r75537 r75740  
    2929int vmmdevHGCMCancel2(VMMDevState *pVMMDevState, RTGCPHYS GCPtr);
    3030
    31 DECLCALLBACK(void) hgcmCompleted(PPDMIHGCMPORT pInterface, int32_t result, PVBOXHGCMCMD pCmdPtr);
     31DECLCALLBACK(int) hgcmCompleted(PPDMIHGCMPORT pInterface, int32_t result, PVBOXHGCMCMD pCmdPtr);
    3232DECLCALLBACK(bool) hgcmIsCmdRestored(PPDMIHGCMPORT pInterface, PVBOXHGCMCMD pCmd);
    3333
  • trunk/src/VBox/Main/include/HGCMThread.h

    r75541 r75740  
    4444 *                  or from HGCM.
    4545 * @param pMsgCore  Pointer to just processed message.
    46  */
    47 typedef DECLCALLBACK(void) HGCMMSGCALLBACK(int32_t result, HGCMMsgCore *pMsgCore);
     46 *
     47 * @return Restricted set of VBox status codes when guest call message:
     48 * @retval VINF_SUCCESS on success
     49 * @retval VERR_CANCELLED if the request was cancelled.
     50 * @retval VERR_ALREADY_RESET if the VM is resetting.
     51 * @retval VERR_NOT_AVAILABLE if HGCM has been disconnected from the VMMDev
     52 *         (shouldn't happen).
     53 */
     54typedef DECLCALLBACK(int) HGCMMSGCALLBACK(int32_t result, HGCMMsgCore *pMsgCore);
     55/** Pointer to a message completeion callback function. */
    4856typedef HGCMMSGCALLBACK *PHGCMMSGCALLBACK;
    4957
  • trunk/src/VBox/Main/src-client/HGCM.cpp

    r75574 r75740  
    895895
    896896
    897 static DECLCALLBACK(void) hgcmMsgCompletionCallback(int32_t result, HGCMMsgCore *pMsgCore)
     897static DECLCALLBACK(int) hgcmMsgCompletionCallback(int32_t result, HGCMMsgCore *pMsgCore)
    898898{
    899899    /* Call the VMMDev port interface to issue IRQ notification. */
     
    902902    LogFlow(("MAIN::hgcmMsgCompletionCallback: message %p\n", pMsgCore));
    903903
    904     if (pMsgHdr->pHGCMPort && !g_fResetting)
    905     {
    906         pMsgHdr->pHGCMPort->pfnCompleted(pMsgHdr->pHGCMPort, g_fSaveState? VINF_HGCM_SAVE_STATE: result, pMsgHdr->pCmd);
    907     }
     904    if (pMsgHdr->pHGCMPort)
     905    {
     906        if (!g_fResetting)
     907            return pMsgHdr->pHGCMPort->pfnCompleted(pMsgHdr->pHGCMPort,
     908                                                    g_fSaveState ? VINF_HGCM_SAVE_STATE : result, pMsgHdr->pCmd);
     909        return VERR_ALREADY_RESET; /* best I could find. */
     910    }
     911    return VERR_NOT_AVAILABLE;
    908912}
    909913
     
    17231727#ifdef VBOX_WITH_CRHGSMI
    17241728
    1725 static DECLCALLBACK(void) hgcmMsgFastCallCompletionCallback(int32_t result, HGCMMsgCore *pMsgCore)
     1729static DECLCALLBACK(int) hgcmMsgFastCallCompletionCallback(int32_t result, HGCMMsgCore *pMsgCore)
    17261730{
    17271731    /* Call the VMMDev port interface to issue IRQ notification. */
     
    17311735    if (pMsg->pfnCompletion)
    17321736        pMsg->pfnCompletion(result, pMsg->u32Function, &pMsg->Param, pMsg->pvCompletion);
     1737    return VINF_SUCCESS;
    17331738}
    17341739
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