Changeset 24264 in vbox
- Timestamp:
- Nov 2, 2009 3:20:35 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/ssm.h
r23872 r24264 1085 1085 VMMR3DECL(int) SSMR3Skip(PSSMHANDLE pSSM, size_t cb); 1086 1086 VMMR3DECL(int) SSMR3SkipToEndOfUnit(PSSMHANDLE pSSM); 1087 VMMR3DECL(int) SSMR3SetLoadError(PSSMHANDLE pSSM, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...); 1088 VMMR3DECL(int) SSMR3SetLoadErrorV(PSSMHANDLE pSSM, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va); 1089 VMMR3DECL(int) SSMR3SetCfgError(PSSMHANDLE pSSM, RT_SRC_POS_DECL, const char *pszFormat, ...); 1087 1090 1088 1091 /** @} */ -
trunk/src/VBox/VMM/SSM.cpp
r24198 r24264 526 526 /** V2: The type and flags byte fo the current record. */ 527 527 uint8_t u8TypeAndFlags; 528 529 /** @name Context info for SSMR3SetLoadError. 530 * @{ */ 531 /** Pointer to the header for the current unit. */ 532 PSSMUNIT pCurUnit; 533 /** The version of the current unit if in the load exec stage. */ 534 uint32_t uCurUnitVer; 535 /** The pass number of the current unit if in the load exec stage. */ 536 uint32_t uCurUnitPass; 537 /** Whether SSMR3SetLoadError[V] has been called. */ 538 bool fHaveSetError; 539 /** @} */ 528 540 529 541 /** RTGCPHYS size in bytes. (Only applicable when loading/reading.) */ … … 6830 6842 6831 6843 /** 6844 * VMSetError wrapper for load errors that inserts the saved state details. 6845 * 6846 * @returns rc. 6847 * @param pSSM The saved state handle. 6848 * @param rc The status code of the error. Use RT_SRC_POS. 6849 * @param RT_SRC_POS_DECL The source location. 6850 * @param pszFormat The message format string. 6851 * @param ... Variable argument list. 6852 */ 6853 VMMR3DECL(int) SSMR3SetLoadError(PSSMHANDLE pSSM, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...) 6854 { 6855 va_list va; 6856 va_start(va, pszFormat); 6857 rc = SSMR3SetLoadErrorV(pSSM, rc, RT_SRC_POS_ARGS, pszFormat, va); 6858 va_end(va); 6859 return rc; 6860 } 6861 6862 6863 /** 6864 * VMSetError wrapper for load errors that inserts the saved state details. 6865 * 6866 * @returns rc. 6867 * @param pSSM The saved state handle. 6868 * @param rc The status code of the error. 6869 * @param RT_SRC_POS_DECL The error location, use RT_SRC_POS. 6870 * @param pszFormat The message format string. 6871 * @param va Variable argument list. 6872 */ 6873 VMMR3DECL(int) SSMR3SetLoadErrorV(PSSMHANDLE pSSM, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va) 6874 { 6875 /* 6876 * Input validations. 6877 */ 6878 SSM_ASSERT_READABLE_RET(pSSM); 6879 AssertPtr(pszFormat); 6880 Assert(RT_FAILURE_NP(rc)); 6881 6882 /* 6883 * Forward to VMSetError with the additional info. 6884 */ 6885 PSSMUNIT pUnit = pSSM->u.Read.pCurUnit; 6886 const char *pszName = pUnit ? pUnit->szName : "unknown"; 6887 uint32_t uInstance = pUnit ? pUnit->u32Instance : 0; 6888 va_list vaCopy; 6889 va_copy(vaCopy, va); 6890 if ( pSSM->enmOp == SSMSTATE_LOAD_EXEC 6891 && pSSM->u.Read.uCurUnitPass == SSM_PASS_FINAL) 6892 rc = VMSetError(pSSM->pVM, rc, RT_SRC_POS_ARGS, N_("%s#u: %N [ver=%u pass=final]"), 6893 pszName, uInstance, 6894 pszFormat, &vaCopy, 6895 pSSM->u.Read.uCurUnitVer); 6896 else if (pSSM->enmOp == SSMSTATE_LOAD_EXEC) 6897 rc = VMSetError(pSSM->pVM, rc, RT_SRC_POS_ARGS, N_("%s#u: %N [ver=%u pass=#%u]"), 6898 pszName, uInstance, 6899 pszFormat, &vaCopy, 6900 pSSM->u.Read.uCurUnitVer, pSSM->u.Read.uCurUnitPass); 6901 else if (pSSM->enmOp == SSMSTATE_LOAD_PREP) 6902 rc = VMSetError(pSSM->pVM, rc, RT_SRC_POS_ARGS, N_("%s#u: %N [prep]"), 6903 pszName, uInstance, 6904 pszFormat, &vaCopy); 6905 else if (pSSM->enmOp == SSMSTATE_LOAD_DONE) 6906 rc = VMSetError(pSSM->pVM, rc, RT_SRC_POS_ARGS, N_("%s#u: %N [done]"), 6907 pszName, uInstance, 6908 pszFormat, &vaCopy); 6909 else if (pSSM->enmOp == SSMSTATE_OPEN_READ) 6910 rc = VMSetError(pSSM->pVM, rc, RT_SRC_POS_ARGS, N_("%s#u: %N [read]"), 6911 pszName, uInstance, 6912 pszFormat, &vaCopy); 6913 else 6914 AssertFailed(); 6915 va_end(vaCopy); 6916 pSSM->u.Read.fHaveSetError = true; 6917 return rc; 6918 } 6919 6920 6921 /** 6922 * SSMR3SetLoadError wrapper that returns VERR_SSM_LOAD_CONFIG_MISMATCH. 6923 * 6924 * @returns VERR_SSM_LOAD_CONFIG_MISMATCH. 6925 * @param pSSM The saved state handle. 6926 * @param RT_SRC_POS_DECL The error location, use RT_SRC_POS. 6927 * @param pszFormat The message format string. 6928 * @param va Variable argument list. 6929 */ 6930 VMMR3DECL(int) SSMR3SetCfgError(PSSMHANDLE pSSM, RT_SRC_POS_DECL, const char *pszFormat, ...) 6931 { 6932 va_list va; 6933 va_start(va, pszFormat); 6934 int rc = SSMR3SetLoadErrorV(pSSM, VERR_SSM_LOAD_CONFIG_MISMATCH, RT_SRC_POS_ARGS, pszFormat, va); 6935 va_end(va); 6936 return rc; 6937 } 6938 6939 6940 /** 6832 6941 * Calculate the checksum of a file portion. 6833 6942 * … … 7340 7449 pSSM->u.Read.fEndOfData = 0; 7341 7450 pSSM->u.Read.u8TypeAndFlags = 0; 7451 7452 pSSM->u.Read.pCurUnit = NULL; 7453 pSSM->u.Read.uCurUnitVer = UINT32_MAX; 7454 pSSM->u.Read.uCurUnitPass = 0; 7455 pSSM->u.Read.fHaveSetError = false; 7342 7456 7343 7457 /* … … 7463 7577 pSSM->cbUnitLeftV1 = UnitHdr.cbUnit - RT_OFFSETOF(SSMFILEUNITHDRV1, szName[UnitHdr.cchName]); 7464 7578 pSSM->offUnit = 0; 7579 pSSM->u.Read.uCurUnitVer = UnitHdr.u32Version; 7580 pSSM->u.Read.uCurUnitPass = SSM_PASS_FINAL; 7581 pSSM->u.Read.pCurUnit = pUnit; 7465 7582 if (!pUnit->u.Common.pfnLoadExec) 7466 7583 { … … 7515 7632 { 7516 7633 LogRel(("SSM: Unit '%s' read %lld bytes too much!\n", pszName, i64Diff)); 7517 rc = VMSetError(pVM, VERR_SSM_LOADED_TOO_MUCH, RT_SRC_POS, 7518 N_("Unit '%s' read %lld bytes too much"), pszName, i64Diff); 7634 if (!pSSM->u.Read.fHaveSetError) 7635 rc = VMSetError(pVM, VERR_SSM_LOADED_TOO_MUCH, RT_SRC_POS, 7636 N_("Unit '%s' read %lld bytes too much"), pszName, i64Diff); 7519 7637 break; 7520 7638 } … … 7526 7644 LogRel(("SSM: Load exec failed for '%s' instance #%u ! (version %u)\n", 7527 7645 pszName, UnitHdr.u32Instance, UnitHdr.u32Version)); 7528 VMSetError(pVM, rc, RT_SRC_POS, N_("Load exec failed for '%s' instance #%u (version %u)"), 7529 pszName, UnitHdr.u32Instance, UnitHdr.u32Version); 7646 if (!pSSM->u.Read.fHaveSetError) 7647 VMSetError(pVM, rc, RT_SRC_POS, N_("Load exec failed for '%s' instance #%u (version %u)"), 7648 pszName, UnitHdr.u32Instance, UnitHdr.u32Version); 7530 7649 break; 7531 7650 } 7651 7652 pSSM->u.Read.pCurUnit = NULL; 7653 pSSM->u.Read.uCurUnitVer = UINT32_MAX; 7654 pSSM->u.Read.uCurUnitPass = 0; 7532 7655 } 7533 7656 else … … 7749 7872 ("SSM: No load exec callback for unit '%s'!\n", UnitHdr.szName), 7750 7873 VERR_SSM_NO_LOAD_EXEC); 7874 pSSM->u.Read.uCurUnitVer = UnitHdr.u32Version; 7875 pSSM->u.Read.uCurUnitPass = UnitHdr.u32Pass; 7876 pSSM->u.Read.pCurUnit = pUnit; 7751 7877 ssmR3DataReadBeginV2(pSSM); 7752 7878 switch (pUnit->enmType) … … 7778 7904 LogRel(("SSM: LoadExec failed for '%s' instance #%u (version %u, pass %#x): %Rrc\n", 7779 7905 UnitHdr.szName, UnitHdr.u32Instance, UnitHdr.u32Version, UnitHdr.u32Pass, rc)); 7780 return VMSetError(pVM, rc, RT_SRC_POS, N_("Failed to load unit '%s'"), UnitHdr.szName); 7906 if (!pSSM->u.Read.fHaveSetError) 7907 rc = VMSetError(pVM, rc, RT_SRC_POS, N_("Failed to load unit '%s'"), UnitHdr.szName); 7908 return rc; 7781 7909 } 7782 7910 } … … 7901 8029 if (pUnit->u.Common.pfnLoadPrep) 7902 8030 { 8031 Handle.u.Read.pCurUnit = pUnit; 7903 8032 pUnit->fCalled = true; 7904 8033 switch (pUnit->enmType) … … 7920 8049 break; 7921 8050 } 8051 Handle.u.Read.pCurUnit = NULL; 7922 8052 if (RT_FAILURE(rc) && RT_SUCCESS_NP(Handle.rc)) 7923 8053 Handle.rc = rc; … … 7948 8078 else 7949 8079 rc = ssmR3LoadExecV1(pVM, &Handle); 8080 Handle.u.Read.pCurUnit = NULL; 8081 Handle.u.Read.uCurUnitVer = UINT32_MAX; 8082 Handle.u.Read.uCurUnitPass = 0; 7950 8083 7951 8084 /* (progress should be pending 99% now) */ … … 7966 8099 || (!pUnit->u.Common.pfnLoadPrep && !pUnit->u.Common.pfnLoadExec))) 7967 8100 { 8101 Handle.u.Read.pCurUnit = pUnit; 7968 8102 int const rcOld = Handle.rc; 7969 8103 rc = VINF_SUCCESS; … … 7986 8120 break; 7987 8121 } 8122 Handle.u.Read.pCurUnit = NULL; 7988 8123 if (RT_SUCCESS(rc) && Handle.rc != rcOld) 7989 8124 rc = Handle.rc;
Note:
See TracChangeset
for help on using the changeset viewer.