On Thu, May 12, 2016 at 03:29:15PM +0200, Cédric Bosdonnat wrote:
+ (* Check if either RHEV-APT or VMDP exists. This is optional. *)
+ let tools = ["rhev-apt.exe"; "vmdp.exe"] in
Strong typing FTW ...
let tools = [ `RhevApt, "rhev-apt.exe"; `VmdpExe, "vmdp.exe" ] in
+ let installer =
try
- let chan = open_in rhev_apt_exe in
- close_in chan;
- Some rhev_apt_exe
- with
- Sys_error msg ->
- warning (f_"'%s' is missing. Unable to install RHEV-APT (RHEV
guest agent). Original error: %s")
- rhev_apt_exe msg;
- None in
+ let tool = List.find (
+ fun item ->
let t, tool = List.find (
fun (_, tool) ->
+ try (
+ let exe_path = virt_tools_data_dir // item in
let exe_path = virt_tools_data_dir // tool in
+ let chan = open_in exe_path in
+ close_in chan;
+ true
+ ) with _ ->
+ false
+ ) tools in
+ Some (virt_tools_data_dir // tool)
Some (t, virt_tools_data_dir // tool)
+ with Not_found -> (
+ warning (f_"Neither rhev-apt.exe nor vmdp.exe can be found. Unable to
install one of them.");
+ None
+ ) in
(* Get the Windows %systemroot%. *)
let systemroot = g#inspect_get_windows_systemroot inspect.i_root in
@@ -211,7 +218,14 @@ let convert ~keep_serial_console (g : G.guestfs) inspect source
rcaps =
(* Perform the conversion of the Windows guest. *)
let rec configure_firstboot () =
- configure_rhev_apt ();
+ match installer with
+ | None -> info (f_"No firstboot installer to configure")
No need to print anything here. We've already printed a
warning earlier.
+ | Some installer_path ->
+ let installer_name = Filename.basename installer_path in
+ match installer_name with
+ | "rhev-apt.exe" -> configure_rhev_apt ()
+ | "vmdp.exe" -> configure_vmdp ()
+ | _ -> info (f_"No setup function for installer '%s'")
installer_path;
| Some (`RhevApt, tool_path) ->
configure_rhev_apt tool_path
| Some (`VmdpExe, tool_path) ->
configure_vmdp tool_path
You'll have to make the obvious adjustments to configure_rhev_apt and
configure_vmdp.
diff --git a/v2v/windows_virtio.ml b/v2v/windows_virtio.ml
index 7e9f735..a878a3e 100644
--- a/v2v/windows_virtio.ml
+++ b/v2v/windows_virtio.ml
@@ -66,11 +66,19 @@ let rec install_drivers g inspect systemroot root current_cs rcaps =
else (
(* Can we install the block driver? *)
let block : guestcaps_block_type =
- let has_viostor = g#exists (driverdir // "viostor.inf") in
+ let filenames = ["virtio_blk"; "vrtioblk";
"viostor"] in
+ let driver_name = try (
+ List.find (
+ fun driver_file ->
+ let source = driverdir // (driver_file ^ ".sys") in
You don't need the extra parens here ^ ^ .
+ g#exists source
+ ) filenames
+ ) with Not_found -> "" in
+ let has_viostor = not (driver_name = "") in
let has_vioscsi = g#exists (driverdir // "vioscsi.inf") in
match rcaps.rcaps_block_bus, has_viostor, has_vioscsi with
| Some Virtio_blk, false, _ ->
- error (f_"there is no viostor (virtio block device) driver for this version
of Windows (%d.%d %s). virt-v2v looks for this driver in %s\n\nThe guest will be
configured to use a slower emulated device.")
+ error (f_"there is no virtio block device driver for this version of
Windows (%d.%d %s). virt-v2v looks for this driver in %s\n\nThe guest will be configured
to use a slower emulated device.")
inspect.i_major_version inspect.i_minor_version
inspect.i_arch virtio_win
@@ -79,8 +87,9 @@ let rec install_drivers g inspect systemroot root current_cs rcaps =
inspect.i_major_version inspect.i_minor_version
inspect.i_arch virtio_win
+
Seem to have added a blank line here.
| None, false, _ ->
- warning (f_"there is no viostor (virtio block device) driver for this
version of Windows (%d.%d %s). virt-v2v looks for this driver in %s\n\nThe guest will be
configured to use a slower emulated device.")
+ warning (f_"there is no virtio block device driver for this version of
Windows (%d.%d %s). virt-v2v looks for this driver in %s\n\nThe guest will be configured
to use a slower emulated device.")
inspect.i_major_version inspect.i_minor_version
inspect.i_arch virtio_win;
IDE
@@ -88,11 +97,12 @@ let rec install_drivers g inspect systemroot root current_cs rcaps =
| (Some Virtio_blk | None), true, _ ->
(* Block driver needs tweaks to allow booting; the rest is set up by PnP
* manager *)
- let source = driverdir // "viostor.sys" in
- let target = sprintf "%s/system32/drivers/viostor.sys" systemroot in
+ let source = driverdir // (driver_name ^ ".sys") in
+ let targetdir = systemroot ^ "/system32/drivers/" in
+ let target = targetdir // (driver_name ^ ".sys") in
What was wrong with using sprintf to construct the target?
let target = g#case_sensitive_path target in
g#cp source target;
- add_guestor_to_registry g root current_cs "viostor"
+ add_guestor_to_registry g root current_cs driver_name
viostor_pciid;
Virtio_blk
@@ -112,7 +122,8 @@ let rec install_drivers g inspect systemroot root current_cs rcaps =
(* Can we install the virtio-net driver? *)
let net : guestcaps_net_type =
- let has_netkvm = g#exists (driverdir // "netkvm.inf") in
+ let filenames = ["virtio_net.inf"; "netkvm.inf"] in
+ let has_netkvm = List.exists (fun driver_file -> g#exists (driverdir //
driver_file)) filenames in
This line is a bit too long.
match rcaps.rcaps_net_bus, has_netkvm with
| Some Virtio_net, false ->
error (f_"there is no virtio network driver for this version of Windows
(%d.%d %s). virt-v2v looks for this driver in %s")
--
2.6.6
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/