[Pkg-libvirt-commits] [libguestfs] 04/21: v2v: Add a check before copying that UEFI is supported (RHBZ#1184690).

Hilko Bengen bengen at moszumanska.debian.org
Sun Nov 1 17:16:18 UTC 2015


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

bengen pushed a commit to annotated tag upstream/1.29.50
in repository libguestfs.

commit b04f39bf10e4f760d880d1077e6ffb68d028c0ae
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Mon Jul 6 12:37:23 2015 +0100

    v2v: Add a check before copying that UEFI is supported (RHBZ#1184690).
    
    If UEFI is required by the guest, but not supported by the host, then
    you wouldn't see an error message until after copying.
    
    Add an additional method to the output object so we can check this
    before copying, to avoid a long wait.
    
    Thanks: Junqin Zhou
    https://bugzilla.redhat.com/show_bug.cgi?id=1184690#c22
---
 v2v/output_libvirt.ml | 12 ++++++++++++
 v2v/output_qemu.ml    |  9 +++++++++
 v2v/types.ml          |  1 +
 v2v/types.mli         |  4 ++++
 v2v/v2v.ml            | 38 +++++++++++++++++++++-----------------
 5 files changed, 47 insertions(+), 17 deletions(-)

diff --git a/v2v/output_libvirt.ml b/v2v/output_libvirt.ml
index 8cff73f..f5d82b0 100644
--- a/v2v/output_libvirt.ml
+++ b/v2v/output_libvirt.ml
@@ -368,6 +368,18 @@ class output_libvirt oc output_pool = object
         { t with target_file = target_file }
     ) targets
 
+  method check_target_firmware guestcaps target_firmware =
+    match target_firmware with
+    | TargetBIOS -> ()
+    | TargetUEFI ->
+       (* This will fail with an error if the target firmware is
+        * not installed on the host.
+        * XXX Can remove this method when libvirt supports
+        * <loader type="efi"/> since then it will be up to
+        * libvirt to check this.
+        *)
+       ignore (find_uefi_firmware guestcaps.gcaps_arch)
+
   method create_metadata source _ target_buses guestcaps _ target_firmware =
     (* We copied directly into the final pool directory.  However we
      * have to tell libvirt.
diff --git a/v2v/output_qemu.ml b/v2v/output_qemu.ml
index 3b782ba..4f9ad77 100644
--- a/v2v/output_qemu.ml
+++ b/v2v/output_qemu.ml
@@ -40,6 +40,15 @@ object
         { t with target_file = target_file }
     ) targets
 
+  method check_target_firmware guestcaps target_firmware =
+    match target_firmware with
+    | TargetBIOS -> ()
+    | TargetUEFI ->
+       (* This will fail with an error if the target firmware is
+        * not installed on the host.
+        *)
+       ignore (find_uefi_firmware guestcaps.gcaps_arch)
+
   method create_metadata source _ target_buses guestcaps inspect
                          target_firmware =
     let name = source.s_name in
diff --git a/v2v/types.ml b/v2v/types.ml
index 9a0b24b..cc417bc 100644
--- a/v2v/types.ml
+++ b/v2v/types.ml
@@ -389,6 +389,7 @@ class virtual output = object
   method virtual as_options : string
   method virtual prepare_targets : source -> target list -> target list
   method virtual supported_firmware : target_firmware list
+  method check_target_firmware (_ : guestcaps) (_ : target_firmware) = ()
   method check_target_free_space (_ : source) (_ : target list) = ()
   method disk_create = (new Guestfs.guestfs ())#disk_create
   method virtual create_metadata : source -> target list -> target_buses -> guestcaps -> inspect -> target_firmware -> unit
diff --git a/v2v/types.mli b/v2v/types.mli
index 70c6fc7..55fb09a 100644
--- a/v2v/types.mli
+++ b/v2v/types.mli
@@ -231,6 +231,10 @@ class virtual output : object
   method virtual supported_firmware : target_firmware list
   (** Does this output method support UEFI?  Allows us to abort early if
       conversion is impossible. *)
+  method check_target_firmware : guestcaps -> target_firmware -> unit
+  (** Called before conversion once the guest's target firmware is known.
+      Can be used as an additional check that the target firmware is
+      supported on the host. *)
   method check_target_free_space : source -> target list -> unit
   (** Called before conversion.  Can be used to check there is enough space
       on the target, using the [target.target_estimated_size] field. *)
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index 6bdf74b..242f129 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -221,23 +221,6 @@ let rec main () =
   message (f_"Inspecting the overlay");
   let inspect = inspect_source g root_choice in
 
-  (* Does the guest require UEFI on the target? *)
-  let target_firmware =
-    match source.s_firmware with
-    | BIOS -> TargetBIOS
-    | UEFI -> TargetUEFI
-    | UnknownFirmware ->
-       if inspect.i_uefi then TargetUEFI else TargetBIOS in
-  let supported_firmware = output#supported_firmware in
-  if not (List.mem target_firmware supported_firmware) then
-    error (f_"this guest cannot run on the target, because the target does not support %s firmware (supported firmware on target: %s)")
-          (string_of_target_firmware target_firmware)
-          (String.concat " "
-            (List.map string_of_target_firmware supported_firmware));
-  (match target_firmware with
-   | TargetBIOS -> ()
-   | TargetUEFI -> info (f_"This guest requires UEFI on the target to boot."));
-
   (* The guest free disk space check and the target free space
    * estimation both require statvfs information from mountpoints, so
    * get that information first.
@@ -311,6 +294,27 @@ let rec main () =
   g#shutdown ();
   g#close ();
 
+  (* Does the guest require UEFI on the target? *)
+  message (f_"Checking if the guest needs BIOS or UEFI to boot");
+  let target_firmware =
+    match source.s_firmware with
+    | BIOS -> TargetBIOS
+    | UEFI -> TargetUEFI
+    | UnknownFirmware ->
+       if inspect.i_uefi then TargetUEFI else TargetBIOS in
+  let supported_firmware = output#supported_firmware in
+  if not (List.mem target_firmware supported_firmware) then
+    error (f_"this guest cannot run on the target, because the target does not support %s firmware (supported firmware on target: %s)")
+          (string_of_target_firmware target_firmware)
+          (String.concat " "
+            (List.map string_of_target_firmware supported_firmware));
+
+  output#check_target_firmware guestcaps target_firmware;
+
+  (match target_firmware with
+   | TargetBIOS -> ()
+   | TargetUEFI -> info (f_"This guest requires UEFI on the target to boot."));
+
   message (f_"Assigning disks to buses");
   let target_buses = target_bus_assignment source targets guestcaps in
   if verbose () then

-- 
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