Changeset 21862 in vbox
- Timestamp:
- Jul 29, 2009 12:23:04 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/SSM-new.cpp
r21858 r21862 100 100 * - type 2: Raw data record. 101 101 * - type 3: Raw data compressed by LZF. The data is prefixed by a 8-bit 102 * field countining the length of the uncompressed data given as103 * a page count.102 * field countining the length of the uncompressed data given in 103 * 1KB units. 104 104 * - type 4: Named data - length prefixed name followed by the data. This 105 105 * type is not implemented yet as we're missing the API part, so … … 112 112 * 113 113 * Record header byte 2 (optionally thru 7) is the size of the following data 114 * encoded in UTF-8 style. 114 * encoded in UTF-8 style. To make buffering simpler and more efficient during 115 * the save operation, the strict checks enforcing optimal encoding has been 116 * relaxed for the 2 and 3 byte encodings. 115 117 * 116 118 * (In version 1.2 and earlier the unit data was compressed and not record … … 256 258 AssertLogRelMsgReturn(u32ActualCRC == u32CRC, Msg, VERR_SSM_INTEGRITY_CRC); \ 257 259 } while (0) 260 261 /** The number of bytes to compress is one block. 262 * Must be a multiple of 1KB. */ 263 #define SSM_ZIP_BLOCK_SIZE _4K 264 AssertCompile(SSM_ZIP_BLOCK_SIZE / _1K * _1K == SSM_ZIP_BLOCK_SIZE); 258 265 259 266 … … 1966 1973 } 1967 1974 if ( uHdr.v2_0.cbMaxDecompr > sizeof(pSSM->u.Read.abDataBuffer) 1968 || uHdr.v2_0.cbMaxDecompr < PAGE_SIZE1975 || uHdr.v2_0.cbMaxDecompr < _1K 1969 1976 || (uHdr.v2_0.cbMaxDecompr & 0xff) != 0) 1970 1977 { … … 3351 3358 for (;;) 3352 3359 { 3353 if (cbBuf >= PAGE_SIZE)3360 if (cbBuf >= SSM_ZIP_BLOCK_SIZE) 3354 3361 { 3355 3362 struct 3356 3363 { 3357 uint8_t c Pages;3358 uint8_t abCompr[ PAGE_SIZE - (PAGE_SIZE / 16)];3364 uint8_t cKB; 3365 uint8_t abCompr[SSM_ZIP_BLOCK_SIZE - (SSM_ZIP_BLOCK_SIZE / 16)]; 3359 3366 } s; 3360 AssertCompile(sizeof(s) == PAGE_SIZE - (PAGE_SIZE / 16) + sizeof(uint8_t));3367 AssertCompile(sizeof(s) == SSM_ZIP_BLOCK_SIZE - (SSM_ZIP_BLOCK_SIZE / 16) + sizeof(uint8_t)); 3361 3368 3362 3369 size_t cbCompr; 3363 3370 rc = RTZipBlockCompress(RTZIPTYPE_LZF, RTZIPLEVEL_FAST, 0 /*fFlags*/, 3364 pvBuf, PAGE_SIZE,3371 pvBuf, SSM_ZIP_BLOCK_SIZE, 3365 3372 &s.abCompr[0], sizeof(s.abCompr), &cbCompr); 3366 3373 if (RT_SUCCESS(rc)) 3367 3374 { 3368 cbCompr += sizeof(s.c Pages);3369 s.c Pages = 1;3375 cbCompr += sizeof(s.cKB); 3376 s.cKB = SSM_ZIP_BLOCK_SIZE / _1K; 3370 3377 rc = ssmR3DataWriteRecHdr(pSSM, cbCompr, SSM_REC_FLAGS_FIXED | SSM_REC_FLAGS_IMPORTANT | SSM_REC_TYPE_RAW_LZF); 3371 3378 if (RT_FAILURE(rc)) … … 3378 3385 { 3379 3386 /* Didn't compress very well, store it. */ 3380 rc = ssmR3DataWriteRecHdr(pSSM, PAGE_SIZE, SSM_REC_FLAGS_FIXED | SSM_REC_FLAGS_IMPORTANT | SSM_REC_TYPE_RAW);3387 rc = ssmR3DataWriteRecHdr(pSSM, SSM_ZIP_BLOCK_SIZE, SSM_REC_FLAGS_FIXED | SSM_REC_FLAGS_IMPORTANT | SSM_REC_TYPE_RAW); 3381 3388 if (RT_FAILURE(rc)) 3382 3389 return rc; 3383 rc = ssmR3DataWriteRaw(pSSM, pvBuf, PAGE_SIZE);3390 rc = ssmR3DataWriteRaw(pSSM, pvBuf, SSM_ZIP_BLOCK_SIZE); 3384 3391 if (RT_FAILURE(rc)) 3385 3392 return rc; 3386 3393 } 3387 if (cbBuf == PAGE_SIZE)3394 if (cbBuf == SSM_ZIP_BLOCK_SIZE) 3388 3395 return VINF_SUCCESS; 3389 cbBuf -= PAGE_SIZE;3390 pvBuf = (uint8_t const*)pvBuf + PAGE_SIZE;3396 cbBuf -= SSM_ZIP_BLOCK_SIZE; 3397 pvBuf = (uint8_t const*)pvBuf + SSM_ZIP_BLOCK_SIZE; 3391 3398 } 3392 3399 else … … 4085 4092 /** @todo this isn't very efficient, we know we have to read it all, so both 4086 4093 * reading the first byte separately. */ 4087 uint8_t c Pages;4088 int rc = ssmR3DataReadV2Raw(pSSM, &c Pages, 1);4094 uint8_t cKB; 4095 int rc = ssmR3DataReadV2Raw(pSSM, &cKB, 1); 4089 4096 if (RT_FAILURE(rc)) 4090 4097 return rc; 4091 pSSM->u.Read.cbRecLeft -= sizeof(c Pages);4092 4093 size_t cbDecompr = (size_t)c Pages * PAGE_SIZE;4098 pSSM->u.Read.cbRecLeft -= sizeof(cKB); 4099 4100 size_t cbDecompr = (size_t)cKB * _1K; 4094 4101 AssertLogRelMsgReturn( cbDecompr >= pSSM->u.Read.cbRecLeft 4095 4102 && cbDecompr <= RT_SIZEOFMEMB(SSMHANDLE, u.Read.abDataBuffer), … … 4277 4284 | ((uint32_t)(abHdr[2] & 0x3f) << 6) 4278 4285 | ((uint32_t)(abHdr[1] & 0x0f) << 12); 4286 #if 0 /* disabled to optimize buffering */ 4279 4287 AssertLogRelMsgReturn(cb >= 0x00000800 && cb <= 0x0000ffff, ("cb=%#x\n", cb), VERR_SSM_INTEGRITY); 4288 #endif 4280 4289 break; 4281 4290 case 2: 4282 4291 cb = (abHdr[2] & 0x3f) 4283 4292 | ((uint32_t)(abHdr[1] & 0x1f) << 6); 4293 #if 0 /* disabled to optimize buffering */ 4284 4294 AssertLogRelMsgReturn(cb >= 0x00000080 && cb <= 0x000007ff, ("cb=%#x\n", cb), VERR_SSM_INTEGRITY); 4295 #endif 4285 4296 break; 4286 4297 default:
Note:
See TracChangeset
for help on using the changeset viewer.