[Libguestfs] [PATCH 3/3] v2v: linux: install QEMU-GA

Tomáš Golembiovský tgolembi at redhat.com
Tue Nov 6 10:44:15 UTC 2018


Signed-off-by: Tomáš Golembiovský <tgolembi at redhat.com>
---
 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;
+
     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")
+        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. *)
+
 (* The following function is only exported for unit tests. *)
 module UNIT_TESTS : sig
   val virtio_iso_path_matches_guest_os : string -> Types.inspect -> bool
-- 
2.19.0




More information about the Libguestfs mailing list