Skip to content

Commit a9d1e9d

Browse files
codyprimestefanhaRH
authored andcommitted
block: vhdx - update PAYLOAD_BLOCK_UNMAPPED value to match 1.00 spec
The 0.95 VHDX spec defined PAYLOAD_BLOCK_UNMAPPED to be 5. The 1.00 VHDX spec redefines PAYLOAD_BLOCK_UNMAPPED to be 3 instead. The original value of 5 is now an undefined state in the spec, but it should be safe to treat it the same and return zeros for data read. This way, we can maintain compatibility with any images out in the wild that may have been created in accordance to the 0.95 spec. Reported-by: Kevin Wolf <[email protected]> Signed-off-by: Jeff Cody <[email protected]> Reviewed-by: Max Reitz <[email protected]> Message-id: 8a4d2da73a8dbc04cde62bea782fc09ff84b1cf1.1418018421.git.jcody@redhat.com Signed-off-by: Stefan Hajnoczi <[email protected]>
1 parent 0571df4 commit a9d1e9d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

block/vhdx.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,7 @@ static coroutine_fn int vhdx_co_readv(BlockDriverState *bs, int64_t sector_num,
11111111
case PAYLOAD_BLOCK_NOT_PRESENT: /* fall through */
11121112
case PAYLOAD_BLOCK_UNDEFINED:
11131113
case PAYLOAD_BLOCK_UNMAPPED:
1114+
case PAYLOAD_BLOCK_UNMAPPED_v095:
11141115
case PAYLOAD_BLOCK_ZERO:
11151116
/* return zero */
11161117
qemu_iovec_memset(&hd_qiov, 0, 0, sinfo.bytes_avail);
@@ -1277,10 +1278,10 @@ static coroutine_fn int vhdx_co_writev(BlockDriverState *bs, int64_t sector_num,
12771278
sectors_to_write += iov2.iov_len >> BDRV_SECTOR_BITS;
12781279
}
12791280
}
1280-
12811281
/* fall through */
12821282
case PAYLOAD_BLOCK_NOT_PRESENT: /* fall through */
12831283
case PAYLOAD_BLOCK_UNMAPPED:
1284+
case PAYLOAD_BLOCK_UNMAPPED_v095:
12841285
case PAYLOAD_BLOCK_UNDEFINED:
12851286
bat_prior_offset = sinfo.file_offset;
12861287
ret = vhdx_allocate_block(bs, s, &sinfo.file_offset);

block/vhdx.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ typedef struct QEMU_PACKED VHDXLogDataSector {
226226
#define PAYLOAD_BLOCK_NOT_PRESENT 0
227227
#define PAYLOAD_BLOCK_UNDEFINED 1
228228
#define PAYLOAD_BLOCK_ZERO 2
229-
#define PAYLOAD_BLOCK_UNMAPPED 5
229+
#define PAYLOAD_BLOCK_UNMAPPED 3
230+
#define PAYLOAD_BLOCK_UNMAPPED_v095 5
230231
#define PAYLOAD_BLOCK_FULLY_PRESENT 6
231232
#define PAYLOAD_BLOCK_PARTIALLY_PRESENT 7
232233

0 commit comments

Comments
 (0)