|
|
ffd6ed |
From 3da2c223701e870e76eb6815527bd880028253d6 Mon Sep 17 00:00:00 2001
|
|
|
ffd6ed |
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
|
ffd6ed |
Date: Thu, 30 Apr 2015 14:09:46 +0100
|
|
|
ffd6ed |
Subject: [PATCH] v2v: efi: Detect if the guest could boot with UEFI.
|
|
|
ffd6ed |
|
|
|
ffd6ed |
Use a heuristic to detect if the guest could boot with UEFI.
|
|
|
ffd6ed |
|
|
|
ffd6ed |
This is only used where we have missing metadata (in the
|
|
|
ffd6ed |
source.s_firmware == UnknownFirmware case). Currently that only
|
|
|
ffd6ed |
applies for `-i disk' and `-i libvirt/libvirtxml'.
|
|
|
ffd6ed |
|
|
|
ffd6ed |
Eventually we'll be able to get this information from the libvirt
|
|
|
ffd6ed |
metadata (RHBZ#1217444), so it'll only be used for `-i disk'.
|
|
|
ffd6ed |
|
|
|
ffd6ed |
(cherry picked from commit 6a76d6d780a8a833c9762195a79515bbc65704a0)
|
|
|
ffd6ed |
---
|
|
|
ffd6ed |
v2v/types.ml | 1 +
|
|
|
ffd6ed |
v2v/types.mli | 1 +
|
|
|
ffd6ed |
v2v/v2v.ml | 19 ++++++++++++++++++-
|
|
|
ffd6ed |
3 files changed, 20 insertions(+), 1 deletion(-)
|
|
|
ffd6ed |
|
|
|
ffd6ed |
diff --git a/v2v/types.ml b/v2v/types.ml
|
|
|
ffd6ed |
index d173c91..9dbdac0 100644
|
|
|
ffd6ed |
--- a/v2v/types.ml
|
|
|
ffd6ed |
+++ b/v2v/types.ml
|
|
|
ffd6ed |
@@ -230,6 +230,7 @@ type inspect = {
|
|
|
ffd6ed |
i_mountpoints : (string * string) list;
|
|
|
ffd6ed |
i_apps : Guestfs.application2 list;
|
|
|
ffd6ed |
i_apps_map : Guestfs.application2 list StringMap.t;
|
|
|
ffd6ed |
+ i_uefi : bool;
|
|
|
ffd6ed |
}
|
|
|
ffd6ed |
|
|
|
ffd6ed |
type mpstat = {
|
|
|
ffd6ed |
diff --git a/v2v/types.mli b/v2v/types.mli
|
|
|
ffd6ed |
index ade1edb..16f5808 100644
|
|
|
ffd6ed |
--- a/v2v/types.mli
|
|
|
ffd6ed |
+++ b/v2v/types.mli
|
|
|
ffd6ed |
@@ -150,6 +150,7 @@ type inspect = {
|
|
|
ffd6ed |
(** This is a map from the app name to the application object.
|
|
|
ffd6ed |
Since RPM allows multiple packages with the same name to be
|
|
|
ffd6ed |
installed, the value is a list. *)
|
|
|
ffd6ed |
+ i_uefi : bool; (** True if the guest could boot with UEFI. *)
|
|
|
ffd6ed |
}
|
|
|
ffd6ed |
(** Inspection information. *)
|
|
|
ffd6ed |
|
|
|
ffd6ed |
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
|
|
|
ffd6ed |
index 1ab6a24..3c0c4aa 100644
|
|
|
ffd6ed |
--- a/v2v/v2v.ml
|
|
|
ffd6ed |
+++ b/v2v/v2v.ml
|
|
|
ffd6ed |
@@ -522,6 +522,22 @@ and inspect_source g root_choice =
|
|
|
ffd6ed |
StringMap.add name (app :: vs) map
|
|
|
ffd6ed |
) StringMap.empty apps in
|
|
|
ffd6ed |
|
|
|
ffd6ed |
+ (* See if this guest could use UEFI to boot. It should use GPT and
|
|
|
ffd6ed |
+ * it should have an EFI System Partition (ESP).
|
|
|
ffd6ed |
+ *)
|
|
|
ffd6ed |
+ let uefi =
|
|
|
ffd6ed |
+ let rec uefi_ESP_guid = "C12A7328-F81F-11D2-BA4B-00A0C93EC93B"
|
|
|
ffd6ed |
+ and is_uefi_ESP dev { G.part_num = partnum } =
|
|
|
ffd6ed |
+ g#part_get_gpt_type dev (Int32.to_int partnum) = uefi_ESP_guid
|
|
|
ffd6ed |
+ and is_uefi_bootable_device dev =
|
|
|
ffd6ed |
+ g#part_get_parttype dev = "gpt" && (
|
|
|
ffd6ed |
+ let partitions = Array.to_list (g#part_list dev) in
|
|
|
ffd6ed |
+ List.exists (is_uefi_ESP dev) partitions
|
|
|
ffd6ed |
+ )
|
|
|
ffd6ed |
+ in
|
|
|
ffd6ed |
+ let devices = Array.to_list (g#list_devices ()) in
|
|
|
ffd6ed |
+ List.exists is_uefi_bootable_device devices in
|
|
|
ffd6ed |
+
|
|
|
ffd6ed |
{ i_root = root;
|
|
|
ffd6ed |
i_type = g#inspect_get_type root;
|
|
|
ffd6ed |
i_distro = g#inspect_get_distro root;
|
|
|
ffd6ed |
@@ -534,7 +550,8 @@ and inspect_source g root_choice =
|
|
|
ffd6ed |
i_product_variant = g#inspect_get_product_variant root;
|
|
|
ffd6ed |
i_mountpoints = mps;
|
|
|
ffd6ed |
i_apps = apps;
|
|
|
ffd6ed |
- i_apps_map = apps_map; }
|
|
|
ffd6ed |
+ i_apps_map = apps_map;
|
|
|
ffd6ed |
+ i_uefi = uefi; }
|
|
|
ffd6ed |
|
|
|
ffd6ed |
(* Conversion can fail if there is no space on the guest filesystems
|
|
|
ffd6ed |
* (RHBZ#1139543). To avoid this situation, check there is some
|
|
|
ffd6ed |
--
|
|
|
ffd6ed |
1.8.3.1
|
|
|
ffd6ed |
|