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

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