- Timestamp:
- Sep 12, 2008 6:40:20 PM (16 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/SSM.cpp
r11944 r12440 49 49 #include <VBox/err.h> 50 50 #include <VBox/log.h> 51 #include <VBox/version.h> 51 52 52 53 #include <iprt/assert.h> … … 219 220 * Internal Functions * 220 221 *******************************************************************************/ 222 static int ssmR3LazyInit(PVM pVM); 223 static DECLCALLBACK(int) ssmR3SelfSaveExec(PVM pVM, PSSMHANDLE pSSM); 224 static DECLCALLBACK(int) ssmR3SelfLoadExec(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version); 221 225 static int smmr3Register(PVM pVM, const char *pszName, uint32_t u32Instance, uint32_t u32Version, size_t cbGuess, PSSMUNIT *ppUnit); 222 226 static int ssmr3CalcChecksum(RTFILE File, uint64_t cbFile, uint32_t *pu32CRC); … … 233 237 234 238 /** 239 * Performs lazy initialization of the SSM. 240 * 241 * @returns VBox status code. 242 * @param pVM The VM. 243 */ 244 static int ssmR3LazyInit(PVM pVM) 245 { 246 #if 1 /* if we want 2.0.2 to remain forward compatible with 2.0.x, disable this. */ 247 /* 248 * Register a saved state unit which we use to put the VirtualBox version, 249 * revision and similar stuff in. 250 */ 251 pVM->ssm.s.fInitialized = true; 252 int rc = SSMR3RegisterInternal(pVM, "SSM", 0 /*u32Instance*/, 1/*u32Version*/, 64 /*cbGuess*/, 253 NULL /*pfnSavePrep*/, ssmR3SelfSaveExec, NULL /*pfnSaveDone*/, 254 NULL /*pfnSavePrep*/, ssmR3SelfLoadExec, NULL /*pfnSaveDone*/); 255 pVM->ssm.s.fInitialized = RT_SUCCESS(rc); 256 return rc; 257 #else 258 pVM->ssm.s.fInitialized = true; 259 return VINF_SUCCESS; 260 #endif 261 } 262 263 264 /** 265 * For saving the version + revision and stuff. 266 * 267 * @returns VBox status code. 268 * @param pVM Pointer to the shared VM structure. 269 * @param pSSM The SSM handle. 270 */ 271 static DECLCALLBACK(int) ssmR3SelfSaveExec(PVM pVM, PSSMHANDLE pSSM) 272 { 273 char szTmp[128]; 274 275 /* 276 * String table containg pairs of variable and value string. 277 * Terminated by two empty strings. 278 */ 279 SSMR3PutStrZ(pSSM, "VBox Version"); 280 SSMR3PutStrZ(pSSM, VBOX_VERSION_STRING); 281 SSMR3PutStrZ(pSSM, "VBox Revision"); 282 RTStrPrintf(szTmp, sizeof(szTmp), "%d", VMMGetSvnRev()); 283 SSMR3PutStrZ(pSSM, szTmp); 284 #ifdef VBOX_OSE 285 SSMR3PutStrZ(pSSM, "OSE"); 286 SSMR3PutStrZ(pSSM, "true"); 287 #endif 288 289 /* terminator */ 290 SSMR3PutStrZ(pSSM, ""); 291 return SSMR3PutStrZ(pSSM, ""); 292 } 293 294 295 /** 296 * For load the version + revision and stuff. 297 * 298 * @returns VBox status code. 299 * @param pVM Pointer to the shared VM structure. 300 * @param pSSM The SSM handle. 301 * @param u32Version The version (1). 302 */ 303 static DECLCALLBACK(int) ssmR3SelfLoadExec(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version) 304 { 305 AssertLogRelMsgReturn(u32Version == 1, ("%d", u32Version), VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION); 306 307 /* 308 * String table containg pairs of variable and value string. 309 * Terminated by two empty strings. 310 */ 311 LogRel(("SSM: Saved state info:\n", szVar, szValue)); 312 for (;;) 313 { 314 char szVar[128]; 315 char szValue[1024]; 316 int rc = SSMR3GetStrZ(pSSM, szVar, sizeof(szVar)); 317 AssertRCReturn(rc, rc); 318 rc = SSMR3GetStrZ(pSSM, szValue, sizeof(szValue)); 319 AssertRCReturn(rc, rc); 320 if (!szVar[0] && !szValue[0]) 321 break; 322 LogRel(("SSM: %s: %s\n", szVar, szValue)); 323 } 324 return VINF_SUCCESS; 325 } 326 327 328 /** 235 329 * Internal registration worker. 236 330 * … … 246 340 static int smmr3Register(PVM pVM, const char *pszName, uint32_t u32Instance, uint32_t u32Version, size_t cbGuess, PSSMUNIT *ppUnit) 247 341 { 342 /* 343 * Lazy init. 344 */ 345 if (!pVM->ssm.s.fInitialized) 346 { 347 int rc = ssmR3LazyInit(pVM); 348 AssertRCReturn(rc, rc); 349 } 350 248 351 /* 249 352 * Walk to the end of the list checking for duplicates as we go. … … 2901 3004 * 2902 3005 * Note: only applies to: 2903 * - SSMR3GetGCPtr 3006 * - SSMR3GetGCPtr 2904 3007 * - SSMR3GetGCUIntPtr 2905 3008 * - SSMR3GetGCSInt -
trunk/src/VBox/VMM/SSMInternal.h
r8155 r12440 159 159 160 160 161 162 /**163 * Converts a SSM pointer into a VM pointer.164 * @returns Pointer to the VM structure the SSM is part of.165 * @param pSSM Pointer to SSM instance data.166 */167 #define SSM2VM(pSSM) ( (PVM)((char*)pSSM - pSSM->offVM) )168 169 170 161 /** 171 162 * SSM VM Instance data. … … 174 165 typedef struct SSM 175 166 { 176 /** Offset to the VM structure.177 * See SSM2VM(). */178 RTUINT offVM;179 180 167 /** FIFO of data entity descriptors. */ 181 168 R3PTRTYPE(PSSMUNIT) pHead; 182 169 /** For lazy init. */ 170 bool fInitialized; 183 171 } SSM; 184 172 /** Pointer to SSM VM instance data. */
Note:
See TracChangeset
for help on using the changeset viewer.