|
|
a034fe |
From a0e44877a4ba2df153ec5334b24eb254f9c2aeb3 Mon Sep 17 00:00:00 2001
|
|
|
a034fe |
From: Pino Toscano <ptoscano@redhat.com>
|
|
|
a034fe |
Date: Wed, 20 Mar 2019 12:32:02 +0100
|
|
|
a034fe |
Subject: [PATCH] v2v: linux: improve arch detection from modules
|
|
|
a034fe |
(RHBZ#1690574)
|
|
|
a034fe |
|
|
|
a034fe |
Try to look for a well known kernel module (so far only virtio, or kvm)
|
|
|
a034fe |
to use for detecting the architecture of a kernel. This way, we can
|
|
|
a034fe |
avoid picking 3rd party modules that cause troubles.
|
|
|
a034fe |
|
|
|
a034fe |
(cherry picked from commit 363b5e0b4ecebe861a9aafe8bce5a8390b54571c)
|
|
|
a034fe |
---
|
|
|
a034fe |
v2v/linux_kernels.ml | 30 +++++++++++++++++++++++++++---
|
|
|
a034fe |
1 file changed, 27 insertions(+), 3 deletions(-)
|
|
|
a034fe |
|
|
|
a034fe |
diff --git a/v2v/linux_kernels.ml b/v2v/linux_kernels.ml
|
|
|
a034fe |
index 889ec2f2a..30160f0da 100644
|
|
|
a034fe |
--- a/v2v/linux_kernels.ml
|
|
|
a034fe |
+++ b/v2v/linux_kernels.ml
|
|
|
a034fe |
@@ -185,11 +185,35 @@ let detect_kernels (g : G.guestfs) inspect family bootloader =
|
|
|
a034fe |
assert (List.length modules > 0);
|
|
|
a034fe |
|
|
|
a034fe |
(* Determine the kernel architecture by looking at the
|
|
|
a034fe |
- * architecture of an arbitrary kernel module.
|
|
|
a034fe |
+ * architecture of a kernel module.
|
|
|
a034fe |
+ *
|
|
|
a034fe |
+ * To avoid architecture detection issues with 3rd party
|
|
|
a034fe |
+ * modules (RHBZ#1690574), try to pick one of the well
|
|
|
a034fe |
+ * known modules, if available. Otherwise, an arbitrary
|
|
|
a034fe |
+ * module is used.
|
|
|
a034fe |
*)
|
|
|
a034fe |
let arch =
|
|
|
a034fe |
- let any_module = modpath ^ List.hd modules in
|
|
|
a034fe |
- g#file_architecture (g#realpath any_module) in
|
|
|
a034fe |
+ (* Well known kernel modules. *)
|
|
|
a034fe |
+ let candidates = [ "virtio"; "kvm" ] in
|
|
|
a034fe |
+ let all_candidates = List.flatten (
|
|
|
a034fe |
+ List.map (
|
|
|
a034fe |
+ fun f ->
|
|
|
a034fe |
+ [ "/" ^ f ^ ".o"; "/" ^ f ^ ".ko"; "/" ^ f ^ ".ko.xz" ]
|
|
|
a034fe |
+ ) candidates
|
|
|
a034fe |
+ ) in
|
|
|
a034fe |
+ let candidate =
|
|
|
a034fe |
+ try
|
|
|
a034fe |
+ List.find (
|
|
|
a034fe |
+ fun m ->
|
|
|
a034fe |
+ List.exists (String.is_suffix m) all_candidates
|
|
|
a034fe |
+ ) modules
|
|
|
a034fe |
+ with Not_found ->
|
|
|
a034fe |
+ (* No known module found, pick an arbitrary one
|
|
|
a034fe |
+ * (the first).
|
|
|
a034fe |
+ *)
|
|
|
a034fe |
+ List.hd modules in
|
|
|
a034fe |
+ let candidate = modpath ^ candidate in
|
|
|
a034fe |
+ g#file_architecture (g#realpath candidate) in
|
|
|
a034fe |
|
|
|
a034fe |
(* Just return the module names, without path or extension. *)
|
|
|
a034fe |
let modules = List.filter_map (
|
|
|
a034fe |
--
|
|
|
a034fe |
2.21.0
|
|
|
a034fe |
|