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 <kwolf@redhat.com> Signed-off-by: Jeff Cody <jcody@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-id: 8a4d2da73a8dbc04cde62bea782fc09ff84b1cf1.1418018421.git.jcody@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
0571df44a1
commit
a9d1e9daa5
@ -1111,6 +1111,7 @@ static coroutine_fn int vhdx_co_readv(BlockDriverState *bs, int64_t sector_num,
|
|||||||
case PAYLOAD_BLOCK_NOT_PRESENT: /* fall through */
|
case PAYLOAD_BLOCK_NOT_PRESENT: /* fall through */
|
||||||
case PAYLOAD_BLOCK_UNDEFINED:
|
case PAYLOAD_BLOCK_UNDEFINED:
|
||||||
case PAYLOAD_BLOCK_UNMAPPED:
|
case PAYLOAD_BLOCK_UNMAPPED:
|
||||||
|
case PAYLOAD_BLOCK_UNMAPPED_v095:
|
||||||
case PAYLOAD_BLOCK_ZERO:
|
case PAYLOAD_BLOCK_ZERO:
|
||||||
/* return zero */
|
/* return zero */
|
||||||
qemu_iovec_memset(&hd_qiov, 0, 0, sinfo.bytes_avail);
|
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,
|
|||||||
sectors_to_write += iov2.iov_len >> BDRV_SECTOR_BITS;
|
sectors_to_write += iov2.iov_len >> BDRV_SECTOR_BITS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case PAYLOAD_BLOCK_NOT_PRESENT: /* fall through */
|
case PAYLOAD_BLOCK_NOT_PRESENT: /* fall through */
|
||||||
case PAYLOAD_BLOCK_UNMAPPED:
|
case PAYLOAD_BLOCK_UNMAPPED:
|
||||||
|
case PAYLOAD_BLOCK_UNMAPPED_v095:
|
||||||
case PAYLOAD_BLOCK_UNDEFINED:
|
case PAYLOAD_BLOCK_UNDEFINED:
|
||||||
bat_prior_offset = sinfo.file_offset;
|
bat_prior_offset = sinfo.file_offset;
|
||||||
ret = vhdx_allocate_block(bs, s, &sinfo.file_offset);
|
ret = vhdx_allocate_block(bs, s, &sinfo.file_offset);
|
||||||
|
@ -226,7 +226,8 @@ typedef struct QEMU_PACKED VHDXLogDataSector {
|
|||||||
#define PAYLOAD_BLOCK_NOT_PRESENT 0
|
#define PAYLOAD_BLOCK_NOT_PRESENT 0
|
||||||
#define PAYLOAD_BLOCK_UNDEFINED 1
|
#define PAYLOAD_BLOCK_UNDEFINED 1
|
||||||
#define PAYLOAD_BLOCK_ZERO 2
|
#define PAYLOAD_BLOCK_ZERO 2
|
||||||
#define PAYLOAD_BLOCK_UNMAPPED 5
|
#define PAYLOAD_BLOCK_UNMAPPED 3
|
||||||
|
#define PAYLOAD_BLOCK_UNMAPPED_v095 5
|
||||||
#define PAYLOAD_BLOCK_FULLY_PRESENT 6
|
#define PAYLOAD_BLOCK_FULLY_PRESENT 6
|
||||||
#define PAYLOAD_BLOCK_PARTIALLY_PRESENT 7
|
#define PAYLOAD_BLOCK_PARTIALLY_PRESENT 7
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user