Bug 1188553

Summary: 'btrfs qgroup show' output changed, breaks libguestfs
Product: [Community] Virtualization Tools Reporter: Richard W.M. Jones <rjones>
Component: libguestfsAssignee: Hu Tao <hutao>
Status: CLOSED UPSTREAM QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: hutao, ppisar, ptoscano, rbalakri
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-04-30 14:36:48 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
fix parsing of output of 'btrfs qgroup show'
none
patch to fix parsing of output of 'btrfs qgroup show' none

Description Richard W.M. Jones 2015-02-03 08:59:04 UTC
Description of problem:

The output of btrfs qgroup show changed, resulting in a failure
in libguestfs.

The output is now:

  0/5           4.00KiB      4.00KiB

which doesn't match:

    if (sscanf (line, "%" SCNu64 "/%" SCNu64 " %" SCNu64 " %" SCNu64,
                &dummy1, &dummy2, &this->btrfsqgroup_rfer,
                &this->btrfsqgroup_excl) != 4) {
      reply_with_error ("cannot parse output of qgroup show command: %s", line);
      goto error;
    }

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

btrfs-progs-3.18.2-1.fc22.x86_64
libguestfs 1.29.24

How reproducible:

100%

Steps to Reproduce:
1. Use btrfs-qgroup-show API, or run the tests.

Comment 1 Richard W.M. Jones 2015-02-03 10:19:59 UTC
*** Bug 1188534 has been marked as a duplicate of this bug. ***

Comment 2 Hu Tao 2015-02-04 02:42:54 UTC
Created attachment 987903 [details]
fix parsing of output of 'btrfs qgroup show'

Comment 3 Hu Tao 2015-02-04 02:48:00 UTC
Created attachment 987904 [details]
patch to fix parsing of output of 'btrfs qgroup show'

Sorry, the previous one does not have commit message edited, please use this one.

Comment 4 Richard W.M. Jones 2015-02-05 08:36:08 UTC
This breaks the old btrfs command:

libguestfs: error: btrfs_qgroup_show: /: btrfs qgroup show: unrecognized option '--raw'
usage: btrfs qgroup show -pcreFf [--sort=qgroupid,rfer,excl,max_rfer,max_excl] <path>

    Show subvolume quota groups.

    -p		print parent qgroup id
    -c		print child qgroup id
    -r		print max referenced size of qgroup
    -e		print max exclusive size of qgroup
    -F		list all qgroups which impact the given path(include ancestral qgroups)
    -f		list all qgroups which impact the given path(exclude ancestral qgroups)
    --sort=qgroupid,rfer,excl,max_rfer,max_excl
    		list qgroups in order of qgroupid,rfer,max_rfer or max_excl
    		you can use '+' or '-' in front of each item.
    		(+:ascending, -:descending, ascending default)
FAIL: test_btrfs_qgroup_show_0

-----

I think you will need to check if the --raw flag is supported.

Comment 5 Pino Toscano 2015-04-30 14:36:48 UTC
This has been fixed with
https://github.com/libguestfs/libguestfs/commit/039ba9cf19b69f9c16efc831d4a4180cc04172a4
which is in libguestfs >= 1.29.31.