4ebc84
From d9d48602daa653635b061ef9d16d9bc5140626ce Mon Sep 17 00:00:00 2001
4ebc84
From: Pino Toscano <ptoscano@redhat.com>
4ebc84
Date: Tue, 26 Mar 2019 17:10:38 +0100
4ebc84
Subject: [PATCH] v2v: try to pick the right arch for qemu-ga pkgs
4ebc84
4ebc84
Right now the code copies, and then tries to install, all the files
4ebc84
found for the directory of a distro.  This does not take into account
4ebc84
differences in the architectures of the packages available, so a x86_64
4ebc84
package must be installed only on x86_64 guests.
4ebc84
4ebc84
As solution, filter the packages using the typical suffix used by
4ebc84
packages (so architecture + file extension), to pick only packages
4ebc84
compatible with the current guest.
4ebc84
4ebc84
(cherry picked from commit 78f08a15faca826d4f3320834eb06309ccf3ec94)
4ebc84
---
4ebc84
 v2v/windows_virtio.ml | 11 ++++++++++-
4ebc84
 1 file changed, 10 insertions(+), 1 deletion(-)
4ebc84
4ebc84
diff --git a/v2v/windows_virtio.ml b/v2v/windows_virtio.ml
4ebc84
index 92bf3ec60..a499fcf8a 100644
4ebc84
--- a/v2v/windows_virtio.ml
4ebc84
+++ b/v2v/windows_virtio.ml
4ebc84
@@ -203,10 +203,19 @@ and install_linux_tools g inspect =
4ebc84
   | Some os ->
4ebc84
       let src_path = "linux" // os in
4ebc84
       let dst_path = "/var/tmp" in
4ebc84
+      let pkg_arch = Linux.architecture_string inspect in
4ebc84
+      let pkg_ext = Linux.binary_package_extension inspect in
4ebc84
+      let package_suffixes = [
4ebc84
+        sprintf ".%s.%s" pkg_arch pkg_ext;
4ebc84
+        sprintf "_%s.%s" pkg_arch pkg_ext;
4ebc84
+      ] in
4ebc84
+      let package_filter path _ =
4ebc84
+        List.exists (String.is_suffix path) package_suffixes
4ebc84
+      in
4ebc84
       debug "locating packages in %s" src_path;
4ebc84
       let packages =
4ebc84
         copy_from_virtio_win g inspect src_path dst_path
4ebc84
-                             (fun _ _ -> true)
4ebc84
+                             package_filter
4ebc84
                              (fun () ->
4ebc84
                                warning (f_"guest tools directory ā€˜%sā€™ is missing from the virtio-win directory or ISO.\n\nGuest tools are only provided in the RHV Guest Tools ISO, so this can happen if you are using the version of virtio-win which contains just the virtio drivers.  In this case only virtio drivers can be installed in the guest, and installation of Guest Tools will be skipped.")
4ebc84
                                        src_path) in
4ebc84
-- 
4ebc84
2.21.0
4ebc84