]> git.proxmox.com Git - mirror_qemu.git/commit
block: Fix copy-on-read crash with partial final cluster
authorKevin Wolf <kwolf@redhat.com>
Fri, 6 Jul 2018 16:41:07 +0000 (18:41 +0200)
committerKevin Wolf <kwolf@redhat.com>
Tue, 10 Jul 2018 08:36:15 +0000 (10:36 +0200)
commitb0ddcbbb36a66a605eb232b905cb49b1cc72e74e
tree17559d6ee3a6ea34daf7bd50a8174a54d90a4b30
parentb994c5bc515fe611885113e7cfa7e87817bfd4e2
block: Fix copy-on-read crash with partial final cluster

If the virtual disk size isn't aligned to full clusters,
bdrv_co_do_copy_on_readv() may get pnum == 0 before having the full
cluster completed, which will let it run into an assertion failure:

qemu-io: block/io.c:1203: bdrv_co_do_copy_on_readv: Assertion `skip_bytes < pnum' failed.

Check for EOF, assert that we read at least as much as the read request
originally wanted to have (which is true at EOF because otherwise
bdrv_check_byte_request() would already have returned an error) and
return success early even though we couldn't copy the full cluster.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/io.c
tests/qemu-iotests/197
tests/qemu-iotests/197.out