[Libguestfs] [PATCH 2/3] v2v: linux: check also kernel config for modules
Richard W.M. Jones
rjones at redhat.com
Mon Oct 3 08:07:09 UTC 2016
Actually I have another comment about this patch ..
On Tue, Sep 27, 2016 at 05:58:11PM +0200, Pino Toscano wrote:
> diff --git a/v2v/linux_kernels.ml b/v2v/linux_kernels.ml
> index b292921..c197f78 100644
> --- a/v2v/linux_kernels.ml
> +++ b/v2v/linux_kernels.ml
> @@ -53,6 +53,21 @@ let detect_kernels (g : G.guestfs) inspect family bootloader =
> (* What kernel/kernel-like packages are installed on the current guest? *)
> let installed_kernels : kernel_info list =
> let rex_ko = Str.regexp ".*\\.k?o\\(\\.xz\\)?$" in
> + let check_config version feature =
> + let prefix = "^CONFIG_" ^ String.uppercase_ascii feature ^ "=" in
> + let lines = g#grep ~extended:true prefix ("/boot/config-" ^ version) in
This could fail if the config file doesn't exist or has an
unexpected name.
I don't think we should fail in that case.
I think what we should do is put the config file name in the
Linux_kernels.kernel_info struct, eg:
ki_config_file : string option;
where None would be "not found".
The check_config function can then short-circuit when ki_config_file == None.
Rich.
> + let lines = Array.to_list lines in
> + match lines with
> + | [] -> false
> + | line :: _ ->
> + let kind = snd (String.split "=" line) in
> + (match kind with
> + | "m" (* Theoretically this should not be needed, since the module
> + * would be found. *)
> + | "y" -> true
> + | _ -> false
> + )
> + in
> let rex_ko_extract = Str.regexp ".*/\\([^/]+\\)\\.k?o\\(\\.xz\\)?$" in
> let rex_initrd =
> if family = `Debian_family then
> @@ -156,7 +171,10 @@ let detect_kernels (g : G.guestfs) inspect family bootloader =
> ) modules in
> assert (List.length modules > 0);
>
> - let supports_virtio = List.mem "virtio_net" modules in
> + let kernel_supports what kconf =
> + List.mem what modules || check_config version kconf in
> +
> + let supports_virtio = kernel_supports "virtio_net" "VIRTIO_NET" in
> let is_xen_kernel = List.mem "xennet" modules in
>
> (* If the package name is like "kernel-debug", then it's
> --
> 2.7.4
>
> _______________________________________________
> Libguestfs mailing list
> Libguestfs at redhat.com
> https://www.redhat.com/mailman/listinfo/libguestfs
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/
More information about the Libguestfs
mailing list