qemu-img: Check post-truncation size
commit5279b30392da7a3248b320c75f20c61e3a95863c
authorMax Reitz <mreitz@redhat.com>
Sat, 21 Apr 2018 16:39:57 +0000 (21 18:39 +0200)
committerMax Reitz <mreitz@redhat.com>
Tue, 15 May 2018 14:15:21 +0000 (15 16:15 +0200)
tree2a66caefe524deea0645e27a20b051804644462d
parent3e7a95feb9b5d66cff7fee38b3c423135ed245f6
qemu-img: Check post-truncation size

Some block drivers (iscsi and file-posix when dealing with device files)
do not actually support truncation, even though they provide a
.bdrv_truncate() method and will happily return success when providing a
new size that does not exceed the current size.  This is because these
drivers expect the user to resize the image outside of qemu and then
provide qemu with that information through the block_resize command
(compare cb1b83e740384b4e0d950f3d7c81c02b8ce86c2e).

Of course, anyone using qemu-img resize will find that behavior useless.
So we should check the actual size of the image after the supposedly
successful truncation took place, emit an error if nothing changed and
emit a warning if the target size was not met.

Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1523065
Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-id: 20180421163957.29872-1-mreitz@redhat.com
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
qemu-img.c