Signed-off-by: Tomáš Golembiovský <tgole...@redhat.com>
---
 v2v/convert_linux.ml   |  2 ++
 v2v/windows_virtio.ml  | 32 ++++++++++++++++++++++++++++++++
 v2v/windows_virtio.mli |  4 ++++
 3 files changed, 38 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;
+
     unconfigure_xen ();
     unconfigure_vbox ();
     unconfigure_vmware ();
diff --git a/v2v/windows_virtio.ml b/v2v/windows_virtio.ml
index 5d3dbde4d..0b9bdfff3 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,36 @@ 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")
+        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_from_virtio_win 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_local 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..fa9997829 100644
--- a/v2v/windows_virtio.mli
+++ b/v2v/windows_virtio.mli
@@ -40,6 +40,10 @@ val install_drivers
     virtio devices if we managed to install those, or legacy devices
     if we didn't. *)
 
+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. *)
+
 (**/**)
 
 (* The following function is only exported for unit tests. *)
-- 
2.19.1

_______________________________________________
Libguestfs mailing list
Libguestfs@redhat.com
https://www.redhat.com/mailman/listinfo/libguestfs

Reply via email to