block/vdi: Fix image opening and creation for odd disk sizes
commitf21dc3a4652eeb82117d7d55d975278fe1444b26
authorStefan Weil <weil@mail.berlios.de>
Wed, 12 May 2010 18:25:45 +0000 (12 20:25 +0200)
committerKevin Wolf <kwolf@redhat.com>
Mon, 17 May 2010 08:20:05 +0000 (17 10:20 +0200)
tree6c679bf2481ec5185ab3ac8528b2715e51fe83c4
parent64a31d5c3d73396a88563d7a504654edc85aa854
block/vdi: Fix image opening and creation for odd disk sizes

The fix is based on a patch from Kevin Wolf. Here his comment:

"The number of blocks needs to be rounded up to cover all of the virtual hard
disk. Without this fix, we can't even open our own images if their size is not
a multiple of the block size."

While Kevin's patch addressed vdi_create, my modification also fixes
vdi_open which now accepts images with odd disk sizes.

v3:
Don't allow reading of disk images with too large disk sizes.
Neither VBoxManage nor old versions of qemu-img read such images.
This change requires rounding of odd disk sizes before we do the checks.

Cc: Kevin Wolf <kwolf@redhat.com>
Cc: François Revol <revol@free.fr>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/vdi.c