Blame SOURCES/0008-inspection-More-reliable-detection-of-Linux-split-us.patch

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