The current code does not cover all subvolume variants. If a subvolume
exists which covers the entire root filesystem the result is two
mountables that have is_root set. This leads to failures in virt-ls and
other tools because they work only with a single root.
Update the btrfs subvolume call to use the "-o" option. This fixes two
cases: first it skips the subvolume for the root filesystem, so the
virt-ls case is covered. Second case is failure of mount(1) in
guestfs___check_for_filesystem_on. Without this change the subvol would
be a relative path, which causes mount(1) to return with ENOENT.
The option "-o" changes the output to print <path> as absolute:
<rescue> btrfs subvolume list /sysroot/
ID 257 gen 135
top level 5 path @
ID 258 gen 124 top level 257 path boot/grub2/i386-pc
vs.
<rescue> btrfs subvolume list -o /sysroot/
ID 258 gen 124
top level 257 path @/boot/grub2/i386-pc
mount -osubvol=boot/grub2/i386-pc $dev /sysroot will fail, while
mount -osubvol=@/boot/grub2/i386-pc $dev /sysroot will succeed.
Signed-off-by: Olaf Hering <olaf(a)aepfle.de>
---
daemon/btrfs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index 7a4d43d..3aceffc 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -356,6 +356,7 @@ do_btrfs_subvolume_list (const mountable_t *fs)
ADD_ARG (argv, i, str_btrfs);
ADD_ARG (argv, i, "subvolume");
ADD_ARG (argv, i, "list");
+ ADD_ARG (argv, i, "-o");
ADD_ARG (argv, i, fs_buf);
ADD_ARG (argv, i, NULL);
@@ -399,7 +400,7 @@ do_btrfs_subvolume_list (const mountable_t *fs)
* updated.
* "top level <n>" is the top level subvolume ID.
* "path <str>" is the subvolume path, relative to the top of the
- * filesystem.
+ * filesystem. Using the option "-o" will print the absolute path.
*
* Note that the order that each of the above is fixed, but
* different versions of btrfs may display different sets of data.