mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
storage: only run safezero if allocation is > 0
While a zero allocation in safezero should be fine it isn't when we use
posix_fallocate which returns EINVAL on a zero allocation.
While we could skip the zero allocation in safezero_posix_fallocate it's
an optimization to do it for all allocations.
This fixes vm installation via virtinst for me which otherwise aborts
like:
Starting install...
Retrieving file linux... | 5.9 MB 00:01 ...
Retrieving file initrd.gz... | 29 MB 00:07 ...
ERROR Couldn't create storage volume 'virtinst-linux.sBgds4': 'cannot fill file '/var/lib/libvirt/boot/virtinst-linux.sBgds4': Invalid argument'
The error was introduced by e30297b0
as spotted by Chunyan Liu
This commit is contained in:
parent
2f01cfdf05
commit
269d39afe5
@ -455,7 +455,7 @@ createRawFile(int fd, virStorageVolDefPtr vol,
|
||||
pos = inputvol->target.capacity - remain;
|
||||
}
|
||||
|
||||
if (need_alloc) {
|
||||
if (need_alloc && (vol->target.allocation - pos > 0)) {
|
||||
if (safezero(fd, pos, vol->target.allocation - pos) < 0) {
|
||||
ret = -errno;
|
||||
virReportSystemError(errno, _("cannot fill file '%s'"),
|
||||
|
Loading…
Reference in New Issue
Block a user