VirtualBox

Changeset 22988 in vbox


Ignore:
Timestamp:
Sep 14, 2009 6:57:38 AM (15 years ago)
Author:
vboxsync
Message:

VMM: Simplify AtError and AtRuntimeError registration and deregistration.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VM.cpp

    r22986 r22988  
    143143static void              vmR3AtDtor(PVM pVM);
    144144static DECLCALLBACK(int) vmR3Reset(PVM pVM);
    145 static DECLCALLBACK(int) vmR3AtStateDeregisterU(PUVM pUVM, PFNVMATSTATE pfnAtState, void *pvUser);
    146 static DECLCALLBACK(int) vmR3AtErrorRegisterU(PUVM pUVM, PFNVMATERROR pfnAtError, void *pvUser);
    147 static DECLCALLBACK(int) vmR3AtErrorDeregisterU(PUVM pUVM, PFNVMATERROR pfnAtError, void *pvUser);
    148145static int               vmR3SetErrorU(PUVM pUVM, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...);
    149 static DECLCALLBACK(int) vmR3AtRuntimeErrorRegisterU(PUVM pUVM, PFNVMATRUNTIMEERROR pfnAtRuntimeError, void *pvUser);
    150 static DECLCALLBACK(int) vmR3AtRuntimeErrorDeregisterU(PUVM pUVM, PFNVMATRUNTIMEERROR pfnAtRuntimeError, void *pvUser);
    151146
    152147
     
    425420     * Create and initialize the UVM.
    426421     */
    427     PUVM pUVM = (PUVM)RTMemAllocZ(RT_OFFSETOF(UVM, aCpus[cCpus]));
     422    PUVM pUVM = (PUVM)RTMemPageAllocZ(RT_OFFSETOF(UVM, aCpus[cCpus]));
    428423    AssertReturn(pUVM, VERR_NO_MEMORY);
    429424    pUVM->u32Magic = UVM_MAGIC;
     
    27832778{
    27842779    LogFlow(("VMR3AtErrorRegister: pfnAtError=%p pvUser=%p\n", pfnAtError, pvUser));
     2780
     2781    /*
     2782     * Validate input.
     2783     */
    27852784    AssertPtrReturn(pfnAtError, VERR_INVALID_PARAMETER);
    2786 
    2787     /*
    2788      * Make sure we're in EMT (to avoid the logging).
    2789      */
    2790     PVMREQ pReq;
    2791     int rc = VMR3ReqCallU(pUVM, VMCPUID_ANY, &pReq, RT_INDEFINITE_WAIT, 0, (PFNRT)vmR3AtErrorRegisterU, 3, pUVM, pfnAtError, pvUser);
    2792     if (RT_FAILURE(rc))
    2793         return rc;
    2794     rc = pReq->iStatus;
    2795     VMR3ReqFree(pReq);
    2796 
    2797     LogFlow(("VMR3AtErrorRegister: returns %Rrc\n", rc));
    2798     return rc;
    2799 }
    2800 
    2801 
    2802 /**
    2803  * Registers a VM error callback.
    2804  *
    2805  * @returns VBox status code.
    2806  * @param   pUVM            Pointer to the user mode VM structure.
    2807  * @param   pfnAtError      Pointer to callback.
    2808  * @param   pvUser          User argument.
    2809  * @thread  EMT
    2810  */
    2811 static DECLCALLBACK(int) vmR3AtErrorRegisterU(PUVM pUVM, PFNVMATERROR pfnAtError, void *pvUser)
    2812 {
     2785    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
     2786
    28132787    /*
    28142788     * Allocate a new record.
    28152789     */
    2816 
    28172790    PVMATERROR pNew = (PVMATERROR)MMR3HeapAllocU(pUVM, MM_TAG_VM, sizeof(*pNew));
    28182791    if (!pNew)
     
    28432816 * @thread  Any.
    28442817 */
    2845 VMMR3DECL(int)   VMR3AtErrorDeregister(PVM pVM, PFNVMATERROR pfnAtError, void *pvUser)
     2818VMMR3DECL(int) VMR3AtErrorDeregister(PVM pVM, PFNVMATERROR pfnAtError, void *pvUser)
    28462819{
    28472820    LogFlow(("VMR3AtErrorDeregister: pfnAtError=%p pvUser=%p\n", pfnAtError, pvUser));
     
    28502823     * Validate input.
    28512824     */
    2852     if (!pfnAtError)
    2853     {
    2854         AssertMsgFailed(("callback is required\n"));
    2855         return VERR_INVALID_PARAMETER;
    2856     }
    2857 
    2858     /*
    2859      * Make sure we're in EMT (to avoid the logging).
    2860      */
    2861     PVMREQ pReq;
    2862     int rc = VMR3ReqCall(pVM, VMCPUID_ANY, &pReq, RT_INDEFINITE_WAIT, (PFNRT)vmR3AtErrorDeregisterU, 3, pVM->pUVM, pfnAtError, pvUser);
    2863     if (RT_FAILURE(rc))
    2864         return rc;
    2865     rc = pReq->iStatus;
    2866     VMR3ReqFree(pReq);
    2867 
    2868     LogFlow(("VMR3AtErrorDeregister: returns %Rrc\n", rc));
    2869     return rc;
    2870 }
    2871 
    2872 
    2873 /**
    2874  * Deregisters a VM error callback.
    2875  *
    2876  * @returns VBox status code.
    2877  * @param   pUVM            Pointer to the user mode VM structure.
    2878  * @param   pfnAtError      Pointer to callback.
    2879  * @param   pvUser          User argument.
    2880  * @thread  EMT
    2881  */
    2882 static DECLCALLBACK(int)    vmR3AtErrorDeregisterU(PUVM pUVM, PFNVMATERROR pfnAtError, void *pvUser)
    2883 {
    2884     LogFlow(("vmR3AtErrorDeregisterU: pfnAtError=%p pvUser=%p\n", pfnAtError, pvUser));
     2825    AssertPtrReturn(pfnAtError, VERR_INVALID_PARAMETER);
     2826    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
     2827
     2828    PUVM pUVM = pVM->pUVM;
    28852829    RTCritSectEnter(&pUVM->vm.s.AtErrorCritSect);
    28862830
     
    30753019     * Validate input.
    30763020     */
    3077     if (!pfnAtRuntimeError)
    3078     {
    3079         AssertMsgFailed(("callback is required\n"));
    3080         return VERR_INVALID_PARAMETER;
    3081     }
    3082 
    3083     /*
    3084      * Make sure we're in EMT (to avoid the logging).
    3085      */
    3086     PVMREQ pReq;
    3087     int rc = VMR3ReqCall(pVM, VMCPUID_ANY, &pReq, RT_INDEFINITE_WAIT, (PFNRT)vmR3AtRuntimeErrorRegisterU, 3, pVM->pUVM, pfnAtRuntimeError, pvUser);
    3088     if (RT_FAILURE(rc))
    3089         return rc;
    3090     rc = pReq->iStatus;
    3091     VMR3ReqFree(pReq);
    3092 
    3093     LogFlow(("VMR3AtRuntimeErrorRegister: returns %Rrc\n", rc));
    3094     return rc;
    3095 }
    3096 
    3097 
    3098 /**
    3099  * Registers a VM runtime error callback.
    3100  *
    3101  * @returns VBox status code.
    3102  * @param   pUVM            Pointer to the user mode VM structure.
    3103  * @param   pfnAtRuntimeError   Pointer to callback.
    3104  * @param   pvUser              User argument.
    3105  * @thread  EMT
    3106  */
    3107 static DECLCALLBACK(int)    vmR3AtRuntimeErrorRegisterU(PUVM pUVM, PFNVMATRUNTIMEERROR pfnAtRuntimeError, void *pvUser)
    3108 {
     3021    AssertPtrReturn(pfnAtRuntimeError, VERR_INVALID_PARAMETER);
     3022    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
     3023
    31093024    /*
    31103025     * Allocate a new record.
    31113026     */
    3112 
     3027    PUVM pUVM = pVM->pUVM;
    31133028    PVMATRUNTIMEERROR pNew = (PVMATRUNTIMEERROR)MMR3HeapAllocU(pUVM, MM_TAG_VM, sizeof(*pNew));
    31143029    if (!pNew)
     
    31463061     * Validate input.
    31473062     */
    3148     if (!pfnAtRuntimeError)
    3149     {
    3150         AssertMsgFailed(("callback is required\n"));
    3151         return VERR_INVALID_PARAMETER;
    3152     }
    3153 
    3154     /*
    3155      * Make sure we're in EMT (to avoid the logging).
    3156      */
    3157     PVMREQ pReq;
    3158     int rc = VMR3ReqCall(pVM, VMCPUID_ANY, &pReq, RT_INDEFINITE_WAIT, (PFNRT)vmR3AtRuntimeErrorDeregisterU, 3, pVM->pUVM, pfnAtRuntimeError, pvUser);
    3159     if (RT_FAILURE(rc))
    3160         return rc;
    3161     rc = pReq->iStatus;
    3162     VMR3ReqFree(pReq);
    3163 
    3164     LogFlow(("VMR3AtRuntimeErrorDeregister: returns %Rrc\n", rc));
    3165     return rc;
    3166 }
    3167 
    3168 
    3169 /**
    3170  * Deregisters a VM runtime error callback.
    3171  *
    3172  * @returns VBox status code.
    3173  * @param   pUVM            Pointer to the user mode VM structure.
    3174  * @param   pfnAtRuntimeError   Pointer to callback.
    3175  * @param   pvUser              User argument.
    3176  * @thread  EMT
    3177  */
    3178 static DECLCALLBACK(int)    vmR3AtRuntimeErrorDeregisterU(PUVM pUVM, PFNVMATRUNTIMEERROR pfnAtRuntimeError, void *pvUser)
    3179 {
    3180     LogFlow(("vmR3AtRuntimeErrorDeregisterU: pfnAtRuntimeError=%p pvUser=%p\n", pfnAtRuntimeError, pvUser));
     3063    AssertPtrReturn(pfnAtRuntimeError, VERR_INVALID_PARAMETER);
     3064    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
     3065
     3066    PUVM pUVM = pVM->pUVM;
    31813067    RTCritSectEnter(&pUVM->vm.s.AtErrorCritSect);
    31823068
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