[Libguestfs] [PATCH v2 5/7] v2v: linux: check also kernel config for modules

Pino Toscano ptoscano at redhat.com
Tue Sep 27 14:04:19 UTC 2016


On Friday, 26 August 2016 14:16:12 CEST Richard W.M. Jones wrote:
> On Fri, Aug 26, 2016 at 11:02:07AM +0200, Pino Toscano wrote:
> > When checking whether a kernel supports virtio or it is Xen-based, it is
> > assumed that the feature has the kernel module for it; this will fail if
> > the feature is built-in in the kernel, misrepresenting it.
> > 
> > The solution is to check the kernel configuration (/boot/config-$kver)
> > whether the feature is built-in, in case there is no module available.
> > 
> > This fixes the virtio detection on Ubuntu kernels, where virtio is
> > built in and not as module.
> 
> Should we only check the config file?  Seems like a waste of time to
> download the module names and check those, and I suppose in some
> corner case might even be misleading.

The list of modules is already downloaded for other reasons already,
see rebuild_initrd in convert_linux.ml.

Which corner cases could be in this case?  (I don't have any coming up
in my head right now, so more ideas would be welcome.)

> Also the code as it stands makes the assumption that the name of the
> CONFIG_* option is the same as the kernel module, which is not true
> for some things we care about (virtio-scsi, I think?).

OK -- I will decouple module name and config feature.

> >  v2v/convert_linux.ml | 22 ++++++++++++++++++++--
> >  1 file changed, 20 insertions(+), 2 deletions(-)
> > 
> > diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml
> > index ce9a1e3..6f96073 100644
> > --- a/v2v/convert_linux.ml
> > +++ b/v2v/convert_linux.ml
> > @@ -95,6 +95,21 @@ let rec convert ~keep_serial_console (g : G.guestfs) inspect source rcaps =
> >    (* 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
> > +      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 = Str.regexp "^initr\\(d\\|amfs\\)-.*\\(\\.img\\)?$" in
> >      filter_map (
> > @@ -193,8 +208,11 @@ let rec convert ~keep_serial_console (g : G.guestfs) inspect source rcaps =
> >               ) modules in
> >               assert (List.length modules > 0);
> >  
> > -             let supports_virtio = List.mem "virtio_net" modules in
> > -             let is_xen_kernel = List.mem "xennet" modules in
> > +             let kernel_supports what =
> > +               List.mem what modules || check_config version what in
> > +
> > +             let supports_virtio = kernel_supports "virtio_net" in
> > +             let is_xen_kernel = kernel_supports "xennet" in
> >  
> >               (* If the package name is like "kernel-debug", then it's
> >                * a debug kernel.
> 
> 

-- 
Pino Toscano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20160927/0b5e5431/attachment.sig>


More information about the Libguestfs mailing list