VirtualBox

Changeset 24508 in vbox


Ignore:
Timestamp:
Nov 9, 2009 2:44:12 PM (15 years ago)
Author:
vboxsync
Message:

SSM,VM: VMSetError handling.

Location:
trunk
Files:
4 edited

Legend:

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

    r24353 r24508  
    355355typedef FNVMATDTOR *PFNVMATDTOR;
    356356
    357 VMMR3DECL(int)  VMR3AtDtorRegister(PFNVMATDTOR pfnAtDtor, void *pvUser);
    358 VMMR3DECL(int)  VMR3AtDtorDeregister(PFNVMATDTOR pfnAtDtor);
    359 VMMR3DECL(int)  VMR3AtStateRegister(PVM pVM, PFNVMATSTATE pfnAtState, void *pvUser);
    360 VMMR3DECL(int)  VMR3AtStateDeregister(PVM pVM, PFNVMATSTATE pfnAtState, void *pvUser);
    361 VMMR3DECL(VMSTATE) VMR3GetState(PVM pVM);
     357VMMR3DECL(int)      VMR3AtDtorRegister(PFNVMATDTOR pfnAtDtor, void *pvUser);
     358VMMR3DECL(int)      VMR3AtDtorDeregister(PFNVMATDTOR pfnAtDtor);
     359VMMR3DECL(int)      VMR3AtStateRegister(PVM pVM, PFNVMATSTATE pfnAtState, void *pvUser);
     360VMMR3DECL(int)      VMR3AtStateDeregister(PVM pVM, PFNVMATSTATE pfnAtState, void *pvUser);
     361VMMR3DECL(VMSTATE)  VMR3GetState(PVM pVM);
    362362VMMR3DECL(const char *) VMR3GetStateName(VMSTATE enmState);
    363 VMMR3DECL(bool) VMR3TeleportedAndNotFullyResumedYet(PVM pVM);
    364 VMMR3DECL(int)  VMR3AtErrorRegister(PVM pVM, PFNVMATERROR pfnAtError, void *pvUser);
    365 VMMR3DECL(int)  VMR3AtErrorRegisterU(PUVM pVM, PFNVMATERROR pfnAtError, void *pvUser);
    366 VMMR3DECL(int)  VMR3AtErrorDeregister(PVM pVM, PFNVMATERROR pfnAtError, void *pvUser);
    367 VMMR3DECL(void) VMR3SetErrorWorker(PVM pVM);
    368 VMMR3DECL(int)  VMR3AtRuntimeErrorRegister(PVM pVM, PFNVMATRUNTIMEERROR pfnAtRuntimeError, void *pvUser);
    369 VMMR3DECL(int)  VMR3AtRuntimeErrorDeregister(PVM pVM, PFNVMATRUNTIMEERROR pfnAtRuntimeError, void *pvUser);
    370 VMMR3DECL(int)  VMR3SetRuntimeErrorWorker(PVM pVM);
    371 VMMR3DECL(int)  VMR3ReqCall(PVM pVM, VMCPUID idDstCpu, PVMREQ *ppReq, unsigned cMillies, uint32_t fFlags, PFNRT pfnFunction, unsigned cArgs, ...);
    372 VMMR3DECL(int)  VMR3ReqCallU(PUVM pUVM, VMCPUID idDstCpu, PVMREQ *ppReq, unsigned cMillies, unsigned fFlags, PFNRT pfnFunction, unsigned cArgs, ...);
    373 VMMR3DECL(int)  VMR3ReqCallVU(PUVM pUVM, VMCPUID idDstCpu, PVMREQ *ppReq, unsigned cMillies, unsigned fFlags, PFNRT pfnFunction, unsigned cArgs, va_list Args);
    374 VMMR3DECL(int)  VMR3ReqCallWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
    375 VMMR3DECL(int)  VMR3ReqCallWaitU(PUVM pUVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
    376 VMMR3DECL(int)  VMR3ReqCallNoWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
    377 VMMR3DECL(int)  VMR3ReqCallNoWaitU(PUVM pUVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
    378 VMMR3DECL(int)  VMR3ReqCallVoidWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
    379 VMMR3DECL(int)  VMR3ReqCallVoidWaitU(PUVM pUVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
    380 VMMR3DECL(int)  VMR3ReqCallVoidNoWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
    381 VMMR3DECL(int)  VMR3ReqCallVoidNoWaitU(PUVM pUVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
    382 VMMR3DECL(int)  VMR3ReqAlloc(PVM pVM, PVMREQ *ppReq, VMREQTYPE enmType, VMCPUID idDstCpu);
    383 VMMR3DECL(int)  VMR3ReqAllocU(PUVM pUVM, PVMREQ *ppReq, VMREQTYPE enmType, VMCPUID idDstCpu);
    384 VMMR3DECL(int)  VMR3ReqFree(PVMREQ pReq);
    385 VMMR3DECL(int)  VMR3ReqQueue(PVMREQ pReq, unsigned cMillies);
    386 VMMR3DECL(int)  VMR3ReqWait(PVMREQ pReq, unsigned cMillies);
    387 VMMR3DECL(int)  VMR3ReqProcessU(PUVM pUVM, VMCPUID idDstCpu);
    388 VMMR3DECL(void) VMR3NotifyGlobalFFU(PUVM pUVM, uint32_t fFlags);
    389 VMMR3DECL(void) VMR3NotifyCpuFFU(PUVMCPU pUVMCpu, uint32_t fFlags);
     363VMMR3DECL(bool)     VMR3TeleportedAndNotFullyResumedYet(PVM pVM);
     364VMMR3DECL(int)      VMR3AtErrorRegister(PVM pVM, PFNVMATERROR pfnAtError, void *pvUser);
     365VMMR3DECL(int)      VMR3AtErrorRegisterU(PUVM pVM, PFNVMATERROR pfnAtError, void *pvUser);
     366VMMR3DECL(int)      VMR3AtErrorDeregister(PVM pVM, PFNVMATERROR pfnAtError, void *pvUser);
     367VMMR3DECL(void)     VMR3SetErrorWorker(PVM pVM);
     368VMMR3DECL(uint32_t) VMR3GetErrorCount(PVM pVM);
     369VMMR3DECL(int)      VMR3AtRuntimeErrorRegister(PVM pVM, PFNVMATRUNTIMEERROR pfnAtRuntimeError, void *pvUser);
     370VMMR3DECL(int)      VMR3AtRuntimeErrorDeregister(PVM pVM, PFNVMATRUNTIMEERROR pfnAtRuntimeError, void *pvUser);
     371VMMR3DECL(int)      VMR3SetRuntimeErrorWorker(PVM pVM);
     372VMMR3DECL(uint32_t) VMR3GetRuntimeErrorCount(PVM pVM);
     373VMMR3DECL(int)      VMR3ReqCall(PVM pVM, VMCPUID idDstCpu, PVMREQ *ppReq, unsigned cMillies, uint32_t fFlags, PFNRT pfnFunction, unsigned cArgs, ...);
     374VMMR3DECL(int)      VMR3ReqCallU(PUVM pUVM, VMCPUID idDstCpu, PVMREQ *ppReq, unsigned cMillies, unsigned fFlags, PFNRT pfnFunction, unsigned cArgs, ...);
     375VMMR3DECL(int)      VMR3ReqCallVU(PUVM pUVM, VMCPUID idDstCpu, PVMREQ *ppReq, unsigned cMillies, unsigned fFlags, PFNRT pfnFunction, unsigned cArgs, va_list Args);
     376VMMR3DECL(int)      VMR3ReqCallWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
     377VMMR3DECL(int)      VMR3ReqCallWaitU(PUVM pUVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
     378VMMR3DECL(int)      VMR3ReqCallNoWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
     379VMMR3DECL(int)      VMR3ReqCallNoWaitU(PUVM pUVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
     380VMMR3DECL(int)      VMR3ReqCallVoidWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
     381VMMR3DECL(int)      VMR3ReqCallVoidWaitU(PUVM pUVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
     382VMMR3DECL(int)      VMR3ReqCallVoidNoWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
     383VMMR3DECL(int)      VMR3ReqCallVoidNoWaitU(PUVM pUVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
     384VMMR3DECL(int)      VMR3ReqAlloc(PVM pVM, PVMREQ *ppReq, VMREQTYPE enmType, VMCPUID idDstCpu);
     385VMMR3DECL(int)      VMR3ReqAllocU(PUVM pUVM, PVMREQ *ppReq, VMREQTYPE enmType, VMCPUID idDstCpu);
     386VMMR3DECL(int)      VMR3ReqFree(PVMREQ pReq);
     387VMMR3DECL(int)      VMR3ReqQueue(PVMREQ pReq, unsigned cMillies);
     388VMMR3DECL(int)      VMR3ReqWait(PVMREQ pReq, unsigned cMillies);
     389VMMR3DECL(int)      VMR3ReqProcessU(PUVM pUVM, VMCPUID idDstCpu);
     390VMMR3DECL(void)     VMR3NotifyGlobalFFU(PUVM pUVM, uint32_t fFlags);
     391VMMR3DECL(void)     VMR3NotifyCpuFFU(PUVMCPU pUVMCpu, uint32_t fFlags);
    390392/** @name Flags for VMR3NotifyCpuFFU and VMR3NotifyGlobalFFU.
    391393 * @{ */
  • trunk/src/VBox/VMM/SSM.cpp

    r24292 r24508  
    76497649                                    pszName, UnitHdr.u32Instance, UnitHdr.u32Version));
    76507650                            if (!ASMAtomicXchgBool(&pSSM->u.Read.fHaveSetError, true))
    7651                                 VMSetError(pVM, rc, RT_SRC_POS, N_("Load exec failed for '%s' instance #%u (version %u)"),
    7652                                            pszName, UnitHdr.u32Instance, UnitHdr.u32Version);
     7651                                if (rc == VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION)
     7652                                    VMSetError(pVM, rc, RT_SRC_POS, N_("Unsupported version %u of data unit '%s' (instance #%u)"),
     7653                                               UnitHdr.u32Version, UnitHdr.szName, UnitHdr.u32Instance);
     7654                                else
     7655                                    VMSetError(pVM, rc, RT_SRC_POS, N_("Load exec failed for '%s' instance #%u (version %u)"),
     7656                                               pszName, UnitHdr.u32Instance, UnitHdr.u32Version);
    76537657                            break;
    76547658                        }
     
    79107914                        UnitHdr.szName, UnitHdr.u32Instance, UnitHdr.u32Version, UnitHdr.u32Pass, rc));
    79117915                if (!ASMAtomicXchgBool(&pSSM->u.Read.fHaveSetError, true))
    7912                     rc = VMSetError(pVM, rc, RT_SRC_POS, N_("Failed to load unit '%s'"), UnitHdr.szName);
     7916                    if (rc == VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION)
     7917                        rc = VMSetError(pVM, rc, RT_SRC_POS, N_("Unsupported version %u of data unit '%s' (instance #%u, pass %#x)"),
     7918                                        UnitHdr.u32Version, UnitHdr.szName, UnitHdr.u32Instance, UnitHdr.u32Pass);
     7919                    else
     7920                        rc = VMSetError(pVM, rc, RT_SRC_POS, N_("Failed to load unit '%s'"), UnitHdr.szName);
    79137921                return rc;
    79147922            }
  • trunk/src/VBox/VMM/VM.cpp

    r24474 r24508  
    18461846    pVM->vm.s.fTeleportedAndNotFullyResumedYet = fTeleporting;
    18471847
     1848    uint32_t cErrorsPriorToSave = VMR3GetErrorCount(pVM);
    18481849    rc = SSMR3Load(pVM, pszFilename, pStreamOps, pvStreamOpsUser, SSMAFTER_RESUME, pfnProgress, pvProgressUser);
    18491850    if (RT_SUCCESS(rc))
     
    18561857        pVM->vm.s.fTeleportedAndNotFullyResumedYet = false;
    18571858        vmR3SetState(pVM, VMSTATE_LOAD_FAILURE, VMSTATE_LOADING);
    1858         rc = VMSetError(pVM, rc, RT_SRC_POS,
    1859                         N_("Unable to restore the virtual machine's saved state from '%s'.  It may be damaged or from an older version of VirtualBox.  Please discard the saved state before starting the virtual machine"),
    1860                         pszFilename);
     1859        if (cErrorsPriorToSave == VMR3GetErrorCount(pVM))
     1860            rc = VMSetError(pVM, rc, RT_SRC_POS,
     1861                            N_("Unable to restore the virtual machine's saved state from '%s'. "
     1862                               "It may be damaged or from an older version of VirtualBox.  "
     1863                               "Please discard the saved state before starting the virtual machine"),
     1864                            pszFilename);
    18611865    }
    18621866
     
    35203524    PUVM pUVM = pVM->pUVM;
    35213525    RTCritSectEnter(&pUVM->vm.s.AtErrorCritSect);
     3526    ASMAtomicIncU32(&pUVM->vm.s.cRuntimeErrors);
    35223527    for (PVMATERROR pCur = pUVM->vm.s.pAtError; pCur; pCur = pCur->pNext)
    35233528        vmR3SetErrorWorkerDoCall(pVM, pCur, rc, RT_SRC_POS_ARGS, "%s", pszMessage);
    35243529    RTCritSectLeave(&pUVM->vm.s.AtErrorCritSect);
     3530}
     3531
     3532
     3533/**
     3534 * Gets the number of errors raised via VMSetError.
     3535 *
     3536 * This can be used avoid double error messages.
     3537 *
     3538 * @returns The error count.
     3539 * @param   pVM             The VM handle.
     3540 */
     3541VMMR3DECL(uint32_t) VMR3GetErrorCount(PVM pVM)
     3542{
     3543    return pVM->pUVM->vm.s.cErrors;
    35253544}
    35263545
     
    35803599    bool fCalledSomeone = false;
    35813600    RTCritSectEnter(&pUVM->vm.s.AtErrorCritSect);
     3601    ASMAtomicIncU32(&pUVM->vm.s.cErrors);
    35823602    for (PVMATERROR pCur = pUVM->vm.s.pAtError; pCur; pCur = pCur->pNext)
    35833603    {
     
    37733793    PUVM pUVM = pVM->pUVM;
    37743794    RTCritSectEnter(&pUVM->vm.s.AtErrorCritSect);
     3795    ASMAtomicIncU32(&pUVM->vm.s.cRuntimeErrors);
    37753796    for (PVMATRUNTIMEERROR pCur = pUVM->vm.s.pAtRuntimeError; pCur; pCur = pCur->pNext)
    37763797    {
     
    39023923
    39033924/**
     3925 * Gets the number of runtime errors raised via VMR3SetRuntimeError.
     3926 *
     3927 * This can be used avoid double error messages.
     3928 *
     3929 * @returns The runtime error count.
     3930 * @param   pVM             The VM handle.
     3931 */
     3932VMMR3DECL(uint32_t) VMR3GetRuntimeErrorCount(PVM pVM)
     3933{
     3934    return pVM->pUVM->vm.s.cRuntimeErrors;
     3935}
     3936
     3937
     3938/**
    39043939 * Gets the ID virtual of the virtual CPU assoicated with the calling thread.
    39053940 *
  • trunk/src/VBox/VMM/VMInternal.h

    r23915 r24508  
    228228    /** List of registered error callbacks. */
    229229    PVMATERROR                     *ppAtErrorNext;
    230 
     230    /** The error message count.
     231     * This is incremented every time an error is raised.  */
     232    uint32_t volatile               cErrors;
     233
     234    /** The runtime error message count.
     235     * This is incremented every time a runtime error is raised.  */
     236    uint32_t volatile               cRuntimeErrors;
    231237    /** List of registered error callbacks. */
    232238    PVMATRUNTIMEERROR               pAtRuntimeError;
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