Bug 880801

Summary: virt-df with two -a options displays incorrect disk image name
Product: [Community] Virtualization Tools Reporter: Richard W.M. Jones <rjones>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED UPSTREAM QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: dyasny, mbooth
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 880805 880806 (view as bug list) Environment:
Last Closed: 2012-11-29 11:48:28 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: 880805, 880806    

Description Richard W.M. Jones 2012-11-27 20:10:06 UTC
Description of problem:

(Reported by muued on IRC)

$ sudo virt-df -a /dev/vg_pin/Debian5x64 -a /dev/vg_pin/WinXP
Filesystem                           1K-blocks       Used  Available  Use%
WinXP:/dev/sda1                         329679      67325     244787   21%
WinXP:/dev/sdb1                        6281380    2812564    3468816   45%
WinXP:/dev/debian5x64.home.annexia.org/home
                                       3555936     365544    3009760   11%
WinXP:/dev/debian5x64.home.annexia.org/root
                                        329233     309786       2449   95%
WinXP:/dev/debian5x64.home.annexia.org/tmp
                                        309401      10292     283135    4%
WinXP:/dev/debian5x64.home.annexia.org/usr
                                       3539776    2089124    1270840   60%
WinXP:/dev/debian5x64.home.annexia.org/var
                                       2774352    2088408     548332   76%

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

libguestfs 1.18.10
libguestfs 1.19.64

How reproducible:

100%

Steps to Reproduce:
1. Run virt-df with two -a options.

Comment 1 Richard W.M. Jones 2012-11-27 20:23:21 UTC
Strictly speaking (reading the man page), this is an
incorrect use of virt-df:

      "If any -a or -d arguments are specified, "virt-df" performs a "df"-type
       operation on either the single named libvirt domain, or on the disk
       image(s) listed on the command line (which must all belong to a single
       VM).  In this mode (with arguments), "virt-df" will only work for a
       single guest.  If you want to run on multiple guests, then you have to
       invoke "virt-df" multiple times."

But:

(1) The behaviour is unexpected.  We should at least document it
more clearly.

(2) Using the name of the last disk is arbitrary, and wrong.  We
should use something else here, perhaps both names, or perhaps
the first name plus '*', or an explanatory string.

Comment 2 Richard W.M. Jones 2012-11-27 20:27:07 UTC
Note also, the same thing can happen if the user uses
the -d option multiple times:

$ sudo virt-df -d F17x64 -d F19Rawhidex32 Filesystem                           1K-blocks       Used  Available  Use%
F19Rawhidex32:/dev/sda1                 495844      97005     373239   20%
F19Rawhidex32:/dev/sdb1                 495844      96275     373969   20%
F19Rawhidex32:/dev/sdb3               26894392    3714140   21814084   14%
F19Rawhidex32:/dev/vg_f17x64/lv_root  28447752    5318808   21683876   19%

Roughly the same code in main.c:282 is involved.

Comment 3 Richard W.M. Jones 2012-11-27 20:28:25 UTC
Also the --help output and SYNOPSIS in the man page is
less than clear on this issue.

Comment 4 Richard W.M. Jones 2012-11-29 11:48:28 UTC
Upstream fix here:
https://github.com/libguestfs/libguestfs/commit/9e7daf2ee8f0a619440ca1c55dfe5ddcf61b4460