On Tue, Nov 06, 2018 at 11:44:15AM +0100, Tomáš Golembiovský wrote:
Signed-off-by: Tomáš Golembiovský <tgolembi(a)redhat.com>
The commit message should end with " (RHBZ#1619665)."
v2v/convert_linux.ml | 2 ++
v2v/windows_virtio.ml | 30 ++++++++++++++++++++++++++++++
v2v/windows_virtio.mli | 5 +++++
3 files changed, 37 insertions(+)
diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml
index e8c64ac1b..a1bafe91a 100644
--- a/v2v/convert_linux.ml
+++ b/v2v/convert_linux.ml
@@ -81,6 +81,8 @@ let convert (g : G.guestfs) inspect source output rcaps =
let rec do_convert () =
augeas_grub_configuration ();
+ Windows_virtio.install_linux_tools g inspect;
I see why we're using Windows_virtio, but ... it's surprising!
unconfigure_xen ();
unconfigure_vbox ();
unconfigure_vmware ();
diff --git a/v2v/windows_virtio.ml b/v2v/windows_virtio.ml
index 91649694d..93b4d643e 100644
--- a/v2v/windows_virtio.ml
+++ b/v2v/windows_virtio.ml
@@ -27,6 +27,8 @@ open Regedit
open Types
open Utils
+module G = Guestfs
+
let virtio_win =
try Sys.getenv "VIRTIO_WIN"
with Not_found ->
@@ -181,6 +183,34 @@ let rec install_drivers ((g, _) as reg) inspect rcaps =
virtio_rng_supported, virtio_ballon_supported, isa_pvpanic_supported)
)
+and install_linux_tools g inspect =
+ let os = match inspect.i_distro with
+ | "fedora" -> Some "fc28"
+ | "rhel" | "centos" | "scientificlinux" |
"redhat-based"
+ | "oraclelinux" -> (match inspect.i_major_version with
+ | 6 -> Some "el6"
+ | 7 -> Some "el7"
+ | _ -> None)
+ | "sles" | "suse-based" | "opensuse" -> Some
"lp151"
+ | _ -> None in
+
+ match os with
+ | None ->
+ warning (f_"Don't know how to install guest tools on %s-%d")
Use "don’t" here (lowercase and Unicode quote).
+ inspect.i_distro inspect.i_major_version
+ | Some os ->
+ let src_path = "linux" // os in
+ let dst_path = "/var/tmp" in
+ debug "locating packages in %s" src_path;
+ let packages = copy_files g inspect src_path dst_path
+ (fun _ _ -> true) in
+ debug "done copying %d files" (List.length packages);
+ let packages = List.map ((//) dst_path) packages in
+ try
+ Linux.install g inspect packages;
+ with G.Error msg ->
+ warning (f_"Failed to install QEMU Guest Agent: %s") msg
+
and add_guestor_to_registry ((g, root) as reg) inspect drv_name drv_pciid =
let ddb_node = g#hivex_node_get_child root "DriverDatabase" in
diff --git a/v2v/windows_virtio.mli b/v2v/windows_virtio.mli
index 91b3ced45..4558d041b 100644
--- a/v2v/windows_virtio.mli
+++ b/v2v/windows_virtio.mli
@@ -42,6 +42,11 @@ val install_drivers
(**/**)
+val install_linux_tools : Guestfs.guestfs -> Types.inspect -> unit
+(** [inspect]
+ 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. *)
This definition should be above the (**/**) mark, since that mark
turns off ocamldoc and is used for undocumented functions such as the
unit tests below.
(* The following function is only exported for unit tests. *)
module UNIT_TESTS : sig
val virtio_iso_path_matches_guest_os : string -> Types.inspect -> bool
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages.
http://libguestfs.org