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