Blame SOURCES/0156-v2v-efi-linux-Remove-EFI-hacks.patch

ffd6ed
From d9fe0dbe61bd8b29c9455f95aa0001b9756e5356 Mon Sep 17 00:00:00 2001
ffd6ed
From: "Richard W.M. Jones" <rjones@redhat.com>
ffd6ed
Date: Thu, 30 Apr 2015 13:24:40 +0100
ffd6ed
Subject: [PATCH] v2v: efi: linux: Remove EFI hacks.
ffd6ed
ffd6ed
Old virt-v2v had a bunch of code for removing EFI configuration from a
ffd6ed
Linux guest, and replacing it with grub.  I copied this code to new
ffd6ed
virt-v2v but it was never tested.
ffd6ed
ffd6ed
Now that OVMF exists, we can simply boot EFI guests directly on KVM.
ffd6ed
ffd6ed
Thus these hacks can finally be removed.
ffd6ed
ffd6ed
(cherry picked from commit 051f1f1a3fadcc18786c83066fba611ffe2a7995)
ffd6ed
---
ffd6ed
 v2v/convert_linux.ml | 62 ----------------------------------------------------
ffd6ed
 1 file changed, 62 deletions(-)
ffd6ed
ffd6ed
diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml
ffd6ed
index 718ddaf..3e97656 100644
ffd6ed
--- a/v2v/convert_linux.ml
ffd6ed
+++ b/v2v/convert_linux.ml
ffd6ed
@@ -114,30 +114,6 @@ let rec convert ~verbose ~keep_serial_console (g : G.guestfs) inspect source =
ffd6ed
         ) [ "/boot/grub"; "/boot" ]
ffd6ed
       with Not_found -> "" in
ffd6ed
 
ffd6ed
-  (* EFI? *)
ffd6ed
-  let efi =
ffd6ed
-    if Array.length (g#glob_expand "/boot/efi/EFI/*/grub.cfg") < 1 then
ffd6ed
-      None
ffd6ed
-    else (
ffd6ed
-      (* Check the first partition of each device looking for an EFI
ffd6ed
-       * boot partition. We can't be sure which device is the boot
ffd6ed
-       * device, so we just check them all.
ffd6ed
-       *)
ffd6ed
-      let devs = g#list_devices () in
ffd6ed
-      let devs = Array.to_list devs in
ffd6ed
-      try
ffd6ed
-        Some (
ffd6ed
-          List.find (
ffd6ed
-            fun dev ->
ffd6ed
-              try
ffd6ed
-                g#part_get_gpt_type dev 1
ffd6ed
-                = "C12A7328-F81F-11D2-BA4B-00A0C93EC93B"
ffd6ed
-              with G.Error _ -> false
ffd6ed
-          ) devs
ffd6ed
-        )
ffd6ed
-      with Not_found -> None
ffd6ed
-    ) in
ffd6ed
-
ffd6ed
   (* What kernel/kernel-like packages are installed on the current guest? *)
ffd6ed
   let installed_kernels : kernel_info list =
ffd6ed
     let rex_ko = Str.regexp ".*\\.k?o\\(\\.xz\\)?$" in
ffd6ed
@@ -681,43 +657,6 @@ let rec convert ~verbose ~keep_serial_console (g : G.guestfs) inspect source =
ffd6ed
       if !updated then g#aug_save ();
ffd6ed
     )
ffd6ed
 
ffd6ed
-  and unconfigure_efi () =
ffd6ed
-    match efi with
ffd6ed
-    | None -> ()
ffd6ed
-    | Some dev ->
ffd6ed
-      match grub with
ffd6ed
-      | `Grub1 ->
ffd6ed
-        g#cp "/etc/grub.conf" "/boot/grub/grub.conf";
ffd6ed
-        g#ln_sf "/boot/grub/grub.conf" "/etc/grub.conf";
ffd6ed
-
ffd6ed
-        (* Reload Augeas to pick up new location of grub.conf. *)
ffd6ed
-        Linux.augeas_reload verbose g;
ffd6ed
-
ffd6ed
-        ignore (g#command [| "grub-install"; dev |])
ffd6ed
-
ffd6ed
-      | `Grub2 ->
ffd6ed
-        (* EFI systems boot using grub2-efi, and probably don't have the
ffd6ed
-         * base grub2 package installed.
ffd6ed
-         *)
ffd6ed
-        Linux.install verbose g inspect ["grub2"];
ffd6ed
-
ffd6ed
-        (* Relabel the EFI boot partition as a BIOS boot partition. *)
ffd6ed
-        g#part_set_gpt_type dev 1 "21686148-6449-6E6F-744E-656564454649";
ffd6ed
-
ffd6ed
-        (* Delete the fstab entry for the EFI boot partition. *)
ffd6ed
-        let nodes = g#aug_match "/files/etc/fstab/*[file = '/boot/efi']" in
ffd6ed
-        let nodes = Array.to_list nodes in
ffd6ed
-        List.iter (fun node -> ignore (g#aug_rm node)) nodes;
ffd6ed
-        g#aug_save ();
ffd6ed
-
ffd6ed
-        (* Install grub2 in the BIOS boot partition. This overwrites the
ffd6ed
-         * previous contents of the EFI boot partition.
ffd6ed
-         *)
ffd6ed
-        ignore (g#command [| "grub2-install"; dev |]);
ffd6ed
-
ffd6ed
-        (* Re-generate the grub2 config, and put it in the correct place *)
ffd6ed
-        ignore (g#command [| "grub2-mkconfig"; "-o"; "/boot/grub2/grub.cfg" |])
ffd6ed
-
ffd6ed
   and unconfigure_kudzu () =
ffd6ed
     (* Disable kudzu in the guest
ffd6ed
      * Kudzu will detect the changed network hardware at boot time and
ffd6ed
@@ -1421,7 +1360,6 @@ let rec convert ~verbose ~keep_serial_console (g : G.guestfs) inspect source =
ffd6ed
   unconfigure_vbox ();
ffd6ed
   (*unconfigure_vmware ();*)
ffd6ed
   unconfigure_citrix ();
ffd6ed
-  unconfigure_efi ();
ffd6ed
   unconfigure_kudzu ();
ffd6ed
 
ffd6ed
   let kernel, virtio = configure_kernel () in
ffd6ed
-- 
ffd6ed
1.8.3.1
ffd6ed