Calling fallocate on the new (smaller) capacity ensures that the whole file is allocated, but it does not reduce the file size.
Also call ftruncate after fallocate. https://bugzilla.redhat.com/show_bug.cgi?id=1366446 --- src/util/virstoragefile.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 5df1ea0b8..80a33b1a6 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -1338,12 +1338,12 @@ virStorageFileResize(const char *path, } goto cleanup; } - } else { - if (ftruncate(fd, capacity) < 0) { - virReportSystemError(errno, - _("Failed to truncate file '%s'"), path); - goto cleanup; - } + } + + if (ftruncate(fd, capacity) < 0) { + virReportSystemError(errno, + _("Failed to truncate file '%s'"), path); + goto cleanup; } if (VIR_CLOSE(fd) < 0) { -- 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list