Blame SOURCES/0014-convert_linux-extract-qemu-guest-agent-package-name.patch

696189
From 82c7526e052d2aa64a6754ff0e1082937e3ee4bc Mon Sep 17 00:00:00 2001
696189
From: Laszlo Ersek <lersek@redhat.com>
696189
Date: Mon, 13 Jun 2022 19:01:34 +0200
696189
Subject: [PATCH] convert_linux: extract qemu-guest-agent package name
696189
696189
In commit a30383e35d34 ("v2v: linux: do not install qemu-guest-agent if
696189
already installed", 2019-09-20), the name of the package providing the
696189
QEMU guest agent was hard-coded as "qemu-guest-agent", regardless of
696189
distro family. Turns out this is actually correct (and may have been
696189
intentional, only it was not specifically documented): in all OS families
696189
currently recognized by our "family" function (`RHEL_family, `ALT_family,
696189
`SUSE_family, `Debian_family), the *binary* package is indeed called
696189
"qemu-guest-agent":
696189
696189
- https://brewweb.engineering.redhat.com/brew/packageinfo?packageID=47646
696189
- http://rpmfind.net/linux/rpm2html/search.php?query=qemu-guest-agent&submit=Search+...&system=&arch=
696189
- https://packages.altlinux.org/en/sisyphus/srpms/qemu/
696189
- https://packages.debian.org/search?keywords=qemu-guest-agent&searchon=names&suite=all&section=all
696189
696189
As a way of documenting this, extract the mapping to a new helper function
696189
named "qga_pkg_of_family".
696189
696189
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2028764
696189
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
696189
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
696189
Message-Id: <20220613170135.12557-4-lersek@redhat.com>
696189
(cherry picked from commit f65e8e68fb4eb9b8d40ac0fe7bfc3122a13e5251)
696189
---
696189
 convert/convert_linux.ml | 33 +++++++++++++++++++++++++--------
696189
 1 file changed, 25 insertions(+), 8 deletions(-)
696189
696189
diff --git a/convert/convert_linux.ml b/convert/convert_linux.ml
696189
index 79462aa1..2ddbc07a 100644
696189
--- a/convert/convert_linux.ml
696189
+++ b/convert/convert_linux.ml
696189
@@ -56,6 +56,16 @@ let convert (g : G.guestfs) source inspect keep_serial_console _ =
696189
     | "debian" | "ubuntu" | "linuxmint" | "kalilinux" -> `Debian_family
696189
     | _ -> assert false in
696189
 
696189
+  (* map the OS family name to the qemu-guest-agent package name *)
696189
+  let qga_pkg_of_family =
696189
+    function
696189
+    | `RHEL_family
696189
+    | `ALT_family
696189
+    | `SUSE_family
696189
+    | `Debian_family -> Some "qemu-guest-agent"
696189
+    | _ -> None
696189
+  in
696189
+
696189
   assert (inspect.i_package_format = "rpm" || inspect.i_package_format = "deb");
696189
 
696189
   (* Fail early if i_apps is empty.  Certain steps such as kernel
696189
@@ -539,14 +549,21 @@ let convert (g : G.guestfs) source inspect keep_serial_console _ =
696189
 
696189
   and install_linux_tools () =
696189
     (* It is not fatal if we fail to install the QEMU guest agent. *)
696189
-    let has_qemu_guest_agent =
696189
-      List.exists (
696189
-        fun { G.app2_name = name } ->
696189
-          name = "qemu-guest-agent"
696189
-      ) inspect.i_apps in
696189
-    if not has_qemu_guest_agent then
696189
-      (* FIXME -- install qemu-guest-agent here *)
696189
-      ()
696189
+    match qga_pkg_of_family family with
696189
+    | None -> warning (f_"The name of the package that provides the QEMU Guest \
696189
+                          Agent for this guest OS is unknown.  The guest agent \
696189
+                          will not be installed.  Please consider reporting a \
696189
+                          bug according to the BUGS section of the virt-v2v(1) \
696189
+                          manual.")
696189
+    | Some qga_pkg ->
696189
+        let has_qemu_guest_agent =
696189
+          List.exists (
696189
+            fun { G.app2_name = name } ->
696189
+              name = qga_pkg
696189
+          ) inspect.i_apps in
696189
+        if not has_qemu_guest_agent then
696189
+          (* FIXME -- install qemu-guest-agent here *)
696189
+          ()
696189
 
696189
   and configure_kernel () =
696189
     (* Previously this function would try to install kernels, but we