[Libguestfs] [PATCH v2 11/11] v2v: improve initrd search

Richard W.M. Jones rjones at redhat.com
Fri May 20 09:33:54 UTC 2016


On Wed, May 18, 2016 at 02:00:59PM +0200, Cédric Bosdonnat wrote:
> 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/<version>/ 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 e23cd64..08b27d6 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:

This is fixed now, ACK.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top




More information about the Libguestfs mailing list