[Pkg-libvirt-commits] [libguestfs] 26/40: v2v: If non-Xen and Xen initrds match a kernel, take shortest name (RHBZ#1141145).

Hilko Bengen bengen at moszumanska.debian.org
Fri Oct 3 14:44:52 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag debian/1%1.27.44-1
in repository libguestfs.

commit e1ed66e2b1c6b94bdfe10616667fdbc299ecb800
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Fri Sep 12 15:47:07 2014 +0100

    v2v: If non-Xen and Xen initrds match a kernel, take shortest name (RHBZ#1141145).
    
    Thanks: Tingting Zheng.
---
 v2v/convert_linux.ml | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml
index baff68e..eb1b6cc 100644
--- a/v2v/convert_linux.ml
+++ b/v2v/convert_linux.ml
@@ -183,15 +183,22 @@ let rec convert ~verbose ~keep_serial_console (g : G.guestfs) inspect source =
              (* Don't consider kdump initramfs images (RHBZ#1138184). *)
              let files =
                List.filter (fun n -> string_find n "kdump.img" == -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:
+              *   initrd-2.6.18-308.el5.img
+              *   initrd-2.6.18-308.el5xen.img
+              * and kernel 2.6.18-308.el5 (non-Xen) will match both
+              * (RHBZ#1141145).
+              *)
+             let cmp a b = compare (String.length a) (String.length b) in
+             let files = List.sort cmp files in
              match files with
              | [] ->
                warning ~prog (f_"no initrd was found in /boot matching %s %s.")
                  name version;
                None
-             | [x] -> Some ("/boot/" ^ x)
-             | _ ->
-               error (f_"multiple files in /boot could be the initramfs matching %s %s.  This could be a bug in virt-v2v.")
-                 name version in
+             | x :: _ -> Some ("/boot/" ^ x) in
 
            (* Get all modules, which might include custom-installed
             * modules that don't appear in 'files' list above.

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list