From 75fe93ea74938d4a6c6b81f7cce3f19b7ffa894d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= Date: Wed, 18 May 2016 14:00:59 +0200 Subject: [PATCH] v2v: improve initrd search To make sure we can also find the initrd on openSUSE and SLES, we need two improvements: * the initrd filename may not end with '.img' * don't use the version + release from the RPM data, rather from the /lib/modules// path as we need to find it out anyway. --- v2v/convert_linux.ml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml index e23cd6476..08b27d65b 100644 --- a/v2v/convert_linux.ml +++ b/v2v/convert_linux.ml @@ -125,7 +125,7 @@ let rec convert ~keep_serial_console (g : G.guestfs) inspect source rcaps = let installed_kernels : kernel_info list = let rex_ko = Str.regexp ".*\\.k?o\\(\\.xz\\)?$" in let rex_ko_extract = Str.regexp ".*/\\([^/]+\\)\\.k?o\\(\\.xz\\)?$" in - let rex_initrd = Str.regexp "^initr\\(d\\|amfs\\)-.*\\.img$" in + let rex_initrd = Str.regexp "^initr\\(d\\|amfs\\)-.*\\(\\.img\\)?$" in filter_map ( function | { G.app2_name = name } as app @@ -158,7 +158,8 @@ let rec convert ~keep_serial_console (g : G.guestfs) inspect source rcaps = (* Get/construct the version. XXX Read this from kernel file. *) let version = - sprintf "%s-%s" app.G.app2_version app.G.app2_release in + let prefix_len = String.length "/lib/modules/" in + String.sub modpath prefix_len (String.length modpath - prefix_len) in (* Find the initramfs which corresponds to the kernel. * Since the initramfs is built at runtime, and doesn't have @@ -173,12 +174,11 @@ let rec convert ~keep_serial_console (g : G.guestfs) inspect source rcaps = let files = List.filter ( fun n -> - String.find n app.G.app2_version >= 0 && - String.find n app.G.app2_release >= 0 + String.find n version >= 0 ) files in (* Don't consider kdump initramfs images (RHBZ#1138184). *) let files = - List.filter (fun n -> String.find n "kdump.img" == -1) files in + List.filter (fun n -> String.find n "kdump" == -1) files in (* If several files match, take the shortest match. This * handles the case where we have a mix of same-version non-Xen * and Xen kernels: