On Tue, Oct 20, 2015 at 04:08:14PM +0300, Roman Kagan wrote:
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 633c29f..afffde2 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -103,26 +103,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
@@ -820,6 +801,30 @@ and do_convert g inspect source keep_serial_console =
guestcaps
+and 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
+
(* Update the target_actual_size field in the target structure. *)
and actual_target_size target =
{ target with target_actual_size = du target.target_file }
Straight refactor, ACK.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW