Signed-off-by: Roman Kagan <rkagan(a)virtuozzo.com>
---
v2v/v2v.ml | 45 +++++++++++++++++++++++++--------------------
1 file changed, 25 insertions(+), 20 deletions(-)
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index c6a567a..c1bce1b 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -399,6 +399,30 @@ let do_convert g inspect source keep_serial_console =
guestcaps
+let get_target_firmware inspect guestcaps source output =
+ (* 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."));
+
+ target_firmware
+
let rec main () =
(* Handle the command line. *)
let input, output,
@@ -461,26 +485,7 @@ 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."));
+ let target_firmware = get_target_firmware inspect guestcaps source output in
message (f_"Assigning disks to buses");
let target_buses = target_bus_assignment source targets guestcaps in
--
2.4.3