[PATCH] fix vol-create when target allocation=0

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Regression is introduced by commit e30297b0. After that, it will
report "Cannot fill file" error with following xml file:
<volume>
  <name>virtinst-vmlinuz-xen.tP1NHh</name>
  <capacity>4343792</capacity>
  <allocation>0</allocation>
  <target>
    <format type="raw"/>
    <nocow/>
  </target>
</volume>
Because of this, installing xen pv guest with virt-manager fails.

Reason is: posix_fallocate(int fd, off_t offset, off_t len) will
return EINVAL when len is equal to 0. So, this patch adds a check
before calling safezero().

Signed-off-by: Chunyan Liu <cyliu@xxxxxxxx>
---
 src/storage/storage_backend.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index db49739..2a265af 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -455,7 +455,7 @@ createRawFile(int fd, virStorageVolDefPtr vol,
         pos = inputvol->target.capacity - remain;
     }
 
-    if (need_alloc) {
+    if (need_alloc && (vol->target.allocation > pos)) {
         if (safezero(fd, pos, vol->target.allocation - pos) < 0) {
             ret = -errno;
             virReportSystemError(errno, _("cannot fill file '%s'"),
-- 
2.1.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]