mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
v2v: windows: install QEMU Guest Agent MSI
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 00b4ed312b)
This commit is contained in:
committed by
Richard W.M. Jones
parent
66cd34e84e
commit
cf06f1d264
@@ -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 *)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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. *)
|
||||
|
||||
Reference in New Issue
Block a user