Bug 1525241

Summary: virt-df displays zeros for filesystems with block size =512
Product: [Community] Virtualization Tools Reporter: Mykola Ivanets <stenavin>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED UPSTREAM QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: ptoscano, rbalakri, stenavin
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1525262 (view as bug list) Environment:
Last Closed: 2018-01-17 17:18:00 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:
Bug Depends On:    
Bug Blocks: 1525262    
Attachments:
Description Flags
Compressed sample image with mbr partition table, single fat32 partition in qcow2 format none

Description Mykola Ivanets 2017-12-12 21:25:15 UTC
Created attachment 1366952 [details]
Compressed sample image with mbr partition table, single fat32 partition in qcow2 format

Description of problem:

Call virt-df for disk image which contains filesystem with block size = 512 bytes. virt-df shows zeroes for such filesystems in all numeric fields (except Use%). But everything is OK if you call it with --human-readable option.

Version-Release number of selected component (if applicable):

Any. Tested on 1.36.10 Fedora 25 and 1.36.11 CentOS 6.

How reproducible:

virt-df -a disk.qcow2

Actual results:

Filesystem                           1K-blocks       Used  Available  Use%
disk.qcow2:/dev/sda1                         0          0          0    1%

Expected results:

Filesystem                           1K-blocks       Used  Available  Use%
disk.qcow2:/dev/sda1                     99800          1      99800    1%

Additional info:

statvfs:

bsize: 512
blocks: 199600
bfree: 199599

Here is a root of the issue: https://github.com/libguestfs/libguestfs/blob/master/df/output.c#L112

Comment 1 Richard W.M. Jones 2017-12-12 21:29:47 UTC
Can reproduce the same with virt-df 1.37.34fedora=28,release=3.fc28,libvirt

Comment 2 Richard W.M. Jones 2017-12-12 21:33:13 UTC
Relevant part of the trace output is:

libguestfs: trace: statvfs "/"
libguestfs: trace: statvfs = <struct guestfs_statvfs = bsize: 512, frsize: 512, blocks: 199600, bfree: 199599, bavail: 199599, files: 0, ffree: 0, favail: 0, fsid: 2049, flag: 4097, namemax: 1530, >

Note that bsize = 512, therefore factor = bsize / 1024 = 0, so
everything is multiplied by zero resulting in:

image:/dev/sda1                              0          0          0    1%

Comment 3 Richard W.M. Jones 2017-12-12 22:24:07 UTC
Patch posted:

https://www.redhat.com/archives/libguestfs/2017-December/msg00051.html

Comment 4 Pino Toscano 2018-01-17 17:18:00 UTC
This was fixed upstream with commit
d3afdb6e3edbfe031aac86c14df60c530781ace5
which is in libguestfs >= 1.37.36.