VirtualBox

Changeset 24508 in vbox for trunk/src


Ignore:
Timestamp:
Nov 9, 2009 2:44:12 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
54602
Message:

SSM,VM: VMSetError handling.

Location:
trunk/src/VBox/VMM
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • 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.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette