Use firstboot script to install MSI with QEMU-GA from virtio-win ISO or
oVirt/RHV guest tools ISO.
Signed-off-by: Tomáš Golembiovský <tgolembi(a)redhat.com>
---
v2v/convert_windows.ml | 19 +++++++++++++++++++
v2v/windows_virtio.ml | 27 +++++++++++++++++++++++++++
v2v/windows_virtio.mli | 4 ++++
3 files changed, 50 insertions(+)
diff --git a/v2v/convert_windows.ml b/v2v/convert_windows.ml
index 7ea56592c..06122e42a 100644
--- a/v2v/convert_windows.ml
+++ b/v2v/convert_windows.ml
@@ -291,6 +291,13 @@ let convert (g : G.guestfs) inspect source output rcaps =
if Sys.file_exists tool_path then
configure_vmdp tool_path;
+ (* Install QEMU Guest Agent unconditionally and warn if missing *)
+ let qemu_ga_files = Windows_virtio.copy_qemu_ga g inspect in
+ if qemu_ga_files <> [] then (
+ configure_qemu_ga qemu_ga_files;
+ ) else
+ warning (f_"QEMU Guest Agent MSI not found on tools ISO/directory. You may
want to install the guest agent manually after conversion.");
+
unconfigure_xenpv ();
unconfigure_prltools ();
unconfigure_vmwaretools ()
@@ -416,6 +423,18 @@ popd
Firstboot.add_firstboot_script g inspect.i_root
"finish vmdp setup" fb_recover_script
+ and configure_qemu_ga files =
+ List.iter (
+ fun msi_path ->
+ let fb_script = "\
+echo Installing qemu-ga from " ^ msi_path ^ "
+\"\\" ^ msi_path ^ "\" /qn /forcerestart /l+*vx
\"%cd%\\qemu-ga.log\"
+" in
+ Firstboot.add_firstboot_script g inspect.i_root
+ ("install " ^ msi_path) fb_script;
+ ) files
+
+
and unconfigure_xenpv () =
match xenpv_uninst with
| None -> () (* nothing to be uninstalled *)
diff --git a/v2v/windows_virtio.ml b/v2v/windows_virtio.ml
index 56c7a6757..e040eabaf 100644
--- a/v2v/windows_virtio.ml
+++ b/v2v/windows_virtio.ml
@@ -302,6 +302,13 @@ and copy_drivers g inspect driverdir =
(fun () ->
error (f_"root directory ‘/’ is missing from the virtio-win directory or
ISO.\n\nThis should not happen and may indicate that virtio-win or virt-v2v is broken in
some way. Please report this as a bug with a full debug log."))
+and copy_qemu_ga g inspect =
+ copy_from_virtio_win g inspect "/" "/"
+ virtio_iso_path_matches_qemu_ga
+ (fun () ->
+ error (f_"root directory ‘/’ is missing from the virtio-win directory or
ISO.\n\nThis should not happen and may indicate that virtio-win or virt-v2v is broken in
some way. Please report this as a bug with a full debug log."))
+
+
(* Copy all files from virtio_win directory/ISO located in [srcdir]
* subdirectory and all its subdirectories to the [destdir]. The directory
* hierarchy is not preserved, meaning all files will be directly in [destdir].
@@ -433,6 +440,26 @@ and virtio_iso_path_matches_guest_os path inspect =
with Not_found -> false
+(* Given a path of a file relative to the root of the directory tree
+ * with virtio-win drivers, figure out if it's suitable for the
+ * specific Windows flavor of the current guest.
+ *)
+and virtio_iso_path_matches_qemu_ga path inspect =
+ let { i_arch = arch } = inspect in
+ (* Lowercased path, since the ISO may contain upper or lowercase path
+ * elements.
+ *)
+ let lc_name = String.lowercase_ascii (Filename.basename path) in
+ lc_name = "rhev-qga.msi" ||
+ match arch, lc_name with
+ | ("i386", "qemu-ga-x86.msi")
+ | ("i386", "qemu-ga-i386.msi")
+ | ("i386", "RHEV-QGA.msi")
+ | ("x86_64", "qemu-ga-x64.msi")
+ | ("x86_64", "qemu-ga-x86_64.msi")
+ | ("x86_64", "RHEV-QGA64.msi") -> true
+ | _ -> false
+
(* The following function is only exported for unit tests. *)
module UNIT_TESTS = struct
let virtio_iso_path_matches_guest_os = virtio_iso_path_matches_guest_os
diff --git a/v2v/windows_virtio.mli b/v2v/windows_virtio.mli
index ae3b7e865..731dbd6f0 100644
--- a/v2v/windows_virtio.mli
+++ b/v2v/windows_virtio.mli
@@ -44,6 +44,10 @@ val install_linux_tools : Guestfs.guestfs -> Types.inspect ->
unit
(** installs QEMU Guest Agent on Linux guest OS from the driver directory or
driver ISO. It is not fatal if we fail to install the agent. *)
+val copy_qemu_ga : Guestfs.guestfs -> Types.inspect -> string list
+(** copy MSIs (idealy just one) with QEMU Guest Agent to Windows guest. The
+ MSIs are not installed by this function. *)
+
(**/**)
(* The following function is only exported for unit tests. *)
--
2.23.0