[Libguestfs] virtdf outputs on host differs from df in guest

Richard W.M. Jones rjones at redhat.com
Mon Jan 8 08:23:49 UTC 2018


There are some strange things going on with the kernel XFS driver.
Opening a filesystem for write or read-only makes a difference to the
stats returned.

With bit-for-bit identical filesystems:

  ><rescue> mount /dev/sda1 /sysroot
  ><rescue> stat -f /sysroot
    File: "/sysroot"
      ID: 80100000000 Namelen: 255     Type: xfs
  Block size: 4096       Fundamental block size: 4096
  Blocks: Total: 24713      Free: 23347      Available: 23347
  Inodes: Total: 51136      Free: 51133

vs:

  ><rescue> mount -o ro /dev/sda1 /sysroot
  ><rescue> stat -f /sysroot
    File: "/sysroot"
      ID: 80100000000 Namelen: 255     Type: xfs
  Block size: 4096       Fundamental block size: 4096
  Blocks: Total: 24713      Free: 24653      Available: 24653
  Inodes: Total: 51136      Free: 51133

virt-df always uses the ‘-o ro’ option.

Despite this virt-df itself is working fine:

  $ virt-df -a test1.img 
  Filesystem                     1K-blocks       Used  Available  Use%
  test1.img:/dev/sda1                98852        240      98612    1%

Using the calculations from here:

  https://github.com/libguestfs/libguestfs/blob/ab0a3e0276656965021413194380ae602c05513d/df/output.c#L126-L136

                  blocks * bsize / 1024 = 24713 * 4096 / 1024 = 98852
(blocks - bfree) * bsize / 1024 = (24713-24653) * 4096 / 1024 = 240
                  bavail * bsize / 1024 = 24653 * 4096 / 1024 = 98612

So everything appears to be working fine, besides possibly odd stuff
going on in the kernel XFS driver.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW




More information about the Libguestfs mailing list