Bug 1146339

Summary: Improve the error showing when no enough space left on host while conversion
Product: Red Hat Enterprise Linux 7 Reporter: zhoujunqin <juzhou>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED WONTFIX QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1CC: codong, dyuan, mbooth, mzhan, ptoscano, tzheng
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: V2V
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-04-20 15:12:32 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
log file for step3
none
log file for step4 none

Description zhoujunqin 2014-09-25 03:48:16 UTC
Description of problem:
Improve the error showing when no enough space left on host while conversion

Version-Release number of selected component (if applicable):
virt-v2v-1.27.54-1.1.el7.x86_64
libguestfs-1.27.54-1.1.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Copy xen guest image and xml file from xen server to v2v server:
# qemu-img info /var/lib/xen/images/rhel6.6-pv-x64-test.img
image: /var/lib/xen/images/rhel6.6-pv-x64-test.img
file format: raw
virtual size: 7.8G (8388608000 bytes)
disk size: 7.8G

2. Check the host left space <8G
# df -h 
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda6        98G   95G  3.4G  97% /
devtmpfs        3.8G     0  3.8G   0% /dev
tmpfs           3.9G  144K  3.9G   1% /dev/shm
tmpfs           3.9G  169M  3.7G   5% /run
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda1        96G   88G  3.6G  97% /mnt
/dev/sda3        98G   39G   59G  40% /opt

3. Run virt-v2v to connect a xen pv/hvm guest either by -i disk or -i libvirtxml.
# export LIBGUESTFS_BACKEND=direct

# virt-v2v -i libvirtxml -o local -os  /var/tmp/  rhel6.6-pv-x64-test.xml -on test33 -of raw -oa preallocated
[   0.0] Opening the source -i libvirtxml rhel6.6-pv-x64-test.xml
[   0.0] Creating an overlay to protect the source from being modified
[   1.0] Opening the overlay
[   4.0] Initializing the target -o local -os /var/tmp/
[   4.0] Inspecting the overlay
[   8.0] Checking for sufficient free disk space in the guest
[   8.0] Estimating space required on target for each disk
[   8.0] Converting Red Hat Enterprise Linux Server release 6.6 Beta (Santiago) to run on KVM
This guest has virtio drivers installed.
[  34.0] Mapping filesystem data to avoid copying unused and blank areas
[  35.0] Closing the overlay
[  35.0] Copying disk 1/1 to /var/tmp/test33-sda (raw)
virt-v2v: error: libguestfs error: /var/tmp/test33-sda: fallocate: No space 
left on device

If reporting bugs, run virt-v2v with debugging enabled and include the 
complete output:

  virt-v2v -v -x [...]

4. Run step3 again with host space using almost 100%.
# df -h 
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda6        98G   98G   20K 100% /
devtmpfs        3.8G     0  3.8G   0% /dev
tmpfs           3.9G  144K  3.9G   1% /dev/shm
tmpfs           3.9G  161M  3.7G   5% /run
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda1        96G   88G  3.6G  97% /mnt
/dev/sda3        98G   39G   59G  40% /opt

# virt-v2v -i libvirtxml -o local -os  /var/tmp/  rhel6.6-pv-x64-test.xml -on test333 -of raw -oa preallocated 
[   0.0] Opening the source -i libvirtxml rhel6.6-pv-x64-test.xml
[   0.0] Creating an overlay to protect the source from being modified
virt-v2v: error: /tmp/v2vovl8aad70.qcow2: No space left on device

If reporting bugs, run virt-v2v with debugging enabled and include the 
complete output:

  virt-v2v -v -x [...]

Actual results:
As described.

Expected results:
"fallocate" is a function name, didn't show such function in error message, it's unsafe and unfriendly.
step3 and step4 result should keep consistent.

Additional info:
Attached log file for step3 and step4.

Comment 1 zhoujunqin 2014-09-25 03:50:38 UTC
Created attachment 940968 [details]
log file for step3

Comment 2 zhoujunqin 2014-09-25 03:51:21 UTC
Created attachment 940969 [details]
log file for step4

Comment 4 Richard W.M. Jones 2014-09-25 13:39:15 UTC
Since this is a cosmetic change, moving to 7.2.

Comment 6 Richard W.M. Jones 2015-04-20 15:12:32 UTC
I'm going to close because I think the error messages are
reasonable.  They both clearly state the problem
("No space left on device").  fallocate is the system call
which fails, and the top Google hit for me is clear:

  fallocate(2) - Linux manual page - man7.org
  man7.org/linux/man-pages/man2/fallocate.2.html
  For the portable, POSIX.1-specified method of ensuring that space is
    allocated for a file, 

In addition, predicting the space required for conversion is
non-trivial.  If we just used the size of the input disk, then
we'd massively overestimate in the common case (-oa preallocated
is not common, nor especially recommended).

We already have code to estimate the space used by the target
(v2v.ml:estimate_target_size) but it's only used by the RHEV
target, and it is notoriously inaccurate.

See also:
https://github.com/libguestfs/libguestfs/blob/a1646fa65c6cd544e287f25051a88c4a572ebb3e/v2v/v2v.ml#L641-L767