Bug 1525241 - virt-df displays zeros for filesystems with block size =512
Summary: virt-df displays zeros for filesystems with block size =512
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libguestfs
Version: unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Richard W.M. Jones
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks: 1525262
TreeView+ depends on / blocked
 
Reported: 2017-12-12 21:25 UTC by Mykola Ivanets
Modified: 2018-01-17 17:18 UTC (History)
3 users (show)

Fixed In Version:
Clone Of:
: 1525262 (view as bug list)
Environment:
Last Closed: 2018-01-17 17:18:00 UTC
Embargoed:


Attachments (Terms of Use)
Compressed sample image with mbr partition table, single fat32 partition in qcow2 format (1.10 KB, application/x-xz)
2017-12-12 21:25 UTC, Mykola Ivanets
no flags Details

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.


Note You need to log in before you can comment on or make changes to this bug.