[Libguestfs] [PATCH v2 2/3] v2v: linux kernels: detect config file

Pino Toscano
Mon, 03 Oct 2016 09:44:00 -0000

Add a simple detection for the config file of each kernel, so that can
be used later to get more information on what a kernel provides.
---
 v2v/linux_kernels.ml  | 10 +++++++++-
 v2v/linux_kernels.mli |  1 +
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/v2v/linux_kernels.ml b/v2v/linux_kernels.ml
index b292921..df093d0 100644
--- a/v2v/linux_kernels.ml
+++ b/v2v/linux_kernels.ml
@@ -41,12 +41,14 @@ type kernel_info = {
   ki_supports_virtio : bool;
   ki_is_xen_kernel : bool;
   ki_is_debug : bool;
+  ki_config_file : string option;
 }

 let string_of_kernel_info ki -  sprintf "(%s, %s, %s, %s, %s, virtio=%b,
xen=%b, debug=%b)"
+  sprintf "(%s, %s, %s, %s, %s, %s, virtio=%b, xen=%b, debug=%b)"
     ki.ki_name ki.ki_version ki.ki_arch ki.ki_vmlinuz
     (match ki.ki_initrd with None -> "None" | Some f -> f)
+    (match ki.ki_config_file with None -> "None" | Some f -> f)
     ki.ki_supports_virtio ki.ki_is_xen_kernel ki.ki_is_debug

 let detect_kernels (g : G.guestfs) inspect family bootloader @@ -156,6 +158,11
@@ let detect_kernels (g : G.guestfs) inspect family bootloader               )
modules in
              assert (List.length modules > 0);

+             let config_file +               let cfg =
"/boot/config-" ^ version in
+               if List.mem cfg files then Some cfg
+               else None in
+
              let supports_virtio = List.mem "virtio_net" modules in
              let is_xen_kernel = List.mem "xennet" modules in

@@ -179,6 +186,7 @@ let detect_kernels (g : G.guestfs) inspect family bootloader
ki_supports_virtio = supports_virtio;
                ki_is_xen_kernel = is_xen_kernel;
                ki_is_debug = is_debug;
+               ki_config_file = config_file;
              }
            )

diff --git a/v2v/linux_kernels.mli b/v2v/linux_kernels.mli
index 453ce67..c01adeb 100644
--- a/v2v/linux_kernels.mli
+++ b/v2v/linux_kernels.mli
@@ -31,6 +31,7 @@ type kernel_info = {
   ki_supports_virtio : bool;       (** Kernel has virtio drivers? *)
   ki_is_xen_kernel : bool;         (** Is a Xen paravirt kernel? *)
   ki_is_debug : bool;              (** Is debug kernel? *)
+  ki_config_file : string option;  (** Path of config file, if found. *)
 }
 (** Kernel information. *)

--
2.7.4