libguestfs uses aug_get to get /files/etc/fstab/X/opt instead /files/etc/fstab/X/opt[Y]

Bug #1615337 reported by Zhongfu Li
24
This bug affects 5 people
Affects Status Importance Assigned to Milestone
libguestfs (Ubuntu)
Confirmed
Medium
Unassigned

Bug Description

When running virt-sysprep on a VM file containing an fstab, with entries with multiple options, it will fail with "guestfsd: error: aug_get: /files/etc/fstab/1/opt: Too many matches for path expression: There are 2 nodes matching /files/etc/fstab/1/opt", or a similar error.

Augeas' aug_get only returns the value for a single node, and will fail with an error if there are multiple matches for the string. In this case, the nodes "/files/etc/fstab/1/opt[1]" and "/files/etc/fstab/1/opt[2]" exists and aug_get /files/etc/fstab/1/opt will match both of these nodes.

It appears that libguestfs does "aug_match /files/etc/fstab/1/opt" to get the nodes for all the options for the first entry (and so on), but it then runs "aug_get /files/etc/fstab/1/opt", which returns an error. I suspect that it's supposed to get the first option instead (/files/etc/fstab/1/opt[1]).

Ubuntu version: Ubuntu 16.04 LTS
libguestfs0 version: 1:1.32.2-4ubuntu2
libguestfs-tools version: 1:1.32.2-4ubuntu2

Additional information:
The image file in question is a qcow2 image file, with Ubuntu 16.04 "xenial" installed.
The partitions present on the qcow2 image are a FAT32 EFI System Partition, and a btrfs root filesystem with two subvolumes: @ (for /), and @home (for /home).
The fstab present on the installation of Ubuntu contains multiple fstab entries with multiple options, e.g. "relatime,subvol=@" for /

Revision history for this message
Zhongfu Li (zhongfu) wrote :
Revision history for this message
Zhongfu Li (zhongfu) wrote :

Bug still exists as of commit c711b517094375d4c321af4800e747b955643133 (https://github.com/libguestfs/libguestfs/commit/c711b517094375d4c321af4800e747b955643133)

Revision history for this message
Richard Jones (rjones-redhat) wrote :

Reproducer for this is:

$ virt-builder fedora-24

$ rm fedora-24-copy
$ truncate -s20G fedora-24-copy
$ virt-resize fedora-24.img fedora-24-copy

$ guestfish -a fedora-24-copy -i
><fs> list-filesystems
/dev/sda1: ext4
/dev/sda2: swap
/dev/sda3: xfs
/dev/sda4: unknown
><fs> mkfs btrfs /dev/sda4
><fs> list-filesystems
/dev/sda1: ext4
/dev/sda2: swap
/dev/sda3: xfs
/dev/sda4: btrfs
><fs> emacs /etc/fstab

... Add an extra fstab entry at the end of the file:

/dev/sda4 /home btrfs rw,user 0 0

... It doesn't matter what the options field says as long as there are
at least 2 options.

><fs> exit

$ virt-inspector fedora-24-copy
libguestfs: error: aug_get: aug_get: /files/etc/fstab/4/opt: Too many matches for path expression: There are 2 nodes matching /files/etc/fstab/4/opt

Revision history for this message
Richard Jones (rjones-redhat) wrote :
Revision history for this message
Richard Jones (rjones-redhat) wrote :

Fixed upstream in
https://github.com/libguestfs/libguestfs/commit/738c3bf4fdce569858369b2d2ce3879bf4b75f50
which will appear in libguestfs >= 1.35.2 and >= 1.34.1.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in libguestfs (Ubuntu):
status: New → Confirmed
Changed in libguestfs (Ubuntu):
importance: Undecided → Medium
Revision history for this message
Landon Gilbert-Bland (landogbland) wrote :

Any idea if the patched version will make it 16.04?

Revision history for this message
Thomas Dreibholz (dreibh) wrote :

The bug still exists in Ubuntu 16.04., more than one year after a fix has been released. Is there any backport available?

Revision history for this message
Richard Jones (rjones-redhat) wrote :

Someone's going to need to step up and become a maintainer, because there is currently no libguestfs maintainer for Ubuntu.

Revision history for this message
Arnab Banerjee (arnabcse28) wrote :

Looks like there's no fix available for Ubuntu 16.04 yet for this issue...

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.