From e1b339688e5f8f2a14fe0c7e9d02ad68004e4655 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 15 Apr 2021 09:18:22 +0100 Subject: [PATCH] inspection: More reliable detection of Linux split /usr configurations In RHEL 8+, /usr/etc no longer exists. Since we were looking for this directory in order to detect a separate /usr partition, those were no longer detected, so the merging of /usr data into the root was not being done. The result was incomplete inspection data and failure of virt-v2v. All Linux systems since forever have had /usr/src but not /src, so detect this instead. Furthermore the merging code didn't work, because we expected that the root filesystem had a distro assigned, but in this configuration we may need to look for that information in /usr/lib/os-release (not on the root filesystem). This change makes the merging work even if we have incomplete information about the root filesystem, so long as we have an /etc/fstab entry pointing to the /usr mountpoint. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1949683 Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1930133 Fixes: commit 394d11be49121884295e61964ed47f5a8488c252 (cherry picked from commit 26427b9ecc64e7e5e53a1d577cef9dc080d08877) --- daemon/inspect.ml | 33 +++++++++++++++------------------ daemon/inspect_fs.ml | 6 +++--- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/daemon/inspect.ml b/daemon/inspect.ml index 945a476f6..fb75b4a6c 100644 --- a/daemon/inspect.ml +++ b/daemon/inspect.ml @@ -182,11 +182,9 @@ and check_for_duplicated_bsd_root fses = and collect_linux_inspection_info fses = List.map ( function - | { role = RoleRoot { distro = Some d } } as root -> - if d <> DISTRO_COREOS then - collect_linux_inspection_info_for fses root - else - root + | { role = RoleRoot { distro = Some DISTRO_COREOS } } as root -> root + | { role = RoleRoot _ } as root -> + collect_linux_inspection_info_for fses root | fs -> fs ) fses @@ -196,29 +194,28 @@ and collect_linux_inspection_info fses = * or other ways to identify the OS). *) and collect_linux_inspection_info_for fses root = - let root_distro, root_fstab = + let root_fstab = match root with - | { role = RoleRoot { distro = Some d; fstab = f } } -> d, f + | { role = RoleRoot { fstab = f } } -> f | _ -> assert false in try let usr = List.find ( function - | { role = RoleUsr { distro = d } } - when d = Some root_distro || d = None -> true + | { role = RoleUsr _; fs_location = usr_mp } -> + (* This checks that this usr is found in the fstab of + * the root filesystem. + *) + List.exists ( + fun (mountable, _) -> + usr_mp.mountable = mountable + ) root_fstab | _ -> false ) fses in - let usr_mountable = usr.fs_location.mountable in - - (* This checks that [usr] is found in the fstab of the root - * filesystem. If not, [Not_found] is thrown. - *) - ignore ( - List.find (fun (mountable, _) -> usr_mountable = mountable) root_fstab - ); - + eprintf "collect_linux_inspection_info_for: merging:\n%sinto:\n%s" + (string_of_fs usr) (string_of_fs root); merge usr root; root with diff --git a/daemon/inspect_fs.ml b/daemon/inspect_fs.ml index 6e00c7083..02b5a0470 100644 --- a/daemon/inspect_fs.ml +++ b/daemon/inspect_fs.ml @@ -164,10 +164,10 @@ and check_filesystem mountable = () ) (* Linux /usr? *) - else if Is.is_dir "/etc" && - Is.is_dir "/bin" && - Is.is_dir "/share" && + else if Is.is_dir "/bin" && Is.is_dir "/local" && + Is.is_dir "/share" && + Is.is_dir "/src" && not (Is.is_file "/etc/fstab") then ( debug_matching "Linux /usr"; role := `Usr; -- 2.31.1