libguestfs/SOURCES/0061-v2v-windows-install-QEMU-Guest-Agent-MSI.patch

120 lines
4.7 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From cf06f1d264a8832aa31265da5b2a28547b0faf49 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= <tgolembi@redhat.com>
Date: Tue, 8 Oct 2019 13:16:38 +0200
Subject: [PATCH] v2v: windows: install QEMU Guest Agent MSI
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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@redhat.com>
(cherry picked from commit 00b4ed312b0ba179e9901b73c099724c3f6606b4)
---
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 75e609d61..bdb0092c3 100644
--- a/v2v/convert_windows.ml
+++ b/v2v/convert_windows.ml
@@ -293,6 +293,13 @@ let convert (g : G.guestfs) inspect source output rcaps static_ips =
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 ()
@@ -418,6 +425,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 70f0bf09d..ea7e5c02d 100644
--- a/v2v/windows_virtio.ml
+++ b/v2v/windows_virtio.ml
@@ -296,6 +296,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].
@@ -427,6 +434,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.18.4