mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
block: Pass truncate exact=true where reasonable
This is a change in behavior, so all instances need a good justification. The comments added here should explain my reasoning. qed already had a comment that suggests it always expected bdrv_truncate()/blk_truncate() to behave as if exact=true were passed (c743849bee
came eight months before55b949c847
), so it was simply broken until now. Signed-off-by: Max Reitz <mreitz@redhat.com> Message-id: 20190918095144.955-8-mreitz@redhat.com Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> [mreitz: Changed comment in qed.c to explain why a new QED file must be empty, as requested and suggested by Maxim] Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
e61a28a9b6
commit
e8d04f9237
5 changed files with 31 additions and 7 deletions
|
@ -3831,7 +3831,12 @@ static int img_resize(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
ret = blk_truncate(blk, total_size, false, prealloc, &err);
|
||||
/*
|
||||
* The user expects the image to have the desired size after
|
||||
* resizing, so pass @exact=true. It is of no use to report
|
||||
* success when the image has not actually been resized.
|
||||
*/
|
||||
ret = blk_truncate(blk, total_size, true, prealloc, &err);
|
||||
if (ret < 0) {
|
||||
error_report_err(err);
|
||||
goto out;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue