Blame SOURCES/0077-v2v-When-picking-a-default-kernel-favour-non-debug-k.patch

0d20ef
From 1edc8185581110a862e17f74414b9caca17ffeb6 Mon Sep 17 00:00:00 2001
0d20ef
From: "Richard W.M. Jones" <rjones@redhat.com>
0d20ef
Date: Thu, 4 Dec 2014 09:13:23 +0000
0d20ef
Subject: [PATCH] v2v: When picking a default kernel, favour non-debug kernels
0d20ef
 over debug kernels (RHBZ#1170073).
0d20ef
0d20ef
(cherry picked from commit 0c2e676f6c92efce890006903585dabd1f72f3b1)
0d20ef
---
0d20ef
 v2v/convert_linux.ml | 20 +++++++++++++++++---
0d20ef
 1 file changed, 17 insertions(+), 3 deletions(-)
0d20ef
0d20ef
diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml
0d20ef
index 6e45ac8..5852022 100644
0d20ef
--- a/v2v/convert_linux.ml
0d20ef
+++ b/v2v/convert_linux.ml
0d20ef
@@ -49,13 +49,14 @@ type kernel_info = {
0d20ef
   ki_modules : string list;        (* The list of module names. *)
0d20ef
   ki_supports_virtio : bool;       (* Kernel has virtio drivers? *)
0d20ef
   ki_is_xen_kernel : bool;         (* Is a Xen paravirt kernel? *)
0d20ef
+  ki_is_debug : bool;              (* Is debug kernel? *)
0d20ef
 }
0d20ef
 
0d20ef
 let string_of_kernel_info ki =
0d20ef
-  sprintf "(%s, %s, %s, %s, %s, virtio=%b, xen=%b)"
0d20ef
+  sprintf "(%s, %s, %s, %s, %s, virtio=%b, xen=%b, debug=%b)"
0d20ef
     ki.ki_name ki.ki_version ki.ki_arch ki.ki_vmlinuz
0d20ef
     (match ki.ki_initrd with None -> "None" | Some f -> f)
0d20ef
-    ki.ki_supports_virtio ki.ki_is_xen_kernel
0d20ef
+    ki.ki_supports_virtio ki.ki_is_xen_kernel ki.ki_is_debug
0d20ef
 
0d20ef
 (* The conversion function. *)
0d20ef
 let rec convert ~verbose ~keep_serial_console (g : G.guestfs) inspect source =
0d20ef
@@ -236,6 +237,13 @@ let rec convert ~verbose ~keep_serial_console (g : G.guestfs) inspect source =
0d20ef
            let supports_virtio = List.mem "virtio_net" modules in
0d20ef
            let is_xen_kernel = List.mem "xennet" modules in
0d20ef
 
0d20ef
+           (* If the package name is like "kernel-debug", then it's
0d20ef
+            * a debug kernel.
0d20ef
+            *)
0d20ef
+           let is_debug =
0d20ef
+             string_suffix app.G.app2_name "-debug" ||
0d20ef
+             string_suffix app.G.app2_name "-dbg" in
0d20ef
+
0d20ef
            Some {
0d20ef
              ki_app  = app;
0d20ef
              ki_name = name;
0d20ef
@@ -248,6 +256,7 @@ let rec convert ~verbose ~keep_serial_console (g : G.guestfs) inspect source =
0d20ef
              ki_modules = modules;
0d20ef
              ki_supports_virtio = supports_virtio;
0d20ef
              ki_is_xen_kernel = is_xen_kernel;
0d20ef
+             ki_is_debug = is_debug;
0d20ef
            }
0d20ef
 
0d20ef
          with Not_found -> None
0d20ef
@@ -739,7 +748,12 @@ let rec convert ~verbose ~keep_serial_console (g : G.guestfs) inspect source =
0d20ef
       let compare_best_kernels k1 k2 =
0d20ef
         let i = compare k1.ki_supports_virtio k2.ki_supports_virtio in
0d20ef
         if i <> 0 then i
0d20ef
-        else compare_app2_versions k1.ki_app k2.ki_app
0d20ef
+        else (
0d20ef
+          let i = compare_app2_versions k1.ki_app k2.ki_app in
0d20ef
+          if i <> 0 then i
0d20ef
+          (* Favour non-debug kernels over debug kernels (RHBZ#1170073). *)
0d20ef
+          else compare k2.ki_is_debug k1.ki_is_debug
0d20ef
+        )
0d20ef
       in
0d20ef
       let kernels = grub_kernels in
0d20ef
       let kernels = List.filter (fun { ki_is_xen_kernel = is_xen_kernel } -> not is_xen_kernel) kernels in
0d20ef
-- 
0d20ef
1.8.3.1
0d20ef